How do you retrieve what windows is using as a default font for static boxes (fontname, fontsize, etc.)?
Printable View
How do you retrieve what windows is using as a default font for static boxes (fontname, fontsize, etc.)?
I think GetSystemMetrics and SystemParametersInfo should retrieve most of what you want.
If not then you can get the metrics from the stock object SYSTEM_FONT.
Using GetStockObject I was able to get several fonts, however the following off of MSDN was NOT true (atleast in the case of this machine):
SYSTEM_FONT - 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
However, using DEFAULT_GUI_FONT as it recommends later in that same article, I was able to get something very close but not exactly equivelant to what's in my windows, both in font and in size; I'm not being anal or anything, I just want to make sure I get it correct so that there aren't any problems running the app on another machine. I don't think GetSystemMetrics or SystemParametersInfo will provide any of the information I am seeking, though I may be wrong.
Here's some of the code I've tried:
-----
hFont = CreateFont(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL);
SendMessage(hwndLabel, WM_SETFONT, (UINT) hFont, 0);
Although I thought this wouldn't do jack to change the font, it seems to change the font face to Tahoma (MS Sans Serif, Arial, or some true type font) instead of System, but the font size remains the same.
-----
hFont = GetStockObject(DEFAULT_GUI_FONT);
SendMessage(hwndLabel, WM_SETFONT, (UINT) hFont, 0);
Creates the font that's really close to what's used, but not right...
Then create a static control in the dialog editor and leave all settings as default. Then in code send it a WM_GETFONT message.