Share via


ACTIVATE MENU Command

Displays and activates a menu bar.

ACTIVATE MENU MenuBarName   [NOWAIT]   [PAD MenuTitleName]

Parameters

  • MenuBarName
    Specifies the name of the menu bar to activate.
  • NOWAIT
    Specifies that at run time the program should not wait for the user to choose a menu from the active menu bar or to press ESC. Instead, the program continues to execute. A menu activated with the NOWAIT option does not return program execution to the line following the ACTIVATE MENU command when DEACTIVATE MENU is issued.
  • PAD MenuTitleName
    Specifies the menu title name that is automatically selected when the menu bar is activated. If you don't specify a menu title name, the first menu title name in the activated menu bar is activated by default.

Remarks

Displays and activates the menu bar specified with MenuBarName. This command works in conjunction with DEFINE MENU and DEFINE PAD.

Note   When you include the Visual FoxPro system menu bar (_MSYSMENU) in an application, there is no need to activate the menu. Instead, issue SET SYSMENU AUTOMATIC.

Example

The following example uses ACTIVATE MENU to display and activate a user-defined menu system. The current system menu bar is first saved to memory with SET SYSMENU SAVE, and then all system menu titles are removed with SET SYSMENU TO.

Two menu titles are created with DEFINE PAD; DEFINE POPUP is used to create a drop-down menu for each menu title. DEFINE BAR is used to create menu items on each of the menus. When a menu title is chosen, ON PAD uses ACTIVATE POPUP to activate the corresponding menu. ACTIVATE MENU displays and activates the menu bar.

When a menu item is chosen from a menu, the CHOICE procedure is executed. CHOICE displays the name of the chosen item and the name of the menu containing the item.

** Name this program ACTIMENU.PRG ** CLEAR SET SYSMENU SAVE SET SYSMENU TO ON KEY LABEL ESC KEYBOARD CHR(13) DEFINE MENU example BAR AT LINE 1 DEFINE PAD convpad OF example PROMPT '<Conversions' COLOR SCHEME 3 ; KEY ALT+C, '' DEFINE PAD cardpad OF example PROMPT 'Card <Info' COLOR SCHEME 3 ; KEY ALT+I, '' ON PAD convpad OF example ACTIVATE POPUP conversion ON PAD cardpad OF example ACTIVATE POPUP cardinfo DEFINE POPUP conversion MARGIN RELATIVE COLOR SCHEME 4 DEFINE BAR 1 OF conversion PROMPT 'Ar<ea' ; KEY CTRL+E, '^E' DEFINE BAR 2 OF conversion PROMPT '<Length' ; KEY CTRL+L, '^L' DEFINE BAR 3 OF conversion PROMPT 'Ma<ss' ; KEY CTRL+S, '^S' DEFINE BAR 4 OF conversion PROMPT 'Spee<d' ; KEY CTRL+D, '^D' DEFINE BAR 5 OF conversion PROMPT '<Temperature' ; KEY CTRL+T, '^T' DEFINE BAR 6 OF conversion PROMPT 'T<ime' ; KEY CTRL+I, '^I' DEFINE BAR 7 OF conversion PROMPT 'Volu<me' ; KEY CTRL+M, '^M' ON SELECTION POPUP conversion DO choice IN actimenu; WITH PROMPT( ), POPUP( ) DEFINE POPUP cardinfo MARGIN RELATIVE COLOR SCHEME 4 DEFINE BAR 1 OF cardinfo PROMPT '<View Charges' ; KEY ALT+V, '' DEFINE BAR 2 OF cardinfo PROMPT 'View <Payments' ; KEY ALT+P, '' DEFINE BAR 3 OF cardinfo PROMPT 'Vie<w Users' ; KEY ALT+W, '' DEFINE BAR 4 OF cardinfo PROMPT '-' DEFINE BAR 5 OF cardinfo PROMPT '<Charges ' ; KEY ALT+C, '' ON SELECTION POPUP cardinfo; DO choice IN actimenu WITH PROMPT( ), POPUP( )

ACTIVATE MENU example
DEACTIVATE MENU example
RELEASE MENU example EXTENDED
SET SYSMENU TO DEFAULT
ON KEY LABEL ESC
PROCEDURE choice
PARAMETERS mprompt, mpopup
WAIT WINDOW 'You chose ' + mprompt + ' from popup ' + mpopup NOWAIT

See Also

CLEAR Commands | CREATE MENU Command | DEACTIVATE MENU Command | DEFINE MENU Command | DEFINE PAD | HIDE MENU Command | SET SYSMENU | SHOW MENU