删除顶级菜单项(在MFC中)。 。
1>我可以使用以下代码删除MFC MDI应用程序中的顶级菜单项(以及其子菜单)。
void CMainFrame::OnRemoveMyMenu()
{
////////////////////////////////////////////////////////////////////////
CString sMenuText = _T("");
BOOL bReturn = FALSE;
const CMFCMenuBar *pMenuBar = GetMenuBar();
HMENU hMainMenu = NULL;
HMENU hSubMenu = NULL;
hMainMenu = pMenuBar->GetHMenu();
ASSERT(hMainMenu);
RemoveMenu(hMainMenu, 3, MF_BYPOSITION);
//----------------------------------------------------------------------
}
2>但是,它仅在AppWizard创建 idr_mainframe 菜单上工作。它确实在AppWizard在资源中创建的另一个菜单上确实可以使用,主要是 idr_> type 菜单(这是使用MDI窗口显示的菜单)。
3>我尝试在视图中的不同位置调用类似的代码,并从视图中调用与上述相同的代码。但这无效。
4>有人可以暗示我缺少什么吗?
非常感谢
ka.mumbai
1> I could remove top level menu item (along with its sub-menus) in MFC MDI application using below code.
void CMainFrame::OnRemoveMyMenu()
{
////////////////////////////////////////////////////////////////////////
CString sMenuText = _T("");
BOOL bReturn = FALSE;
const CMFCMenuBar *pMenuBar = GetMenuBar();
HMENU hMainMenu = NULL;
HMENU hSubMenu = NULL;
hMainMenu = pMenuBar->GetHMenu();
ASSERT(hMainMenu);
RemoveMenu(hMainMenu, 3, MF_BYPOSITION);
//----------------------------------------------------------------------
}
2> However, it works only on AppWizard created IDR_MAINFRAME menu. It does "not" work on another menu created in Resources by AppWizard, mainly IDR_<>TYPE menu (which is the Menu displayed with MDI window is put on).
3> I tried to call similar code within different places in View as well as call the same code as above, placed in MainFrame from View. But it did not work.
4> Can somebody given hint as to what I am missing?
Thanks a lot
KA.Mumbai
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论