Share via


How to: Control Menus at Run Time

Each Visual FoxPro menu has two names, and each menu item has a name and a number. Visual FoxPro uses one name in the user interface and the other name or number in the generated menu program (.mpr). You can use these names or numbers to reference and control menus and menu items at run time. If you don't provide a name or number when creating menus and menu items, Visual FoxPro creates one when you generate the menu program.

For an example of adding and removing menu items at run time, see Solution.app in the Visual FoxPro ...\Samples\Solution directory.

Warning

Avoid using Visual FoxPro-generated names and numbers in code, because they change each time you generate the menu program. If you refer to a generated name or number, your code might fail.

In the Menu and Shortcut Designers, the Prompt column shows what appears in the user interface, and the column to the right of the Result box shows what appears in the generated program.

To specify a name for a menu pad

  1. In the Prompt column, select the appropriate menu title.

    Note

    The Result column must show Command, Submenu, or Procedure — not Pad Name.

  2. Choose the button in the Options column to display the Prompt Options dialog box.

  3. In the Pad Name box, type the name of your choice.

  4. Choose OK to return to the Menu Designer.

To specify a number for a menu item

  1. In the Prompt column, select the appropriate menu item.

    Note

    The Result column must show Command, Submenu, or Procedure — not Bar #.

  2. Choose the button in the Options column to display the Prompt Options dialog box.

  3. In the Bar # box, type the number of your choice.

  4. Choose OK to return to the Menu Designer.

    Tip

    If you use the Quick Menu feature, don't change the names or numbers that Visual FoxPro provides for system menus or menu items; otherwise, you might get unpredictable results when you run the generated menu program.

See Also

Tasks

How to: Add Cleanup Code to a Menu System

Other Resources

Designing Menus and Toolbars

Creating Custom Toolbars

Creating Menus, Shortcut Menus, Menu Items, and Submenus

Compiling an Application