Enabling and Disabling Menu Items

You can enable or disable a menu or menu item based on a logical condition.

To enable or disable a menu or menu item

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

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

  3. Select Skip For.

    The Expression Builder appears.

  4. In the Skip For box, type the expression that determines whether the menu or menu item is enabled or disabled.

    If the expression evaluates to false (.F.), the menu or menu item is enabled. If the expression evaluates to true (.T.), the menu or menu item is disabled and cannot be selected or chosen. For details, see DEFINE BAR and DEFINE PAD.

    Note   After the menu system has been displayed, you can enable and disable menus and menu items by using the SET SKIP OF command.

Marking the State of a Menu Item

On a menu, a check mark next to a menu item indicates that it is in effect. For example, if you put a check mark next to the Credit item on the Customer menu created earlier, Credit is in effect.

At run time, you can place a check mark next to a menu item by using the SET MARK OF command.

For an example of disabling and marking the state of menu items, run Solution.app in the Visual FoxPro \Samples\Solution directory.

Assigning Tasks to Menus or Menu Items

When a menu or menu item is selected, it performs a task, such as displaying a form, a toolbar, or another menu system. To perform a task, a menu or menu item must execute a Visual FoxPro command. The command can be contained in one line, or it can be a procedure call.

**Tip   **If you expect to use a set of commands in several places, write a procedure. The procedure should be explicitly named and written in the menu cleanup code, or somewhere where it can be referenced by any menu or object.

See Also

Assigning Tasks to a Menu System | Performing Tasks with Commands | Performing Tasks with Procedures | Designing Menus and Toolbars | Compiling an Application