Pretty easy this, but not obvious. Sure, it looks like all you have to do is send a WM_SETFONT message, and that's true, but you need the new font in order to send the message. So we have a create a font object, and make sure it stays alive for long enough so that the dialog can use it.
Add a font member object to your dialog class, like so:
private: CFont m_fntBoldComic;
Create a control member variable for the item you want to change. NOTE: If the item is static text, give it a new ID, don't use ID_STATIC.
Create your font object when the dialog initialises, after the base class handler has been called, then call the CWnd member SetFont function against the member variable you created in Step 2. I'm changing a radio button label here.
BOOL CTestbed2Dlg::OnInitDialog() { LOGFONT lfNew; CDialog::OnInitDialog(); ZeroMemory (&lfNew, sizeof(LOGFONT)); lfNew.lfHeight = 18; lfNew.lfWeight = FW_BOLD; strcpy (lfNew.lfFaceName, "Comic Sans MS"); m_fntBoldComic.CreateFontIndirect(&lfNew); m_ctrlRadio1.SetFont (&m_fntBoldComic, TRUE); // etc... }
Don't forget to make the dialog control big enough to contain the text after you've changed it :-)
And that's all there is to it. The font object lives for as long as the dialog does, because it's a member.
Download