How to: Create Menus and Submenus
You can create menus by customizing the existing Visual FoxPro menu system or by developing your own menu system. To start with the existing Visual FoxPro menu system, use the Quick Menu feature.
To create a menu system with Quick Menu
From the Project Manager Window, select the Other tab, select Menus, and then select New.
The Menu Designer appears.
From the Menu menu, choose Quick Menu.
The Menu Designer now contains information about the main Visual FoxPro menus.
Customize the menu system by adding or changing menu items.
For example, insert a Customer menu before the Help menu by choosing the mover button associated with the Help menu, choosing the Insert button, and then typing Customer in the Prompt column. The result looks like this:
A customized menu system
Drag mover buttons to change the location of menus on the menu bar. If you need a Help menu, make it the last menu on the menu bar so that users can find it quickly.
From the Menu menu, choose Generate.
Visual FoxPro prompts you to save the menu system in a file with an .mnx extension. This file is a table that will store all the information about the menu system. After you save the menu system, Visual FoxPro prompts for an output file with an .mpr extension. This file will contain the generated menu program.
Creating SDI Menus
SDI menus are menus that appear in single-document interface (SDI) windows. To create an SDI menu you must indicate that the menu will be used on an SDI form while you're designing the menu. Other than that, the process of creating an SDI menu is the same as that for creating a normal menu.
To create an SDI menu
- While the Menu and Shortcut Designers is open, choose General Options from the View menu, and select Top-Level Form.
Menus on SDI forms (ShowWindow = 2) are not supported if the HalfHeightCaption property of the form is set to True (.T.).
For each menu item, you can create a submenu containing additional menu items.
To create a submenu
In the Prompt column, select the menu item to which you want to add a submenu.
In the Result box, select Submenu.
A Create button appears to the right of the list. If a submenu already exists, an Edit button appears instead.
Select Create or Edit.
In the Prompt column, type the names of the new menu items.
To add menus programmatically
- Use the DEFINE PAD, DEFINE POPUP, or DEFINE BAR commands.
Though you typically create menus and menu items using the Menu Designer, you can also create them using Visual FoxPro commands. For example, you can create a menu using DEFINE PAD, a submenu using DEFINE POPUP, and items on the submenu using a series of DEFINE BAR commands. You can also use DEFINE BAR Command to customize menus in such ways as adding pictures, assigning fonts, and displaying messages to the user.