Question about Dialog Font in RC File
I noticed that when building dialogs using the VS resource editor, sometimes the dialog's definition in the .rc file will include additional parameters following the FONT designation, for example:
Code:
IDD_TESTDIALOG_DIALOG DIALOGEX 0, 0, 320, 200
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "TestDialog"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,260,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,260,23,50,14
LTEXT "TODO: Place dialog controls here.",IDC_STATIC,50,90,200,8
END
Code:
IDD_TESTDIALOG2_DIALOG DIALOGEX 0, 0, 320, 200
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "TestDialog2"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,263,7,50,16
PUSHBUTTON "Cancel",IDCANCEL,263,25,50,16
CTEXT "TODO: Place dialog controls here.",IDC_STATIC,10,96,300,8
END
Could someone provide an explanation of what those extra parameters are? Thanks ... ghovis
Re: Question about Dialog Font in RC File
Font attributes (Bold, italic, underline, etc.)
Re: Question about Dialog Font in RC File
Depending on VS versions, they are different system display logical font mappings (substitutes) that are used in dialogs, menus. It is not real font; it is just a typeface name for a font that does not exists.
Those names are mapped in:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\Current Version\FontSubstitutes
and contain font substitutes for given locale, to accommodate special characters that do not exist in 1252 code page.
"MS Sans Serif" is mapped to Helv was used by Windows versions since 3.1 before 2000 (VS 6.0). Then it was changed to "MS Shell Dlg" and "MS Shell Dlg 2" I think since VS 2000. They are mapped to Tachoma.
New applications generated with VS 2008 use "MS Shell Dlg" mapped to "Microsoft Sans Serif" but Vista is using Segoe UI 9 for a system font, that is why Vista dialogs have different face than apps built with VS.
Re: Question about Dialog Font in RC File
JohnCz and hoxsiew, thanks for the information.
JohnCz, your "mapping" discussion sort of explains my observations which caused me to start this thread. The first block of code I posted was generated by VC++6.0 by going through the MFC app wizard to create a dialog app using all default settings. The second block of code was generated using VC++2005 by going through the MFC app wizard, again with default settings. On my XP system, the default font applied to the controls in the dialog were noticeably different.
Since I prefer the appearance of the latter mapping (FONT 8, "MS Shell Dlg", 0, 0, 0x1), I was considering going back through one of my VC++6.0 apps to manually edit the .rc file to apply this font-mapping style to all the dialogs. However, I was uncertain about those extra entries (which hoxsiew describes as font attributes), so I was hesitant about making the changes before learning more.
Based solely on some 'spot checking' of .rc files, it appears VC++6.0 sometimes applies the attribute codes and sometimes doesn't. VC++2005 seems more consistent in applying them, but it'll apply "MS Shell Dlg" or "MS Sans Serif" sometimes depending upon the window styles chosen (e.g. toowindow vs. non toolwindow).
I searched MSDN trying to find some documentation on format and syntax of the .rc file entries, namely the "FONT" specification, but I couldn't really find anything useful. If you know of some reference material on this topic, that would help as well. Again thanks.
Re: Question about Dialog Font in RC File
The first is the weight of the font. It can be any one of these:
FW_DONTCARE 0
FW_THIN 100
FW_EXTRALIGHT 200
FW_LIGHT 300
FW_NORMAL 400
FW_MEDIUM 500
FW_SEMIBOLD 600
FW_BOLD 700
FW_EXTRABOLD 800
FW_HEAVY 900
The second is a boolean for italics or not (1=Italic, 0=none).
The third is the character set. It can be any of these:
ANSI_CHARSET 0
DEFAULT_CHARSET 1
SYMBOL_CHARSET 2
SHIFTJIS_CHARSET 128
HANGEUL_CHARSET 129
HANGUL_CHARSET 129
GB2312_CHARSET 134
CHINESEBIG5_CHARSET 136
OEM_CHARSET 255
JOHAB_CHARSET 130
HEBREW_CHARSET 177
ARABIC_CHARSET 178
GREEK_CHARSET 161
TURKISH_CHARSET 162
VIETNAMESE_CHARSET 163
THAI_CHARSET 222
EASTEUROPE_CHARSET 238
RUSSIAN_CHARSET 204
Re: Question about Dialog Font in RC File
Excellent info. Thanks hoxsiew.