问题描述
我正在使用vs2010,并且有一个带功能区栏的MFC应用程序
我正在使用CMFCRibbonSlider,但我认为这是任何功能区控件的普遍问题
我想更改滑块的外观.我将其用作音量控制幻灯片,希望滑块部分看起来像拉长的三角形(例如vlc的音量控件),而缩放按钮看起来像小扬声器和大扬声器.
通常我会从CMFCRibbonSlider派生一个类,并覆盖OnDrawRibbonSliderZoomButton例如,但是我的应用程序中的所有控件都是这样创建的
i''m using vs2010 and have an MFC app with a ribbon bar
i''m using CMFCRibbonSlider but i think this is a general question for any ribbon control
i would like to change the look of the slider. i''m using it as a volume control slide and want the slider part to look like a stretched out triangle (like vlc''s volume control) and the zoom buttons to look like small speaker and big speaker
normally i would make a derived class from CMFCRibbonSlider and override OnDrawRibbonSliderZoomButton for example but all the controls in my app are created like this
m_wndRibbonBar.Create(this);
m_wndRibbonBar.LoadFromResource(IDR_RIBBON);
从资源中获取资源,因此我无法想到改变控件的任何行为.
您是否认为有办法以某种方式将自己的海关控制添加到功能区,并且仍然使用功能区设计器与以编程方式创建功能区?
例如,假设我完成了装箱工作,但创建后以某种方式覆盖CMFCRibbonSlider :: OnDraw(CDC * pDC)并将其指向我自己的CMFCRibbonSlider :: OnDraw(CDC * pDC)版本,在这里我可以做我想做的任何事情.
这是合法的C ++编程吗?如何在运行时重写类?
P.S.我尝试简单地编写自己的On Draw函数
from the resources so i have no way that i can think of to change any of the behavior of the control.
do you think there is a way to somehow add your own customs controls to the ribbon and still use the ribbon designer vs. creating the ribbon programmatically?
for example, suppose i get the crate do its job but after creating i somehow override CMFCRibbonSlider::OnDraw(CDC* pDC) and point it to my own version of CMFCRibbonSlider::OnDraw(CDC* pDC)where i can do whatever i want.
it this legitimate c++ programming? how would one override a class at runtime?
P.S. i tried simply writing my own On Draw function
void CMFCRibbonSlider::OnDraw(CDC* pDC)
{
TRACE("this is my CMFCRibbonSlider::OnDraw\n");
}
(奇怪地)编译但没有被调用
[edit:已移出表格的答案]
问题是:如何使功能区设计师认识新的职业?
[/结束编辑]
which compiles (strangely) but does not get called
[edit: moved form answer]
The question is: How to get the ribbon designer to recognize the new class?
[/end of edit]
推荐答案
这篇关于自定义功能区控件.可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!