开发者

Discard ALT key press in CMainFrame

I'm having the following code:

CMainFrame* pFrame = new CMainFrame;
if (!pFrame)
    return FALSE;
m_pMainWnd = pFrame;
// create and load the frame with its r开发者_如何学JAVAesources
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..


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜