codingForFun
codingForFun

Reputation: 123

Is there a way to change the title font for a MFC SDI application?

I am trying to increase the font size for the title on the MainFrame. So far, I have tried several approaches without a good result. Any suggestions are welcome.

A. Approach 1

    void CMainFrame::OnPaint()
{
CPaintDC dc(this); // device context for painting
    LOGFONT lF;
    lF.lfHeight = 10;
    lF.lfWidth = 0;
    lF.lfWeight = FW_NORMAL;
    lF.lfItalic = FALSE; //TRUE;
    lF.lfUnderline = FALSE; //TRUE;
    lF.lfStrikeOut = FALSE; //TRUE;
    lF.lfEscapement = 0;
    lF.lfOrientation = 0;
    _tcscpy_s(lF.lfFaceName, _T("Verdana"));

    CFont m_font;
    m_font.CreateFontIndirect(&lF);
    SetFont(&m_font);
       }

It doesn't change a thing.

B. Approach 2

     void CMainFrame::OnPaint()
     {
     CPaintDC dc(this); // device context for painting
    LOGFONT lF;
    lF.lfHeight = 10;
    lF.lfWidth = 0;
    lF.lfWeight = FW_NORMAL;
    lF.lfItalic = FALSE; //TRUE;
    lF.lfUnderline = FALSE; //TRUE;
    lF.lfStrikeOut = FALSE; //TRUE;
    lF.lfEscapement = 0;
    lF.lfOrientation = 0;
    _tcscpy_s(lF.lfFaceName, _T("Verdana"));

    CFont m_font;
    m_font.CreateFontIndirect(&lF);
    BOOL fRedraw = TRUE;
    SendMessageToDescendants(WM_SETFONT, (WPARAM)m_font.m_hObject);
      }

This approach deletes all my ribbon menus and creates a lot of exceptions.

Upvotes: 0

Views: 1730

Answers (2)

Surak of Vulcan
Surak of Vulcan

Reputation: 434

You may want to look at this: http://msdn.microsoft.com/en-us/library/windows/desktop/bb688195(v=vs.85).aspx

However, as Mark Ransom suggested it is not easy.

Upvotes: 1

rushtoshankar
rushtoshankar

Reputation: 29

The title bar is actually drawn and handled by the OS, program doesn't have a control over it. There is an OS wide setting to change it. Many applications use their own caption so that they can play around the styles of it.

Upvotes: 1

Related Questions