Hello - mfc samples

Illustrates a single application window with a menu and About box.

2025-11-26

Written by: xiaobin

This article adds menu events and shortcut key responses in CFrameWnd. The modifications are based on the HelloMFC example.

CFrameWnd

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

add menu

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

add event

add event

Accelerator

add resource

add resource

Key conflict

Remove the message mapping for MyApp.

BEGIN_MESSAGE_MAP(CMyApp, CWinApp)
    ////ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()

Ref