Add Scribble’s Pen Menu

Adding a new menu is similar to adding new commands to existing menus.

Note   This procedure assumes you have “pinned” the Menu Properties window so that it remains open.

To add Scribble’s Pen menu

  1. With the menu-editor window still showing, click in the empty cell at the right-hand end of the Scribble menu bar (after the Help menu).

  2. To position the menu entry, drag the selected cell to the left and drop it between the Edit and View menus.

  3. Type the new menu’s caption: &Pen.

    The caption appears simultaneously in the cell and in the Caption edit box of the Menu Item Properties window.

  4. Press ENTER to advance to the first menu item on the Pen menu (or click the empty cell that descends beneath the word “Pen”).

  5. Type this menu item’s caption: Thick &Line.

    Move your cursor to the ID box in the Menu Item Properties window. You’ll notice that Visual C++ created an ID for you, based on the menu name and the menu item name: ID_PEN_THICKLINE.

  6. Modify this ID slightly, to ID_PEN_THICK_OR_THIN.

  7. In the Prompt box, type the following command prompt string:

    Toggles the line thickness between thin and thick
    

    No default prompt string appeared because ID_PEN_THICK_OR_THIN is not a predefined command ID.

  8. Select the empty cell at the bottom of the Pen menu, below “Thick Line.” (You can also toggle between the Menu Item Properties window and the menu editor by pressing ENTER.)

  9. Type this menu item’s caption: Pen &Widths....

    An ellipsis (. . .) included in a menu item’s caption lets the user know that selecting the item opens a dialog box or a cascading menu.

  10. In the ID box, modify the Visual C++-generated ID slightly, to ID_PEN_WIDTHS.

  11. Type the following command prompt string:

    Sets the size of the thin and thick pen
    
  12. Close the menu editor and save your work.

The following figure shows the completed menu as it appears in the menu editor.

The Completed Pen Menu

Typically, at this point you would use ClassWizard or WizardBar to bind the menu commands to message-handler functions. That step is postponed until the next lesson in order to keep this lesson focused on constructing the user interface. If you like, you can skip ahead, perform the command-binding steps in Binding Visual Objects to Code Using WizardBar, and then return to this lesson to edit Scribble’s toolbar.