Share via


How to: Customize a Menu System

After creating a basic menu system, you can customize it. For example, you can create status bar messages, define menu locations, or define default procedures.

Displaying Status Bar Messages

When a menu or menu item is selected, you can display a status bar message describing the choice. Such a message helps the user by adding information about the menu choice.

To display a message when a menu or menu item is selected

  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 Message.

    The Expression Builder dialog box appears.

  4. In the Message box, type the appropriate message.

    Tip

    Enclose character strings in quotation marks.

Defining the Location of Menu Titles

You can customize the location of user-defined menu titles in your applications. You can customize the location relative to the active menu system by choosing options in the General Options Dialog Box. Additionally, you can specify the location of menu titles when the user edits an object visually.

To specify a relative location for user — defined menu titles

  1. From the View menu, choose General Options.

  2. Choose the appropriate Location option: Replace, Append, Before, or After.

Visual FoxPro relocates all of the menu titles you've defined. If you want to relocate some but not all of them, drag the mover buttons next to the appropriate menu titles in the Menu and Shortcut Designers.

Additionally, you can specify the location of menu titles when the user edits an object in your application. If you include an object and the user activates it, your menu titles will not appear on the resulting menu bar unless you indicate that you want them there.

To control menu title location during object visual editing

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

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

  3. Set the Negotiate check box.

  4. Choose one of the following option buttons:

    • None does not place the menu title on the menu bar. Choosing None is the same as not choosing any option.

    • Left places the menu title in the left group of menu titles on the menu bar.

    • Middle places the menu title in the middle group of menu titles on the menu bar.

    • Right places the menu title in the right group of menu titles on the menu bar.

If you don't choose Left, Middle, or Right, the menu title will not appear on the menu bar when the user edits an object. For more information about editing objects visually, see Sharing Information and Adding OLE.

Saving and Restoring Menus

You can save and restore menus on the stack by pushing and popping them, which can be useful when you want to remove a menu temporarily, replace it with another, and then restore the original later on. The number of menus you save in memory is limited only by the amount of available memory.

Tip

Check the available memory with the SYS(1016) function. For example, to check how much memory your menu system uses, call SYS(1016), push the menu on the stack, and then call SYS(1016) again.

To save or restore menus

Creating a Default Procedure for a Menu System

You can create a global procedure that applies to your entire menu system. Such a procedure runs whenever a menu without an assigned procedure is chosen.

For example, suppose you're developing an application for which some menus do not yet have submenus, procedures, and so on. For these menus, you can create a code stub that executes when the menus are chosen. For instance, you could create a general procedure that includes this function:

MESSAGEBOX("Feature not available")

To create a default procedure

  1. Open the menu system you're designing.

  2. From the View menu, choose General Options.

  3. Assign the procedure by doing one of the following:

    • Write or call a procedure in the Procedure box.

      -OR-

    • Select Edit and then OK to open a separate editing window and write or call a procedure.

Setting the System Menu

You can manipulate menus that use the Visual FoxPro menu system. You can disable your menus, add and remove items from your menus, restore the default Visual FoxPro menus, and control access to your menus during program execution.

To manipulate menus

See Also

Tasks

How to: Test and Debug a Menu System

Reference

General Options Dialog Box

Customize Toolbar Dialog Box (Visual FoxPro)

Other Resources

Creating Custom Toolbars

Designing Menus and Toolbars

Customizing the Visual FoxPro Environment