放弃 CMainFrame 中的 ALT 键按下

发布于 2024-09-25 05:01:51 字数 537 浏览 2 评论 0原文

我有以下代码:

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_APP_MAINFRAME)。 如何才能始终隐藏菜单并且不响应按键?

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

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..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

顾北清歌寒 2024-10-02 05:01:51

在您的 CMainFrame 中覆盖 PreCreateWindow 并销毁菜单。尝试这样的事情:

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

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);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文