zoukankan      html  css  js  c++  java
  • 改变状态栏字体(MFC)

    0. 定义一个常驻内存的CFont对象

    1. 创建一个雅黑字体,并设置字体大小

    2. 将该字体对象指针赋值给Status Bar对象

    MFC单文档示例:

     1 int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    2 {
    3 if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
    4 return -1;
    5
    6 if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
    7 | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
    8 !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
    9 {
    10 TRACE0("Failed to create toolbar\n");
    11 return -1; // fail to create
    12 }
    13
    14 if (!m_wndStatusBar.Create(this) ||
    15 !m_wndStatusBar.SetIndicators(indicators,
    16 sizeof(indicators)/sizeof(UINT)))
    17 {
    18 TRACE0("Failed to create status bar\n");
    19 return -1; // fail to create
    20 }
    21
    22 m_wndStatusBar.SetPaneInfo(1,ID_INDICATOR_TEXT,SBPS_NORMAL,420);
    23 m_wndStatusBar.SetPaneInfo(2,ID_INDICATOR_TEXT,SBPS_NORMAL,120);
    24
    25 LOGFONT logfont;
    26 GetObject(::GetStockObject(DEFAULT_GUI_FONT),sizeof(logfont),&logfont);
    27 logfont.lfCharSet=GB2312_CHARSET;
    28 logfont.lfWeight = FW_NORMAL;
    29 logfont.lfHeight = 24;
    30 lstrcpy(logfont.lfFaceName, _T("微软雅黑"));
    31 static CFont sfontStatusBar;
    32 sfontStatusBar.CreateFontIndirect(&logfont);
    33
    34 m_wndStatusBar.SetFont(&sfontStatusBar);
    35 m_wndStatusBar.SetPaneText(1,_T("状态栏字体测试。[Status Bar Font Test...]"));
    36
    37
    38 // TODO: Delete these three lines if you don't want the toolbar to
    39 // be dockable
    40 m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    41 EnableDocking(CBRS_ALIGN_ANY);
    42 DockControlBar(&m_wndToolBar);
    43
    44 return 0;
    45 }

    截图:

  • 相关阅读:
    数据库——大事务
    数据库——性能理解
    java——通过GenericObjectPool获取到的资源,调用close()方法会close还是returnObject?
    gradle——入门
    MongoDB——morphia
    jvm——Java main方法的执行
    sql——limit
    阿里云Open API自动化脚本—ECS公网IP转化弹性公网IP
    阿里云共享带宽
    mysql5.x安装脚本
  • 原文地址:https://www.cnblogs.com/kekec/p/2339138.html
Copyright © 2011-2022 走看看