version 3
Menu selected Number
Parameter | Type | Description | ||||
This command does not require any parameters | ||||||
Function result | Number | Menu command selected | ||||
Menu number in high word | ||||||
Menu item number in low word |
Description
Menu selected is used only when forms are displayed. It detects which menu command has been chosen from a menu.
Tip: Whenever possible, use methods associated with menu commands in an associated menu bar (with a negative menu bar number) instead of using Menu selected. Associated menu bars are easier to manage, since it is not necessary to test for their selection. However, if you use the commands APPEND MENU ITEM or INSERT MENU ITEM, you have to use Menu selected because the menu items added by these commands do not have associated methods.
Menu selected returns the menu-selected number, a long integer. To find the menu number, divide Menu selected by 65,536 and convert the result to an integer. To find the menu command number, calculate the modulo of Menu selected with the modulus 65,536. Use the following formulas to calculate the menu number and menu command number:
Menu := Menu selected \ 65536 menu command := Menu selected % 65536
Starting with version 6, you can also extract these values using the bitwise operators as follows:
Menu := (Menu selected & 0xFFFF0000) >> 16 menu command := Menu selected & 0xFFFF
If no menu commands are selected, Menu selected returns 0.
Example
The following form method uses Menu selected to supply the menu and menu command arguments to SET MENU ITEM MARK:
Case of : (Form event=On Menu Selected) If (Menu selected # 0) SET MENU ITEM MARK (Menu selected\65536;Menu selected%65536;Char(18)) End if End case
See Also