CWindow.SetFontmethod
Creates a DPI aware logical font and sets it as the default font.
Syntax
FUNCTION SetFont (BYREF wszFaceName AS WSTRING, BYVAL lPointSize AS LONG, BYVAL lWeight AS LONG = FW_NORMAL, BYVAL bItalic AS UBYTE = FALSE, BYVAL bUnderline AS UBYTE = FALSE, BYVAL bStrikeOut AS UBYTE = FALSE, BYVAL bCharSet AS UBYTE = DEFAULT_CHARSET) AS LONG
Parameters
| Name | Description | |
|---|---|---|
wszFaceName | A string that specifies the typeface name of the font. The length of this string must not exceed 31 characters. The EnumFontFamilies function can be used to enumerate the typeface names of all currently available fonts. If wszFaceName is an empty string, GDI uses the first font that matches the other specified attributes. | |
lPointSize | Specifies the height, in logical units, of the font's character cell or character. | |
lWeight | Specifies the weight of the font in the range 0 through 1000. If this value is zero, a default weight is used. | |
bItalic | Specifies an italic font if set to CTRUE. | |
bUnderline | Specifies an underlined font if set to CTRUE. | |
bStrikeOut | Specifies a strikeout font if set to CTRUE. | |
bCharSet | Specifies the character set. The following values are predefined: ANSI_CHARSET, BALTIC_CHARSET, CHINESEBIG5_CHARSET, DEFAULT_CHARSET, EASTEUROPE_CHARSET, GB2312_CHARSET, GREEK_CHARSET, HANGUL_CHARSET, MAC_CHARSET, OEM_CHARSET, RUSSIAN_CHARSET, SHIFTJIS_CHARSET, SYMBOL_CHARSET, TURKISH_CHARSET. Korean Windows: JOHAB_CHARSET. Middle-Eastern Windows: HEBREW_CHARSET, ARABIC_CHARSET. Thai Windows: THAI_CHARSET. The OEM_CHARSET value specifies a character set that is operating-system dependent. DEFAULT_CHARSET is set to a value based on the current system locale. For example, when the system locale is English (United States), it is set as ANSI_CHARSET. Fonts with other character sets may exist in the operating system. If an application uses a font with an unknown character set, it should not attempt to translate or interpret strings that are rendered with that font. This parameter is important in the font mapping process. To ensure consistent results, specify a specific character set. If you specify a typeface name in the wszFaceName parameter, make sure that the bCharSet value matches the character set of the typeface specified in wszFaceName. | |
nWidth | The new width of the client area of the control. | |
nHeight | The new height of the client area of the control. |
Return value
CTRUE or FALSE.
Description
Creates a DPI aware logical font and sets it as the default font.
Example
pWindow.SetFont("MS Sans Serif", 8, FW_NORMAL, , , , DEFAULT_CHARSET) pWindow.SetFont("Courier New", 10, FW_BOLD, , , , DEFAULT_CHARSET) pWindow.SetFont("Marlett", 8, FW_NORMAL, , , , SYMBOL_CHARSET)
Reference
- Include file
CWindow.inc - Defined in AfxNova/CWindow.inc:1525
- Documented in Windows/Windows GUI/CWindow Class.md
- Topic: CWindow Class