如何更改 RibbonStatusBarPane 文本颜色?

发布于 2024-09-24 05:42:56 字数 345 浏览 0 评论 0原文

我的应用程序使用MFC Ribbon(VS2008 +功能包9)。 我无法更改 RibbonStatus Bar Pane 文本颜色。我重写了 virtual int DrawPaneText(CDC* pDC, const CString& strText, CRect rectText, UINT uiDTFlags) 函数,但事情不起作用。

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

如何在 MFCRibbonStatusBarPane 中执行此操作?

My application is using MFC Ribbon(VS2008 + Feature pack9).
I'm not able to change RibbonStatus Bar Pane text color.I override the virtual int DrawPaneText(CDC* pDC, const CString& strText, CRect rectText, UINT uiDTFlags) function but things are not working.

In non Ribbon Status Bar there is a function void SetPaneTextColor(int nIndex, COLORREF clrText = (COLORREF)-1 , BOOL bUpdate) in order to change pane text color.

how to do this in MFCRibbonStatusBarPane ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

余生再见 2024-10-01 05:42:56
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);

[...]
}
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);

[...]
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文