Web and Software: Inheriting system settings
Windows provides the control panel function, (Control Panel, Display Properties, Appearance) to set the font size. The user has the option of setting 3 relative sizes, “normal”, “large”, and “extra large”. Once set, the font size is uniformly supported by non-client areas such as the window title, menus and system messages. Client areas, and dialogs do not uniformly support this setting.
A program could support this setting by basing their font size on the system setting. This can be done by using the SystemParametersInfo call, passing the SPI_GETNONCLIENTMETRICS system information structure.
The nonClientMetrics structure contains pointers to the logical font (LOGFONT) for the system menu bar, and message fonts. Software can then use the font information to select the font object to be used to display text. SelectObject(hdc, hFont). The code fragment provides an outline of this support.
Void GetClientMetrics(hDC, hWnd)
{
nonClientMetrics.cbSize =sizeof(NONCLIENTMETRICS); // get system metrics information
fResult = SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(NONCLIENTMETRICS),
&nonClientMetrics,
0);
logFont=&nonClientMetrics.lfMessageFont; /* Create the font */
hFont = CreateFontIndirect (logFont); /* Set the logical font to be based on the Message Font */
SelectObject(hdc, hFont);
/* and so on */
}
The font size should be set in an initialization procedure, and also supported dynamically by processing the WM_THEMECHANGED message and responding to the user settings.