Every menu option you add to a menu has a Skip For checkbox on its Prompt Options dialog through which you can enter a logical expression to disable or enable the option. If the logical expression evaluates to true (.T.), Visual FoxPro disables the option.
When you build an application, you must determine when, if ever, a menu option should be disabled. Then, you enter a logical expression into the optionís Skip For to disable the option when the disabling condition applies.
Caution: Too many complex Skip For conditions can slow the operation of Visual FoxPro menus. Keep your Skip Forís as simple as possible and as few as possible.
Generally, a menu option should be disabled when the option would interfere or be incompatible with an active window. To determine what conditions should cause a particular menu option to be disabled, the functionality of every other menu option in the application must be considered. Then, ways of detecting those conditions must be formulated and coded in the optionís Skip For.
The following are examples of situations for which you might want to disable menu options:
∑ Forms: A menu option that runs a form should usually be disabled when the form is on the desktop. In this case, it doesnít usually make sense to choose the menu option to access the form again. Also, the disabled option can be a reminder to users that the form is already displayed.
∑ If you insert the following line in the Skip For of a menu option in a VPM Enterprise application, the option will be disabled when the optionís form is on the desktop:
∑ where FormName is the value in the formís Name property.
∑ Processing Programs: A menu option that runs a program that processes data should be disabled when a form used to edit the data is on the desktop. For example, a payroll calculation program probably shouldnít be run if a form used to input hours worked is visible on the desktop.
∑ This situation can be handled with the same Skip For line described in the preceding example.
∑ Conditional Menu Options: Some menu options should be disabled until some prerequisite action takes place. For example, in VPM Enterprise the Tools and Options menu pads are disabled until you open a project. The Tools and Options menus have no use unless a project is open. In this case, you would need to add an expression to the Skip For that defines and tests a condition.