More on the Menu

When adding new menu items to a menu, additional parameters may be included in the following statements:

MENU ADD POPUP, hMenu, txt$, hPopup, state&[, AT [BYCMD] position&]

MENU ADD STRING, hMenu, txt$, hPopup, state&[, AT [BYCMD] position&] [, CALL callback]

 

AT position&

An optional position parameter that allows the programmer to specify an absolute position of the menu item within the popup menu, inserted immediately before the value of position&. Omitting this parameter causes the menu item to be appended to the menu at the "current position". Position values are indexed to 1. For example:

' Insert a new menu item at position 3 in the popup menu hPopup

position& = 3

MENU ADD STRING, hPopup, "&Print", %id_Print, _

ItemState&, AT position&

BYCMD 

The BYCMD keyword (also applicable to other forms of the MENU statement) changes the interpretation of position& to an identifier value, rather than an absolute position value. For example:

' Insert the "Print Setup" menu item before the "Print" menu item

Position& = %id_Print

MENU ADD STRING, hPopup, "Print Se&tup", _

  %id_PrintSetup, ItemState&, AT BYCMD Position&

callback 

(MENU ADD STRING only) The Callback parameter provides a mechanism to specify a Callback Function that is executed, to process %WM_COMMAND messages for the menu item.

 

See Also

Menus

Menu Walkthrough

Menu State

Menu Example