Displays and activates a menu.
ACTIVATE POPUP MenuName [AT nRow, nColumn] [BAR nMenuItemNumber] [NOWAIT] [REST] |
Parameters
- MenuName
- Specifies the name of the menu to activate.
- AT nRow, nColumn
- Specifies the position of the menu on the screen or in a user-defined window. The row and column coordinate applies to the upper-left corner of the menu. The position you specify with this argument takes precedence over a position you specify with the FROM argument in DEFINE POPUP.
- BAR nMenuItemNumber
- Specifies the item in the menu that is selected when the menu is activated. For example, if nMenuItemNumber is 2, the second item is selected. The first item is selected if you omit BAR nMenuItemNumber or if nMenuItemNumber is greater than the number of items in the menu.
- NOWAIT
- Specifies that, at run time, a program does not wait for the user to choose an item from the menu before continuing program execution. Instead, the program continues to execute.
- REST
- A menu created with the PROMPT FIELD clause of DEFINE POPUP places records from a field into the menu. When the menu is activated, the first item in the menu is initially selected, even if the record pointer in the table containing the field is positioned on a record other than the first record. Include REST to specify that the item selected when the menu is activated corresponds to the current record pointer position in the table.
Remarks
ACTIVATE POPUP works in conjunction with DEFINE POPUP, used to create the menu, and DEFINE BAR, used to create the items on the menu.
Example
This example uses ACTIVATE POPUP with ON PAD to activate a menu when a menu title is chosen. 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 new system menu titles are created with DEFINE PAD; DEFINE POPUP is used to create a 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.
When an 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. If the Exit item is chosen from the Card Info menu, the original Visual FoxPro system menu is restored.
В | Copy Code |
---|---|
*** Name this program ACTIPOP.PRG *** CLEAR SET SYSMENU SAVE SET SYSMENU TO DEFINE PAD convpad OF _MSYSMENU PROMPT '\<Conversions' COLOR SCHEME 3 ; KEY ALT+C, '' DEFINE PAD cardpad OF _MSYSMENU PROMPT 'Card \<Info' COLOR SCHEME 3 ; KEY ALT+I, '' ON PAD convpad OF _MSYSMENU ACTIVATE POPUP conversion ON PAD cardpad OF _MSYSMENU 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 actipop 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, '' DEFINE BAR 6 OF cardinfo PROMPT '\-' DEFINE BAR 7 OF cardinfo PROMPT 'E\<xit'; KEY ALT+X, '' ON SELECTION POPUP cardinfo; DO choice IN actipop WITH PROMPT(),POPUP() PROCEDURE choice PARAMETERS mprompt, mpopup WAIT WINDOW 'You chose ' + mprompt + ; ' from popup ' + mpopup NOWAIT IF mprompt = 'Exit' SET SYSMENU TO DEFAULT ENDIF |