次の方法で共有


How to: Create the Coordinated Menu

When you coordinate a menu with a toolbar, the menu items accomplish the same tasks as the associated toolbar buttons, and the menu items are automatically disabled when the associated toolbar button is disabled.

To create a menu that is coordinated with a toolbar

  1. In the Menu and Shortcut Designers, create a submenu with a descriptive prompt for every button on the toolbar.

  2. In the result column for each submenu item, choose Command.

  3. For each submenu item, call the code associated with the Click Event of the appropriate toolbar command button.

    For example, if the name of the button on the toolbar is cmdA, add the following line of code in the edit box for the submenu item command:

    Formset.toolbar.cmdA.Click
    
  4. Choose the button in the Options column to open the Prompt Options dialog box and choose Skip For.

  5. In the Expression Builder Dialog Box, enter an expression that indicates that the menu option should be skipped when the toolbar command button is not enabled.

    For example, if the name of the button on the toolbar is cmdA, enter the following expression in the Skip For box:

    NOT formset.toolbar.cmdA.Enabled
    
  6. Generate the menu.

  7. Add the menu to the form set with the toolbar and run the form set.

When the user opens the menu, Visual FoxPro evaluates the Skip For condition, disabling the menu item if the associated toolbar command button is disabled. When the user chooses an item on the menu, the code in the Click Event of the associated toolbar command button is executed.

See Also

Tasks

How to: Define Toolbar Actions

How to: Add a Coordinated Toolbar and Menu to a Form Set

Reference

Customize Toolbar Dialog Box (Visual FoxPro)

Other Resources

Creating Custom Toolbars

Designing Menus and Toolbars

Customizing the Visual FoxPro Environment