Defining a Menu with an About Command

Now that you have an About dialog box, you need some way to let the user tell your application when 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, then 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 command on the Help menu.

The most common way to create a menu is to define it in the resource script 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 command on it, Help. The command displays a pop-up menu with the single command, About Generic.

Notice the ampersand (&) in the &Help string. This character immediately precedes the command mnemonic. A “command mnemonic” is a unique letter or digit with which the user can access a menu or command. It is 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 will see the About command when he or she displays the Help menu. If the user chooses the About command, Windows sends the window function a WM_COMMAND message containing the About command's menu ID; in this case, IDM_ABOUT.