简体   繁体   English

MFC CMFCVisualManager替代

[英]MFC CMFCVisualManager Override

I'm trying to override some functions on CMFCVisualManager to customize my ribbon. 我试图覆盖CMFCVisualManager上的某些功能来自定义我的功能区。 So I created a class and derived from it. 所以我创建了一个类并从中派生。

void CMyVisualManager::OnDrawRibbonCategory(CDC* pDC, CMFCRibbonCategory* pCategory, CRect rectCategory)

Now this works and can change colors etc, but there are some functions that I cant or override or not doing it right like 现在这可以工作并且可以更改颜色等,但是有些功能我无法或覆盖或无法正确执行,例如

void CMyVisualManager::OnDrawRibbonLaunchButton(CDC* pDC, CMFCRibbonLaunchButton* pButton, CMFCRibbonPanel* pPanel)

My method doesnt override the original, and the original function gets called 我的方法不会覆盖原始方法,并且原始函数会被调用

But https://msdn.microsoft.com/en-us/subscriptions/downloads/65a24718-8128-43f9-973d-25262bdceae7(v=vs.90) says it can be overridden. 但是https://msdn.microsoft.com/zh-cn/subscriptions/downloads/65a24718-8128-43f9-973d-25262bdceae7(v=vs.90)表示它可以被覆盖。

If anyone can point me in the right direction, I've been looking but can't find an answer thanks 如果有人能指出我正确的方向,我一直在寻找但找不到答案谢谢

Yes you override a function in your class. 是的,您可以在您的课程中覆盖一个函数。

But you visual manager isn't the one that is created. 但是您的视觉管理器不是创建的。 So it is never used. 因此,它永远不会被使用。 When your program starts an instance of the visual manager is created. 程序启动时,将创建可视管理器的实例。 And this instance is used. 并使用此实例。

Only if you also force the MFC to use your visual manager your overriden functions are used. 仅当您还强制MFC使用可视管理器时,才使用覆盖功能。

There for use SetDefaultManager with the runtime class of your class in InitInstance of your program. SetDefaultManager与程序的InitInstance中的类的运行时类一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM