fat font in CDialog and it´s controls

How can I change all text in my CDialog-Boxes and all it´s controls, also the text the user has to put into the controls,  into fat? Please give a detailed answer.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You have to create a CFont object with the properties you want (sorry, I have no docs available here, but set the weight to FW_BOLD) and then set it to all controls by sending WM_SETFONT message (or calling the equivalent MFC CWnd::SetFont).
Derive your class from CFontDialog.
You can use the data member m_cf to modify font type, size etc before calling DoModal.
erebelAuthor Commented:
Details missing
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.


I had a similar problem. Here is my source-code:

// CEDialog.h
// Dialog-Funktion

#include "stdafx.h"
#include "syslib.h"

CCEDialog::CCEDialog(UINT nIDTemplate, CWnd* pParent)
      : CDialog(nIDTemplate, pParent)
            // HINWEIS: Der Klassen-Assistent fügt hier Elementinitialisierung ein

             FirstInit = TRUE;
            // backbrush.CreateSolidBrush(RGB(255,255,255));
        CEDlgStyle = 9;
        CEDlgHelpID = 0x00003;
            CEExplorerHinweisID = 0;

      OnInitDialog -- Initializer

      Erläuterungen:               Font erstellen und setzen;
BOOL CCEDialog::OnInitDialog()
      LOGFONT m_logfont;          // font in use for the document
      HWND hWndChild;
      int nHeight;

      // Schriftgröße bestimmen      
      CPaintDC dc(this);          
      memset(&m_logfont, 0, sizeof m_logfont);
      nHeight = -((dc.GetDeviceCaps(LOGPIXELSY) * 12) / 72);
      m_logfont.lfHeight = nHeight;   // -12
      static char BASED_CODE szArial[] = "Arial";
      lstrcpy(m_logfont.lfFaceName, szArial);
      m_logfont.lfOutPrecision = OUT_TT_PRECIS;
      m_logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
      m_logfont.lfQuality = PROOF_QUALITY;
      m_logfont.lfPitchAndFamily = FF_SWISS | VARIABLE_PITCH;
    m_logfont.lfWeight = (CEDlgStyle>=9) ? FW_NORMAL : FW_BOLD;
      if (FirstInit)
            nHeight = -((dc.GetDeviceCaps(LOGPIXELSY) * 12) / 72);
            m_logfont.lfHeight = nHeight;  
            m_logfont.lfWeight = FW_NORMAL;

            nHeight = -((dc.GetDeviceCaps(LOGPIXELSY) * 16) / 72);
            m_logfont.lfHeight = nHeight;  
            m_logfont.lfWeight = FW_BOLD;

            nHeight = -((dc.GetDeviceCaps(LOGPIXELSY) * 20) / 72);
            m_logfont.lfHeight = nHeight;  
            m_logfont.lfWeight = FW_BOLD;

            nHeight = -((dc.GetDeviceCaps(LOGPIXELSY) * 9) / 72);
            m_logfont.lfHeight = nHeight;  
            m_logfont.lfWeight = FW_NORMAL;

      for (hWndChild = ::GetTopWindow(m_hWnd); hWndChild != NULL;
            hWndChild = ::GetNextWindow(hWndChild, GW_HWNDNEXT)) {
      FirstInit = FALSE;

      return TRUE;  

void CCEDialog::DoDataExchange(CDataExchange* pDX)
            // HINWEIS: Der Klassen-Assistent fügt hier DDX- und DDV-Aufrufe ein

            // HINWEIS: Der Klassen-Assistent fügt hier Zuordnungsmakros für Nachrichten ein

// Behandlungsroutinen für Nachrichten CCEDialog

      Erläuterungen:      Hintergrundfarbe einstellen.
HBRUSH CCEDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
      HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
      return hbr;

void CCEDialog::OnDestroy()
      if (!FirstInit)


      Erläuterungen:      Hilfeaufruf mit F1
BOOL CCEDialog::OnHelpInfo(HELPINFO* pHelpInfo)
      return TRUE;

void CCEDialog::EnableGroup(int *groupField, BOOL do_enable)
      int i=0;
      while (groupField[i])
            if (!do_enable && 
                  GetDlgItem(groupField[i])->IsKindOf( RUNTIME_CLASS( CEdit ) ))
             if (!do_enable && 
                  GetDlgItem(groupField[i])->IsKindOf( RUNTIME_CLASS( CButton ) ))
                   ((CButton*)GetDlgItem(groupField[i]))->SetCheck(0);  // funktioniert nicht??????

BOOL CCEDialog::DoValidate(BOOL *Ptr)
      CWnd *cwndChild;
      BOOL (*FuncPtr) (int fldID);

      TRACE("Eintritt in Validate (CEDialog)\n");

      for (cwndChild = GetTopWindow(); cwndChild != NULL;
            cwndChild = cwndChild->GetNextWindow())
            if (cwndChild->IsWindowEnabled())
                  if (FuncPtr(cwndChild->GetDlgCtrlID()))
                        return FALSE;
      return TRUE;

BOOL CCEDialog::OnHelpDlg()
      return TRUE;

.... and here my .h-file:

// CEDialog
#define WM_WEITER 102
#define WM_HELPDLG 103
#define WM_DOCCHANGED 104
#define WM_DOCPRINT 105
#define WM_DOCSAVE 106
#define WM_DOCSHOW 107

// Dialogfeld CCEDialog

class CCEDialog : public CDialog
// Konstruktion
      CCEDialog(UINT nIDTemplate=NULL, CWnd* pParent = NULL);   // Standardkonstruktor

// Dialogfelddaten
//      enum { IDD = IDD_DIALOG2 };
            // HINWEIS: Der Klassen-Assistent fügt hier Datenelemente ein

// Überschreibungen
      // Vom Klassen-Assistenten generierte virtuelle Funktionsüberschreibungen
      virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV-Unterstützung

// Implementierung
      int ColorStyle;

      int CEDlgStyle;
      int CEDlgHelpID;
      int CEExplorerFrame;
      CString CEExplorerText;
      int CEExplorerHinweisID;

      BOOL FirstInit;

      CFont font0;            // Normal      
      CFont font1;            // Standard
      CFont font2;            // Large

      CFont fontNormal;      // Normal      
      CFont fontStandard;      // Standard
      CFont fontLarge;      // Large
      CFont fontHuge;            // z.B. für Explorer-Control
      CFont fontSmall;      // Small
      CBrush backbrush;
      void EnableGroup(int *groupField, BOOL do_enable);
      BOOL DoValidate(BOOL *Ptr);
      BOOL OnHelpDlg() ;
      // Generierte Nachrichtenzuordnungsfunktionen
      // HINWEIS: Der Klassen-Assistent fügt hier Member-Funktionen ein
        virtual BOOL OnInitDialog();
        afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
         afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
      afx_msg void OnDestroy();

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I'd say it's easier if you want the exact same font (but bold) to do something like in OnInitDialog:

CFont *pFont = GetFont();

pFont->GetObject(sizeof(LOGFONT), &lf);
lf.lfWeight = FW_BOLD;

// m_fontBold is a CFont data member

// Now call SetFont(m_fontBold) for
// every control you want with bold font

And don't forget to delete the font in OnDestroy.

Another thing that might help:

If you want to do it for every control, add this code in your OnInitDialog handler:

// m_fontBold was created with my previous code
::EnumChildWindows(m_hWnd, EnumChildPorc, (LPARAM) &m_fontBold);

and define your function EnumChildProc:

BOOL CALLBACK EnumChildProc( HWND hwnd, LPARAM lParam)
    CWnd *pWnd = CWnd::FromHandle(hwnd);
    pWnd->SetFont((CFont *) lParam);
    return TRUE;

and that's it!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.