Menu Resources

Under Construction...

A menu is the set of commands that appears at the top of many windows, or that you can make appear using the right mouse button (this is often called a context menu, because it depends on what is under the mouse pointer, the context). Basically any list of commands which you click to activate, and which may be divided into several sub-menus (or popup menus) is probably built using a menu resource.

You can build menus from scratch inside your programs using API functions, but it is often more convenient to build them as resources and include them in your programs.

The basic menu syntax in the resource script file is:

id MENU
BEGIN
    item
    ...
END
id is the ID number of the menu. Each item is one of the following:

The syntax of menu items is:

MENUITEM text, result, [options]
text is the text that will appear as the menu item in the displayed menu. This should be enclosed in quotes. An ampersand (&) indicates that the next character should be underlined (and that the underlined character should be the key that the user can use to activate the menu item when using the menu). The \t character sequence represents a tab and aligns menu text in columns. Usually you use \t to separate an indicator of the menu item's accelerator key from the rest of the menu text, for example:
MENUITEM "E&xit\tCtrl+Q", CMD_FILE_EXIT

The x will appear underlined, and the Ctrl+Q will be separated from the rest of the text against the right side of the menu.

result is the number which will be sent to your window with the WM_COMMAND message to indicate which menu item was selected.

options can be CHECKED or GRAYED to indicate that the menu item should initially have a check mark next to it, or be inactive (there are other options, but they are rarely used).

The syntax of a popup menu is:

POPUP text
BEGIN
    item
    ...
END

text is the same as text for a menu item, and item syntax is the same as a top menu's item (thus you can nest any number of menus).