Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Default font used by a dialog

352 views
Skip to first unread message

Sujata R. Naik

unread,
Feb 26, 2003, 8:14:46 AM2/26/03
to
Hi,

I have the following dialog control:

IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 230, 75
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "About"
//FONT 8, "System"
BEGIN
ICON IDI_SIMPLEWIN32,IDC_MYICON,14,9,16,16
LTEXT "simplewin32 Version
1.0",IDC_STATIC,49,10,119,8,SS_NOPREFIX
LTEXT "Copyright (C)
2003",IDC_STATIC,49,20,119,8
DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP
END

The FONT line has been commented out intentionally. Which
font does the dialog use in this case?

Cheers,
Sujata

Jeff Partch

unread,
Feb 26, 2003, 9:23:28 AM2/26/03
to
"Sujata R. Naik" <sujat...@rediffmail.com> wrote in message
news:05b601c2dd99$0882a670$a501...@phx.gbl...

The seemingly relevant documentation appears under the subtopic "Dialog
Box Fonts" at the following URL...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/aboutdialogboxes.asp

...wherein it claims that, "By default, the system draws all text in a
dialog box using the SYSTEM_FONT font", and following this lead to the
GetStockObject documentation...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_1t10.asp

...we find SYSTEM_FONT described as, "System font. By default, the
system uses the system font to draw menus, dialog box controls, and
text. Windows 95/98 and Windows NT: The system font is MS Sans Serif.
Windows 2000/XP: The system font is Tahoma".

--
Jeff Partch [VC++ MVP]


Joe Woodbury

unread,
Feb 27, 2003, 12:24:00 AM2/27/03
to
> ...wherein it claims that, "By default, the system draws all text in a
> dialog box using the SYSTEM_FONT font", and following this lead to the
> GetStockObject documentation...
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons
_1t10.asp
>
> ...we find SYSTEM_FONT described as, "System font. By default, the
> system uses the system font to draw menus, dialog box controls, and
> text. Windows 95/98 and Windows NT: The system font is MS Sans Serif.
> Windows 2000/XP: The system font is Tahoma".

Unfortunately, the documentation is in error as can be proven with a simple
test. SYSTEM_FONT returns the old bold proportional spaced font that goes, I
think, back to Windows 3.0.

My testing seems to show that the documentation for SYSTEM_FONT should
instead be applied to DEFAULT_GUI_FONT.


Quixote

unread,
Feb 27, 2003, 12:23:45 AM2/27/03
to

"Jeff Partch" <je...@mvps.org> wrote in message
news:OelTfKa3...@TK2MSFTNGP12.phx.gbl...


That documentation has been revised recently and they have managed to make a
complete mess of it. The System font is what you get from
GetStockObject(SYSTEM_FONT) and you can easily confirm with the following
code that it is neither MS Sans Serif nor Tahoma. It is in fact a font named
"System" and it is a bitmap font (MS Sans Serif is also a bitmap font, but
Tahoma is a True Type font).

TEXTMETRIC tm;
TCHAR nameBuffer[LF_FACESIZE], fullBuffer[100];
HFONT hfont = (HFONT)GetStockObject (SYSTEM_FONT);
HDC hdc = GetDC(hwnd);
SelectObject(hdc, hfont);
GetTextFace(hdc, LF_FACESIZE, nameBuffer);
GetTextMetrics(hdc, &tm);
if (tm.tmPitchAndFamily & TMPF_TRUETYPE)
wsprintf(fullBuffer, _T("Name is %s and it is a True Type font"),
nameBuffer);
else
wsprintf(fullBuffer, _T("Name is %s and it is NOT a True Type font"),
nameBuffer);
MessageBox(hwnd, fullBuffer, _T(""), MB_OK);
ReleaseDC(hwnd, hdc);


--

Quixote
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)


Sujata R. Naik

unread,
Feb 27, 2003, 12:42:06 AM2/27/03
to
Hi Jeff,

Actually what I want to know is whether there is way to
manipulate SYSTEM_FONT. I am on an XP. I want to use
Tahoma point size 8, but SYSTEM_FONT seems to be a larger
Tahoma font. I do not want to "hard-code" the font with
the statement

FONT 8, 'Tahoma'

in the dialog.

Regards,
Sujata

>....wherein it claims that, "By default, the system draws

all text in a
>dialog box using the SYSTEM_FONT font", and following
this lead to the
>GetStockObject documentation...
>
>http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/gdi/devcons_1t10.asp
>

>....we find SYSTEM_FONT described as, "System font. By

default, the
>system uses the system font to draw menus, dialog box
controls, and
>text. Windows 95/98 and Windows NT: The system font is MS
Sans Serif.
>Windows 2000/XP: The system font is Tahoma".
>
>--
>Jeff Partch [VC++ MVP]
>
>

>.
>

David Liebtag

unread,
Feb 27, 2003, 12:54:45 AM2/27/03
to
Sujata,

Maybe you could code this:

FONT 8,"MS Shell Dlg"

Then, you would get the shell's default dialog font and can specify the size
you want.

David Liebtag
IBM APL Products and Services


Jeff Partch

unread,
Feb 27, 2003, 8:56:49 AM2/27/03
to
"Quixote" <donald...@datafast.net.au> wrote in message
news:uZW2dDi...@TK2MSFTNGP12.phx.gbl...

> "Jeff Partch" <je...@mvps.org> wrote in message
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons
> _1t10.asp
> >
> > ...we find SYSTEM_FONT described as, "System font. By default, the
> > system uses the system font to draw menus, dialog box controls, and
> > text. Windows 95/98 and Windows NT: The system font is MS Sans
Serif.
> > Windows 2000/XP: The system font is Tahoma".
> >
>
> That documentation has been revised recently and they have managed to
make a
> complete mess of it. The System font is what you get from
> GetStockObject(SYSTEM_FONT) and you can easily confirm with the
following
> code that it is neither MS Sans Serif nor Tahoma. It is in fact a font
named
> "System" and it is a bitmap font (MS Sans Serif is also a bitmap font,
but
> Tahoma is a True Type font).

Thanks, Don! Clearly this is the case and the documentation is just
plain wrong.

Jeff Partch

unread,
Feb 27, 2003, 9:01:20 AM2/27/03
to
"Joe Woodbury" <joe_wo...@yahoo.com> wrote in message
news:u6z8vBi3...@TK2MSFTNGP12.phx.gbl...

Thanks, Joe! That does seem to be the case. In fact it looks to me like
maybe the two definitions are reversed.

Quixote

unread,
Mar 3, 2003, 8:20:23 AM3/3/03
to

I've done a little more experimentation in reponse to David Ching's recent
post. In fact the DEFAULT_GUI_FONT documentation is correct, i.e., the
DEFAULT_GUI_FONT font is MS Sans Serif on all Windows versions up to and
including Windows XP, as the documentation states.

If you call GetObject on the handle returned for the DEFAULT_GUI_FONT, then
the font is called MS Shell Dlg on Windows 2000/XP. But MS Shell Dlg maps to
MS Sans Serif in this context and in any CreateFont call (even though, just
to create maximum confusion, MS Shell Dlg maps to Tahoma when used in a
dialog box resource file).

David Ching

unread,
Mar 3, 2003, 9:47:04 AM3/3/03
to

"Quixote" <donald...@datafast.net.au> wrote in message
news:OWrP4eY4...@TK2MSFTNGP10.phx.gbl...

Quixote, thanks for checking into this and confirming what I had seen. Yes,
DEFAULT_GUI_FONT always returns MS Sans Serif, as documented. However, this
breaks a lot of existing code, as the programmer's intent is to use
DEFAULT_GUI_FONT to match the dialog font, and if the Windows OS changes the
dialog font, then we want DEFAULT_GUI_FONT to return the new dialog font.

It wouldn't be so bad if SYSTEM_FONT worked as documented, because this is
supposed to match the dialog font (Tahoma in 2K/XP and MS Sans Serif
elsewhere). However, as was reported by Joe Woodbury, it returns an ugly
font looking like Win 3.0.

Hence, I plan to search all my code for DEFAULT_GUI_FONT, and if Win2K or
greater, change the requested face name to "MS Shell Dlg 2". <Sigh> How
did this get past QA?

Thanks again,
David


Jeff Partch

unread,
Mar 3, 2003, 10:12:43 AM3/3/03
to
"Quixote" <donald...@datafast.net.au> wrote in message
news:OWrP4eY4...@TK2MSFTNGP10.phx.gbl...
>
>

I did some looking into it after both of your posts last week. I think I
found 24 different combinations of DIALOG, DIALOGEX, DS_SETFONT,
DS_SHELLFONT and the FONT statement using "MS Sans Serif", "MS Shell
Dlg" and "MS Shell Dlg2" and I could get anything from "System",
"Fixedsys", "MS Sans Serif", "MS Shell Dlg" and ""MS Shell Dlg 2". For
example: using DIALOGEX and DS_SHELLFONT and FONT 8, "MS Shell Dlg"
results in a dialog wath a font who's facename is "MS Shell Dlg 2" on
this XPSP1 system. And the registry mapping of "MS Shell Dlg 2" is to
"Tahoma". In the absence of any of these modifiers the font used by a
dialog is SYSTEM_FONT (or rather WM_GETFONT returns NULL and the font
sure looks like it), and this is what I consider to be "the default font
used by dialog boxes and controls". Anyway, after a while the issue made
my head hurt, so I just informed MS that maybe they should revisit the
accuracy of the documentation. Some of what I said was:

<quote>
"DEFAULT_GUI_FONT Default font for user interface objects such as menus
and dialog boxes. This is MS Sans Serif. Compare this with SYSTEM_FONT".

A test on XPSP1 using the returned HFONT and GetTextFace indicates that
the name of SYSTEM_FONT is "System" and the name of DEFAULT_GUI_FONT is
"MS Shell Dlg". The registry mapping at...

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\FontSubstitutes
MS Shell Dlg "Microsoft Sans Serif"

...seems to indicate that DEFAULT_GUI_FONT is thus "Microsoft Sans
Serif" and is actually neither "MS Sans Serif" nor "Tahoma".

The system may or may not use "Tahoma" for menus on 2k/XP and "MS Sans
Serif" on 9x, but this is certainly not the default font used for
dialog boxes or controls.
</quote>

Quixote

unread,
Mar 3, 2003, 6:26:15 PM3/3/03
to
Jeff Partch wrote:
> "Quixote" <donald...@datafast.net.au> wrote in message
> news:OWrP4eY4...@TK2MSFTNGP10.phx.gbl...
> >

Yes, you appear to be correct on this. I concluded that it was MS Sans Serif
based on visual comparisons and the fact that DEFAULT_GUI_FONT is documented
to be MS Sans Serif. But I have just looked at the tmPitchAndFamily field of
the TEXTMETRIC structure and it shows a True Type font --- Microsoft Sans
Serif being the True Type version of MS Sans Serif.

> The system may or may not use "Tahoma" for menus on 2k/XP and "MS Sans
> Serif" on 9x, but this is certainly not the default font used for
> dialog boxes or controls.
> </quote>

Thanks for your labours on our behalf. I have been an admirer of your
contributions for some time.

Jeff Partch

unread,
Mar 4, 2003, 8:32:58 AM3/4/03
to
Urm...thanks for the kind words, Don :)
0 new messages