更改功能区按钮的文字颜色 [英] Changing text color of ribbon button
问题描述
我在 VS2013-15 中遇到问题,我的按钮的字体颜色是灰色而不是黑色。
以下是当前按钮的外观:
某些文字似乎变更为所需颜色当盘旋。但是,有些甚至在悬停时也不会改变:
<任何帮助将非常感激。谢谢。
我设法使用Barmak的答案解决它。 Windows 7主题是问题。
要修复,您有2个选项。
选项1
更改您的程序使用的主题
这是一个懒惰的工作。只需将您的视觉管理器从 CMFCVisualManagerWindows7
切换到其他视觉管理器之一。
选项2
覆盖 OnUpdateSystemColors()
函数
首先,你需要一个继承 CMFCVisualManagerWindows7
:
类Win7VM:public CMFCVisualManagerWindows7
{
};
然后你需要调用 DECLARE_DYNCREATE
因为对象是在运行时动态创建的。
类Win7VM:public CMFCVisualManagerWindows7
{
DECLARE_DYNCREATE );
};
接下来,您需要实现该类。
class Win7VM:public CMFCVisualManagerWindows7
{
DECLARE_DYNCREATE(Win7VM)
virtual void OnUpdateSystemColors()
{
CMFCVisualManagerWindows7 :: OnUpdateSystemColors();
m_clrRibbonPanelCaptionText = RGB(0,0,0);
}
};之后,您需要调用 IMPLEMENT_DYNCREATE
。 IMPLEMENT_DYNCREATE(Win7VM,CMFCVisualManagerWindows7);最后,我们需要更改我们对 CMFCVisualManagerWindows7 $ c $的使用情况。
< c>到我们的新类的:
CMFCVisualManager :: SetDefaultManager(RUNTIME_CLASS(Win7VM));
I'm having an issue in VS2013-15 where my buttons' font colour is a shade of grey rather than black.
Here is what the buttons look like currently:
Some of the text seems to change to the desired colour when hovered over. However, some don't changed even when hovered:
Any help would be greatly appreciated. Thanks.
解决方案 I managed to fix it using Barmak's answer. The Windows 7 theme is the problem.
To fix, you have 2 options.
Option 1
Change the theme your program uses
This is a lazy work around. Just switch your visual manager from CMFCVisualManagerWindows7
to one of the other visual managers.
Option 2
Override the OnUpdateSystemColors()
function
First off you'll need a new class that inherits CMFCVisualManagerWindows7
:
class Win7VM : public CMFCVisualManagerWindows7
{
};
Then you'll need to call DECLARE_DYNCREATE
as the object is created dynamically at runtime.
class Win7VM : public CMFCVisualManagerWindows7
{
DECLARE_DYNCREATE(Win7VM);
};
Next, you'll need to implement the class.
class Win7VM : public CMFCVisualManagerWindows7
{
DECLARE_DYNCREATE(Win7VM)
virtual void OnUpdateSystemColors()
{
CMFCVisualManagerWindows7::OnUpdateSystemColors();
m_clrRibbonPanelCaptionText = RGB(0, 0, 0);
}
};
After that, you need to call IMPLEMENT_DYNCREATE
separate to your class implementation, in global scope.
IMPLEMENT_DYNCREATE(Win7VM, CMFCVisualManagerWindows7);
Finally, we need to change our usage of CMFCVisualManagerWindows7
to that of our new class:
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(Win7VM));
这篇关于更改功能区按钮的文字颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!