How do I change the font(s) in an MFC application dialog?

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.

Step 1

Add a font member object to your dialog class, like so:

   CFont m_fntBoldComic;

Step 2

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.

Step 3

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;
   ZeroMemory (&lfNew, sizeof(LOGFONT));
   lfNew.lfHeight = 18;
   lfNew.lfWeight = FW_BOLD;
   strcpy (lfNew.lfFaceName, "Comic Sans MS");
   m_ctrlRadio1.SetFont (&m_fntBoldComic, TRUE);
   // etc...

Step 4

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.