Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/130.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在CMainFrame中放弃按ALT键_C++_Visual C++_Mfc_Mdi_Mfc Feature Pack - Fatal编程技术网

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