Calling Menus

An application displays the main menu when it’s first executed. The menus you add to an application will either replace or modify the main menu or another application menu. The topics below describe how to call a new menu to replace or modify the existing menu.

General Options

When you open the Visual FoxPro Menu Builder to create a menu that will replace or modify an application menu, be sure to select General Options on the View menu so you can specify the location of the menu in relation to the menu it’s replacing or modifying.

The Location option buttons on the General Options dialog determine how Visual FoxPro integrates a menu with the menu already displayed on the Visual FoxPro system menu bar. See the Visual FoxPro Developer’s Guide for descriptions of the Location option buttons.

Calling Code

In the examples below, NEW.MPR is the name of the new menu being called and PREVIOUS.MPR is the name of the current menu being modified or replaced.

There are several ways to call menus in your programs. How you call a menu depends on the relationship of the new menu to the menu already displayed.

·       If the new menu is a permanent modification or replacement of the current menu, a simple DO will suffice:

·       DO NEW.MPR

·       If the new menu is a temporary modification or replacement of the current menu, either of the following two alternatives will work:

·       Alternative 1

·       Call the new menu with the following line to replace or modify the current menu:

·       DO NEW.MPR

·       At the appropriate place re-execute the previous menu with the following line:

·       DO PREVIOUS.MPR

·       Alternative 2

·       Save the current menu and replace or modify it with the following two lines:

·       PUSH MENU _MSYSMENU

·       DO NEW.MPR

·       At the appropriate place re-execute the previous menu with the following line:

·       POP MENU _MSYSMENU

·       If the new menu temporarily modifies the current menu by adding menu pads, try the following code:

·       DO NEW.MPR

·       At the appropriate place, remove each menu pad with the following line:

·       RELEASE PAD <pad name> OF _MSYSMENU

More:

Disabling Menu Options