In my WTL app Im trying to change the font of a static label. But CreatePointFont returns NULL. Why might this be?
CFont font;
font.CreatePointFont(120, _T("Segoe UI"));
text.Attach(GetDlgItem(IDC_MAINTEXT));
text.SetFont(font);
Are you sure that CreatePointFont
is returning NULL?
For a font to be set, it must remain in memory, whereas from your code snippet it appears that the variable font
is destroyed directly after setting it.
Declare the variable somewhere that will not be deleted during the lifetime of the text
object, such as the class if you are using an MFC object.