代码之家  ›  专栏  ›  技术社区  ›  wengseng

在CMainFrame中放弃ALT键

  •  2
  • wengseng  · 技术社区  · 15 年前

    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\u APP\u MAINFRAME)。 我怎么能总是隐藏菜单而不响应按键?

    我听说这是由于MFC中的加速器控件造成的,但是我在使用VS2008的项目解决方案中看不到该控件。。

    1 回复  |  直到 15 年前
        1
  •  0
  •   mmonem    15 年前

    在你的 CMainFrame 覆盖 PreCreateWindow 破坏菜单。尝试以下操作:

    BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
    {
            if(cs.hMenu!=NULL)
            {
                    ::DestroyMenu(cs.hMenu);
                    cs.hMenu = NULL;
            }
            return CFrameWnd::PreCreateWindow(cs);
    }
    
    推荐文章