Date: | February 4, 2005 / year-entry #31 |
Tags: | code |
Orig Link: | https://blogs.msdn.microsoft.com/oldnewthing/20050204-00/?p=36523 |
Comments: | 34 |
Summary: | It indicates that you want the Windows 2000 default shell font. But that doesn't mean that you're going to get it. In order to indicate that you would like the "Windows 2000" look for your dialog, you have to do three things and hope for a fourth: Use a DIALOGEX template instead of a DIALOG template. Set... |
It indicates that you want the Windows 2000 default shell font. But that doesn't mean that you're going to get it. In order to indicate that you would like the "Windows 2000" look for your dialog, you have to do three things and hope for a fourth:
If all four conditions are satisfied, then your dialog gets the "Windows 2000" look. If any condition fails, then you get the "classic" dialog font. Note that the fourth condition is not within your program's control. Consequently, you have to make sure your dialog looks good in both the "classic" dialog font and the new one. For property sheet pages, things are more complicated. It would be visually jarring for there to be a mix of fonts on a property sheet. You wouldn't want the "Advanced" button to be in MS Sans Serif but the "Apply" button in Tahoma. To avoid this problem, the property sheet manager looks at all the pages in the property sheet. If they are all using the "Windows 2000" look, then the property sheet uses the "Windows 2000" look also. But if there is even a single page that does not use the "Windows 2000" look, then the property sheet reverts to the "classic" look and also converts all the "Windows 2000"-look pages to "classic" look. This way, all the pages in the property sheet have the "classic" look instead of having a mishmash of some pages with the classic look and some with the Windows 2000 look. That's why you will occasionally find that a shell property sheet has reverted to the "classic" look. Some shell extension infected the property sheet with a page that does not have the "Windows 2000" look, and for the sake of visual consistency, the property sheet manager set all the pages on the property sheet to "classic" look. This is another reason it is important that you test your property sheet pages both with the "Windows 2000" look and the "classic" look. If your property sheet page ends up sharing a property sheet with a non-"Windows 2000"-look page, your page is going to be reverted to "classic" look. |
Comments (34)
Comments are closed. |
Now if only we could get all property sheets to use visual styles… The all-too-frequent mixing of themed and non-themed backgrounds is definitely a visually jarring experience.
What’s the difference between ‘MS Sans Serif’ and ‘Microsoft Sans Serif’?
And which font will be used in a dialog, if shell font is NOT granted?
Whatever font you would have gotten if you hadn’t said DS_SHELLFONT.
What is the purpose of DS_SHELLFONT then?
I mean, using "MS Shell Dlg" tell the system to map the font using current locale and other settings, so font is substituted anyway. Acording to MSDN, DS_SHELLFONT allows chaging font’s size/weight, but same can be done via DS_SETFONT. Isn’t this like using two flags for same thing, or DS_SHELLFONT does something extra?
Please read the first sentence of the article.
I have no idea what this is all about. I wish there were some pictures to show what you’re talking about.
Yes, I did read it. What I try to figure is why both DS_SHELLFONT and "MS Shell Dlg" should be used to indicate shell font. DS_SHELLFONT simple affects font mapper behave. I simply try to figure why it is impossible to use shell font OR user-defined font, or in other words, why DS_SHELLFONT works ONLY with "MS Shell Dlg".
"Why both DS_SHELLFONT and ‘MS Shell Dlg’ should be used to indicate shell font."
Feel free to propose an alternative algorithm that remains backwards compatible with NT 4.
Hm interesting article, that saves me changing the fonts with WM_SETFONT for my controls to Tahoma if the font is present.
Is there a way to determine the default shell font in Win 2000/XP?
Why is it always 8 pt (2.82 mm). I have to edit the dlg template resource in programs like Character Map and Calculator to be able to see it. At 12 pt I can see the characters in character map but the status bar is off screen.
I went back and was fixing a shell extension of mine to use this, and came across what seems like an additional requirement: DS_3DLOOK. Without it, I was getting MS Sans Serif; with it, I got Tahoma.
Jonathan: actually it works without explicitly specifying DS_3DLOOK. Are you sure you’re using DIALOGEX?
Now if only Visual Studio (version 6) actually allowed you to specify "MS Shell Dlg" as the dialog font. It always replaces it with whatever its own dialog font is (MS Sans Serif).
How is "MS Shell Dlg 2" related to this?
"MS Shell Dlg 2" is another name for the "Windows 2000 look".
Tom: Yes, I’m using DIALOGEX. But I guess I was wrong after all–I just tried it again (without DS_3DLOOK) and it worked correctly. Could’ve sworn it wasn’t working last night ;-)
Tom wrote:
"Is there a way to determine the default shell font in Win 2000/XP?"
1. GetStockObject(SYSTEM_FONT)
2. GetObject()
GetStockObject( DEFAULT_GUI_FONT ) ?
I’ve always used GetStockObject(DEFAULT_GUI_FONT) without any problem.
I just ran the following quick test on Windows XP SP2:
1. Call GetStockObject(DEFAULT_GUI_FONT).
2. Select the returned font handle into a display context.
3. Call GetTextFace() on the display context to retrieve the name of the selected font.
According to GetTextFace(), GetStockObject(DEFAULT_GUI_FONT) returns "MS Shell Dlg", which sounds right to me.
My FontSubstitutes table maps "MS Shell Dlg" to "Myriad Condensed Web Italic", and the actual font used is indeed Myriad Condensed Web Italic. On an uncustomized Windows XP system, it would map to "Tahoma" instead.
Correction: On an uncustomized Windows XP system, "MS Shell Dlg" maps to "Microsoft Sans Serif" (a TrueType rendition of the venerable MS Sans Serif). "MS Shell Dlg 2" maps to "Tahoma".
Going back to Tom’s original question (how to determine the default shell font in Windows 2000/XP): Alex’s answer is correct in the sense that MS Shell Dlg can be called the default shell font. Note that the name "MS Shell Dlg" can actually be used directly in most contexts; Windows will silently do the mapping for you.
If you’re interested in the "Windows 2000"-look GUI font, you can similarly use the name "MS Shell Dlg 2" directly, and not worry about what font is actually being used behind the scenes.
However, if you’re looking to determine what actual font "MS Shell Dlg" (or "MS Shell Dlg 2") maps to, I have no better answer than A’s suggestion that you dig into the FontSubstitutes table in the registry. (Querying an existing DS_SHELLFONT dialog would probably just spit back the "MS Shell Dlg" or "MS Shell Dlg 2" name.) However, going into the registry for this is not something I would recommend.
I hope there’s a clean way to do it.
When would a problem need to know what "MS Shell Dlg" maps to? If it wants to use the default shell font then use ‘MS Shell Dlg’ and let the font mapper do its job.
2/4/2005 1:52 PM David Candy
> Why is it always 8 pt (2.82 mm).
It isn’t.
2/6/2005 3:56 PM Raymond Chen
> When would a problem need to know what
> "MS Shell Dlg" maps to?
Aha. OK, it might be that no application needs to know what font it gets mapped to, but sometimes applications need to know what size of font gets mapped to. If they assume 8 then you know what happens. (By the way despite recent examples, fortunately this happens a lot less often now than in the past.)
BTW, what’s the story behind "native font control" (http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/faq/localization.asp)?
There’s a suggestion box – please use it. If you ask here I will probably forget.
J. Edward Sanchez wrote:
"However, if you’re looking to determine what actual font "MS Shell Dlg" (or "MS Shell Dlg 2") maps to, I have no better answer than A’s suggestion that you dig into the FontSubstitutes table in the registry."
I tried
SystemParametersInfo(SPI_GETICONTITLELOGFONT, …) and it seems that this function does perform font mapping. However, I can’t imagine for now why do I want to know that.
Can you use, say, FONT 8, "MS Shell Dlg" *without* using DS_SHELLFONT?
If so what’s the difference between this and declaring it with DS_SHELLFONT?
If not then that answers Waleri’s question too.
now I modified an existing dialog with the described changes (DIALOGEX, style flags, font). I noticed, CCheckListBox items don’t draw the right edge of the checkbox correctly – is this a known problem? I temporary added a space at the beginning of each string :-(.
Note: this only happens with some characters at beginning – e.g. ‘a’, it doesn’t happen with ‘1’.
Any ideas?
Rookie: If you don’t use DS_SHELLFONT, you get plain old "MS Shell Dlg", which by default maps to "Microsoft Sans Serif" on Windows XP. If you use DS_SHELLFONT, you get "MS Shell Dlg 2" (the "Windows 2000"-look font), which maps to "Tahoma" by default on Windows XP.
You might ask: Why not just use "MS Shell Dlg 2" directly? Because older versions of Windows don’t support it. Using "MS Shell Dlg" with a supplementary flag allows for graceful degradation on older versions of Windows.
For more information, see:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_4qcn.asp
This link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_4qcn.asp
Says: "specify DS_SHELLFONT with MS Shell Dlg 2 to map to Tahoma."
Wait, I thought Raymond just said to use DS_SHELLFONT with "MS Shell Dlg" (not 2)?
If you say "MS Shell Dlg 2" then you don’t need to say DS_SHELLFONT.
I have talked in this blog about a lot of different kind of font mapping features in various Microsoft…