Aracılığıyla paylaş


How to: Perform Tasks with Commands

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. For more information, see How to: Perform Tasks with Procedures.

A command can be any valid Visual FoxPro command, including a call to a program that exists on your path or a procedure defined in the Cleanup option of the General Options Dialog Box. For more information, see How to: Customize a Menu System.

To assign a command to a menu or menu item

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

  2. In the Result box, select Command.

  3. In the box to the right of the Result box, type the appropriate command:

If the command calls a procedure in the menu's cleanup code, use the DO command with the following syntax:

DO procname IN menuname

In this syntax, menuname specifies the location of the procedure. This is the name of the menu file and must have the .mpr extension. If you don't specify the location in menuname, you must specify it with SET PROCEDURE TO menuname.mpr, if the procedure is in the menu cleanup code.

Displaying Forms and Dialog Boxes

From a menu or menu item, you can display a compiled form or dialog box by calling it with a command or procedure.

To display a form or dialog box

  • Use the DO FORM command with the form's name.

For example, to display a form named "Orders," use the following command:

DO FORM Orders

Tip

When you create a menu or menu item that displays a form or dialog box, put three dots at the end of the prompt to indicate that more user input is required.

If you create a custom toolbar for an application, you can display it by calling it from a menu or menu item. For details, see Creating Custom Toolbars.

See Also

Tasks

How to: Enable and Disable Menu Items

How to: Perform Tasks with Procedures

How to: Add Setup Code to a Menu System

Other Resources

Designing Menus and Toolbars

Compiling an Application