【问题标题】:How to change RibbonStatusBarPane text color?如何更改 RibbonStatusBarPane 文本颜色?
【发布时间】:2010-09-21 00:52:01
【问题描述】:

我的应用程序正在使用 MFC 功能区(VS2008 + Feature pack9)。 我无法更改 RibbonStatus 栏窗格文本颜色。我覆盖了虚拟 int DrawPaneText(CDC* pDC, const CString& strText, CRect rectText, UINT uiDTFlags) 函数,但没有工作。

在非功能区状态栏中有一个函数 void SetPaneTextColor(int nIndex, COLORREF clrText = (COLORREF)-1 , BOOL bUpdate) 以更改窗格文本颜色。

如何在 MFCRibbonStatusBarPane 中执行此操作?

【问题讨论】:

    标签: visual-c++ ribbon mfc-feature-pack


    【解决方案1】:
    class MyPane : public CMFCRibbonStatusBarPane
    {
    public:
        MyPane(){};
        MyPane(
            UINT   nCmdID, 
            LPCTSTR lpszText, 
            BOOL   bIsStatic = FALSE,    
            HICON  hIcon = NULL,
            LPCTSTR lpszAlmostLargeText = NULL)
    :CMFCRibbonStatusBarPane(nCmdID,
    lpszText,bIsStatic,hIcon,lpszAlmostLargeText){}
    MyPane(
        UINT   nCmdID,          
        LPCTSTR lpszText,         
        HBITMAP hBmpAnimationList, list
        int   cxAnimation = 16, 
        COLORREF clrTrnsp= RGB(192,192,192),
        HICON  hIcon = NULL,   
        BOOL   bIsStatic = FALSE)
    :CMFCRibbonStatusBarPane(nCmdID,lpszText,
    hBmpAnimationList,cxAnimation,clrTrnsp,hIcon,bIsStatic){}
    
    MyPane(
        UINT   nCmdID,
        LPCTSTR lpszText, 
        UINT   uiAnimationListResID,
        int   cxAnimation = 16,
        COLORREF clrTrnsp= RGB(192,192,192),
        HICON  hIcon = NULL, 
        BOOL   bIsStatic = FALSE)
    :CMFCRibbonStatusBarPane(nCmdID,lpszText,
    uiAnimationListResID,cxAnimation,clrTrnsp, hIcon,bIsStatic){}
    
    
    
     ~MyPane(){};
    
     virtual COLORREF OnFillBackground(CDC* pDC)override
     {
         return RGB(255,0,0); //return whatever new color you want
     }
    };
    
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    [...]
        m_wndStatusBar.AddElement(new MyPane(ID_STATUSBAR_PANE1, strTitlePane1, TRUE), strTitlePane1);
        m_wndStatusBar.AddExtendedElement(new MyPane(ID_STATUSBAR_PANE2, strTitlePane2, TRUE), strTitlePane2);
    
    [...]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-06
      • 2018-03-03
      • 2016-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多