xiaobin_hlj80

https://blog.csdn.net/xiaobin_HLJ80 http://blog.chinaunix.net/uid/31552151.html

导航

Hello MFC - The last little bit of work

This article adds menu events and shortcut key responses in CFrameWnd.

CFrameWnd

  • load menu
    Create(NULL, _T("Hello MFC"),
        WS_OVERLAPPEDWINDOW,
        rectDefault, 
        NULL, 
        MAKEINTRESOURCE(IDR_MENU1)
    );
LoadAccelTable(MAKEINTRESOURCE(IDR_ACCELERATOR1));

add_res6-hellomfc

  • event
void CMainWindow::OnHelpAboutus()
{
    // TODO: Add your command handler code here
    OnBtnClick();
}

add_event1a-hellomfc

add_event2a-hellomfc

Accelerator

add_res7-hellomfc

add_res8-hellomfc

Key conflict

Remove the message mapping for MyApp.

  • MyApp.cpp
BEGIN_MESSAGE_MAP(CMyApp, CWinApp)
    ////ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()

Ref

posted on 2026-09-19 00:12  xiaobin80  阅读(3)  评论(0)    收藏  举报