我有以下代码:
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);
问题是,当我按下 <ALT>
时,菜单(IDR_APP_MAINFRAME)将弹出。
如何始终隐藏菜单并且不响应按键?
我听说这是由于 MFC 中的加速器控件,但我在使用 VS2008 的项目解决方案中看不到该控件..
最佳答案
在您的 CMainFrame
中覆盖 PreCreateWindow
并销毁菜单。尝试这样的事情:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if(cs.hMenu!=NULL)
{
::DestroyMenu(cs.hMenu);
cs.hMenu = NULL;
}
return CFrameWnd::PreCreateWindow(cs);
}
关于c++ - 放弃 CMainFrame 中的 ALT 按键操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3819068/