共用方式為


Creating 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 Designer, 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, 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

Defining Toolbar Actions | Adding a Coordinated Toolbar and Menu to a Form Set | Creating Custom Toolbars | Customize Toolbar Dialog Box | Designing Menus and Toolbars | Configuring Visual FoxPro