C++ 在CMainFrame中放弃按ALT键
我有以下代码:C++ 在CMainFrame中放弃按ALT键,c++,visual-c++,mfc,mdi,mfc-feature-pack,C++,Visual C++,Mfc,Mdi,Mfc Feature Pack,我有以下代码: CMainFrame* pFrame = new CMainFrame; if (!pFrame) return FALSE; m_pMainWnd = pFrame; // create and load the frame with its resources pFrame->LoadFrame(IDR_APP_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL); // The
CMainFrame* pFrame = new CMainFrame;
if (!pFrame)
return FALSE;
m_pMainWnd = pFrame;
// create and load the frame with its resources
pFrame->LoadFrame(IDR_APP_MAINFRAME,
WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
NULL);
// The one and only window has been initialized, so show and update it
pFrame->ShowWindow(SW_SHOWMAXIMIZED);
问题是,当我按
时,菜单(IDR\u APP\u MAINFRAME)将弹出。
我如何始终隐藏菜单而不响应按键
我听说这是由于MFC中的加速器控件造成的,但我在使用VS2008的项目解决方案中看不到该控件。在您的
CMainFrame
覆盖PreCreateWindow
并销毁菜单。试着这样做:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if(cs.hMenu!=NULL)
{
::DestroyMenu(cs.hMenu);
cs.hMenu = NULL;
}
return CFrameWnd::PreCreateWindow(cs);
}
在
CMainFrame
中,覆盖PreCreateWindow
并销毁菜单。试着这样做:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if(cs.hMenu!=NULL)
{
::DestroyMenu(cs.hMenu);
cs.hMenu = NULL;
}
return CFrameWnd::PreCreateWindow(cs);
}
我尝试了你的方法,但是,当它继续运行时,它崩溃了:void CFrameWnd::onitmenupopup(CMenu*pMenu,UINT nIndex,BOOL bSysMenu)(hParentMenu=pParent->GetMenu()->GetSafeHmenu())!=NULL)//-->这里有一种方法可以初始化菜单,但根本不显示它?@wengsenf:为什么要覆盖
CFrameWnd::OnInitMenuPopu
?奇怪!无论如何,请尝试在您的CMainFrame
中为WM_INITMENUPOPUP
消息添加一个空的处理程序。我尝试了您的方法,但是,它在继续时崩溃:void CFrameWnd::OnInitMenuPopup(CMenu*pMenu,UINT nIndex,BOOL bSysMenu)(hParentMenu=pParent->GetMenu()->getsafemenu())!=NULL)//-->这里有一种方法可以初始化菜单,但根本不显示它?@wengsenf:为什么要覆盖CFrameWnd::OnInitMenuPopu
?奇怪!无论如何,请尝试在CMainFrame