Ask a question:
Based on the contents of the text file, the control is dynamically created with Cwin subclasses. In the Create method, all controls are created with the following code, based on the message text font selected by the user in the Display Properties dialog box:
Nonclientmetrics NCM;
ncm.cbsize = sizeof (nonclientmetrics);
SystemParametersInfo (spi_getnonclientmetrics, sizeof (NCM), &NCM, 0);
M_defaultfont.createfontindirect (&ncm.lfmessagefont);
After you get the font, the next question is how to determine the height and width of the static control to display the full text?
The first thing to be clear is that the Display Properties dialog box is right-click on the desktop, select the Properties menu item, and then select the dialog box (figure I) that appears in the Appearance property page.
Figure I
The user can select the active window, the message box, and the color and font of the text in this dialog box. You can call the SystemParametersInfo function and use Spi_getnonclientmetrics as the first parameter to find out what font the user has chosen; systemparametersinfo function to fill in the nonclientmetrics structure with the information you need:
// NONCLIENTMETRICS 结构(winuser.h)
//
struct NONCLIENTMETRICS
{
UINT cbSize;
int iBorderWidth;
int iScrollWidth;
int iScrollHeight;
int iCaptionWidth;
int iCaptionHeight;
LOGFONT lfCaptionFont;
int iSmCaptionWidth;
int iSmCaptionHeight;
LOGFONT lfSmCaptionFont;
int iMenuWidth;
int iMenuHeight;
LOGFONT lfMenuFont;
LOGFONT lfStatusFont;
LOGFONT lfMessageFont;
};