Partager via


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

  1. From the Project Manager Window, select the Other tab, select Menus, and then select New.

  2. Select Menu.

    The Menu Designer appears.

  3. From the Menu menu, choose Quick Menu.

    The Menu Designer now contains information about the main Visual FoxPro menus.

  4. 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

    Customize Menu

    Tip

    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.

  5. 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

Note

Menus on SDI forms (ShowWindow = 2) are not supported if the HalfHeightCaption property of the form is set to True (.T.).

Creating Submenus

For each menu item, you can create a submenu containing additional menu items.

To create a submenu

  1. In the Prompt column, select the menu item to which you want to add a submenu.

  2. 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.

  3. Select Create or Edit.

  4. 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.

See Also

Tasks

How to: Group Menu Items

Concepts

Menu System Creation

Other Resources

Creating Menus, Shortcut Menus, Menu Items, and Submenus

Designing Menus and Toolbars

Compiling an Application