如何重命名 MFC 功能区面板?
我正在编写一个多语言应用程序,它支持从一种语言动态切换到另一种语言。由于CMFCRibbonPanel类中有一个GetName函数,我认为还应该有一个SetName函数。但不幸的是我找不到想要的功能。如何动态重命名功能区面板?非常感谢。
I am programming a multi-language application which supports dynamical switch from one language to another. Since there is a GetName function in class CMFCRibbonPanel, I think there should also be a SetName function. But unfortunately I can't find the desired function. How do I rename a ribbon panel dynamically? Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可能需要删除并重新添加它。这就是其他一些 MFC 功能区函数的工作原理。
You'll probably have to remove and re-add it. That's how some other MFC ribbon functions work.
结合 https://stackoverflow.com/a/5120994/6648895 和 https://stackoverflow.com/a/25180098/6648895
在 VS 2013 中最终对我有用的是:
Combining https://stackoverflow.com/a/5120994/6648895 and https://stackoverflow.com/a/25180098/6648895
is what finally worked for me in VS 2013:
面板名称受到保护。
您可以从 CMFCRibbon 派生您自己的类并添加“SetName”方法。
例如(在 VS2010 中创建虚拟 SDI 应用程序后)
the panel name is protected.
you can derive your own class from CMFCRibbon and add a "SetName" method.
for example ( after creating a dummy SDI application in VS2010 )
如果您通过 VS 功能区 UI 创建了功能区并且不想手动创建它们,那么它也可能对其他人有用。
从之前的答案开始工作。
由于面板没有 ID,因此您也无法选择它们来创建指针。但是,如果面板包含带有 ID 的元素,您可以使用它们创建指向面板的指针,然后重命名,而不必手动创建它。
例如,我的面板上有一个组合 ID_TEST_COMBO
这允许您更改文本,而无需手动创建面板
It might also be useful to others if you have created your ribbons via the VS ribbon UI and don't want to have to manually create them.
Working on from the previous answer.
As panels don't have id's you can't select them to create a pointer too. But if the panels contain elements with ID's you can use these to create a pointer to the panel then rename instead of having to manually create it.
For example I have a combo on my panel, ID_TEST_COMBO
This allows you to change the text without having to manually create the panel
您可以尝试SetWindowText函数。
您也可以覆盖文本的绘制并在其中添加您自己的文本。
希望这有帮助。
You can try SetWindowText function.
Also you could override the drawing of the text and add you own text there.
Hope this helps.