MENU Resource Overview

Overview

The MENU resource defines a menu template that can be compiled into a binary resource and loaded by an application at runtime. Menus are described using a simple text‑based syntax in a .rc file and are typically built with the rc.exe resource compiler.

Syntax

The basic grammar for a MENU resource is:

MENU [MENU_ID] [options]
BEGIN
    MENUITEM "Caption", [ID], [options]
    POPUP "SubMenu Caption", [options]
    BEGIN
        MENUITEM "SubItem", [ID], [options]
        ...
    END
    ...
END

Key elements:

Example

A simple menu resource definition:

#define IDR_MAINMENU 101
#define IDM_FILE_NEW 40001
#define IDM_FILE_OPEN 40002
#define IDM_HELP_ABOUT 40003

MENU IDR_MAINMENU
BEGIN
    POPUP "&File"
    BEGIN
        MENUITEM "&New\tCtrl+N", IDM_FILE_NEW, MF_STRING
        MENUITEM "&Open...\tCtrl+O", IDM_FILE_OPEN, MF_STRING
        MENUITEM SEPARATOR
        MENUITEM "E&xit", 0, MF_STRING
    END
    POPUP "&Help"
    BEGIN
        MENUITEM "&About...", IDM_HELP_ABOUT, MF_STRING
    END
END

Remarks