自定义功能区控件.可能吗? [英] customizing ribbon bar controls. is it possible?

查看:76
本文介绍了自定义功能区控件.可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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]

推荐答案

您需要创建一个从CMFCRibbonSlider派生的自己的类,并覆盖要处理的功能.
You need to create your own class derived from the CMFCRibbonSlider and override the functions that you want to handle.


我遇到了完全相同的问题,并通过在MSDN论坛上提问获得了答案.像您一样,我无法弄清楚如何使用A派生功能区控件类,尤其是在使用功能区设计器时,因为功能区控件是在MFC中实例化的.一旦向我指出该解决方案就很容易:创建功能区后,枚举子窗口以查找上下控件,然后将其子类化并拦截UDN_DELTAPOS.您可以通过在MSDN论坛上搜索我的论坛名称johnsssl来查看完整的答案.哦,在获得上下控件的窗口之后,您将获得其父窗口并为父类子类化,因为控件通知将转到父类.
I had the exact same problem and got the answer by asking on an MSDN forum. Like you, I could not figure out how use a to derived a ribbon control class, especially when using the ribbon designer, since the ribbon controls are instantiated deep within MFC. The solution was easy once pointed out to me: After the ribbon has been created, enumerate the child windows to find the up-down control(s), then subclass them and intercept the UDN_DELTAPOS. You can see the full answer by searching on the MSDN forums for my forum name, johnsssl. Oh, after getting the up-down control''s window, you get its parent window, and subclass the parent, since the control notifications go to the parent.


这篇关于自定义功能区控件.可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆