我想在应用程序中的不同 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/