简体   繁体   English

有没有一种方法可以更改MFC SDI应用程序的标题字体?

[英]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. 我正在尝试增加MainFrame上标题的字体大小。 So far, I have tried several approaches without a good result. 到目前为止,我已经尝试了几种方法,但均未取得良好的结果。 Any suggestions are welcome. 欢迎任何建议。

A. Approach 1 A.方法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. 这种方法删除了我所有的功能区菜单,并创建了许多异常。

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. 许多应用程序使用自己的标题,以便可以围绕其样式进行播放。

You may want to look at this: http://msdn.microsoft.com/en-us/library/windows/desktop/bb688195(v=vs.85).aspx 您可能需要看一下: http : //msdn.microsoft.com/zh-cn/library/windows/desktop/bb688195(v=vs.85).aspx

However, as Mark Ransom suggested it is not easy. 但是,正如Mark Ransom所建议的那样,这并不容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM