2.4.4 Defining a Menu with an About Command

Once you have created an About dialog box for your application, you must provide a way for the user to display the dialog box. In most applications, the About command would appear as the last command on the application's Help menu. If the application does not have a Help menu, it usually appears in the first menu, most often the File menu. In Generic, About is the only command, so it appears as the only item on the Help menu.

The most common way to create a menu is to define it in a resource-definition file. Put the following statements in GENERIC.RC:

GenericMenu MENU
BEGIN
    POPUP        "&Help"
    BEGIN
        MENUITEM "About Generic...", IDM_ABOUT
    END
END

These statements create a menu named GenericMenu with a single item on it, Help. When chosen, the command associated with the item displays a pop-up menu with the single menu item About Generic . . . .

Notice the ampersand (&) in the "&Help" string. This character immediately precedes the command mnemonic a unique character with which the user can access a menu or command. Mnemonics are part of Windows' direct-access method. If a user presses the key for the mnemonic together with the ALT key, Windows selects the menu or chooses the command. In the case of &Help, Windows removes the ampersand and places an underscore under the letter H when displaying the menu.

The user sees the About command when the Help menu is displayed. If the user chooses the About command, Windows sends the window procedure a WM_COMMAND message containing the About command's menu identifier—in this case, IDM_ABOUT.