The following exercise demonstrates a number of menu creation principles and features, including preset menus.

  1. Open a new pulldown Menu designer window.

  2. Type &File (including the ampersand) at the cursor, then press Enter. Type &Form into the new item entry box, then press Tab. A new item entry box appears to the right of the current entry. Type &Close into this box.

  3. If it isn’t already open, press F11 to open the Inspector. Choose the Events tab, then type form.close( ) into your Close item’s onClick event.

  4. Back at the Menu designer, select the top-level "&File" item.

  5. Press Tab. A new top-level item entry box appears. Press Alt+NE to insert a complete menu of basic editing commands. Now press the Tab key again for one more top-level item entry box.

  6. Press Alt+NW. This time, a new top-level "&Window" item is created. This item has no subentries yet, but it will later.

  7. Save the menu as MTEST.MNU, then close the Menu designer.

  8. Open a new form in the Form designer. Add an entryfield control to the form.

  9. Click on the form background. If it’s not already in view, press F11 to view the Inspector. Click the tool button on the form’s MenuFile property (Menu category), choose your MTEST.MNU file, and click OK. Keep other form properties at their default settings.

  10. Press F2 to save (MTEST.FRM, for example) and run the form.

Because this is an MDI form (the default setting), the menu appears on the application frame, replacing the dBASE Plus menu while the form has focus.

Click the Windows menu item; you should see a selectable list of other active dBASE Plus windows. Now try the Edit menu commands. You should be able to use all of these standard Windows text editing commands on the text in your form’s entryfield control.

The reason these two menus provide full functionality without any coding on your part is that the items use built-in menubar objects. You’ll see how these objects work in the next topic when we examine the code behind the menu.

Note

Since the properties used to create these preset menus belong only to the menubar class and are not available to the popup class, you can’t use the properties in a popup menu.

Finally, try your File|Form|Close item to test your first piece of menu action code by closing the form.

Now let’s go to the Source editor to examine the code structure of this menu.