c++ - 在 MDI 应用程序中的不同功能区之间切换

标签 c++ mfc ribbon mdi mfc-feature-pack

我想在应用程序中的不同 MDI 子框架的不同功能区之间切换。我知道旧式菜单可以实现这一点,但我无法使其与功能包功能区一起使用。

旧式菜单时使用的代码:

pDocTemplate = new CMultiDocTemplate(
    IDR_MAINFRAME,//Menu to load
    RUNTIME_CLASS(CModDoc),
    RUNTIME_CLASS(CModFrame), // custom MDI child frame
    RUNTIME_CLASS(CdotView));
if (!pDocTemplate)
    return FALSE;
AddDocTemplate(pDocTemplate);

pDocTemplate = new CMultiDocTemplate(
    IDR_RES_RNGACTIV,//Menu to load
    RUNTIME_CLASS(CModRangeDoc),
    RUNTIME_CLASS(CModRangeFrame), //custom MDI child frame
    RUNTIME_CLASS(CBlankView));
if (!pDocTemplate)
    return FALSE;
AddDocTemplate(pDocTemplate);

我正在考虑的另一种方法是卸载当前的功能区并从资源中加载新的功能区?

//Unload ribbon code?
m_wndRibbonBar.LoadFromResource(IDR_RIBBON);

最佳答案

不需要有多个 CMFCRibbonBar如果不需要,可以使用CMFCRibbonBar::LoadFromResource然后你将不得不使用CMFCRibbonBar::RecalcLayout方法将更改应用到用户界面。 记得检查CMFCRibbonBar::LoadFromResource的返回值为确保加载成功,调用 CMFCRibbonBar::RecalcLayout 非常重要。否则您将看不到新功能区。

关于c++ - 在 MDI 应用程序中的不同功能区之间切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25927889/

相关文章:

c++ - 系统日志和 LOCAL0..7

winapi - MFC:如何打开 Windows 对话框 "Open With"(选择要用于打开此文件的程序)?

button - 禁用功能区按钮

c++ - 在其他计算机 C++ 中运行包含 MFC 类的 Dll

r - ggplot2:根据图形类型显示图例形状

ribbon - MS Ribbon/Office UI License 值得担心吗?

c++ - 如何从esp32查找PC local-ip以使用MQTT Node.js服务器

c++ - 如何检查是否在运行时定义了 C++ 抽象方法

c++ - 导出类的部分命名空间

c++ - CString 用于静态方法