Question

I'm having the following code:

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);

The problem is, when I press <ALT>, the menu(IDR_APP_MAINFRAME) will popup. How can I always hide the menu and do not response to presss?

I had heard this is due to an accelerator control in MFC, but I couldn't see the control in my project solution which is using VS2008..

Was it helpful?

Solution

In your CMainFrame override PreCreateWindow and destroy the menu. Try something like this:

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
        if(cs.hMenu!=NULL)
        {
                ::DestroyMenu(cs.hMenu);
                cs.hMenu = NULL;
        }
        return CFrameWnd::PreCreateWindow(cs);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top