Menu Events

In addition to control events are events associated with pop-up menus that are tied to a control. You can detect pop-up menu selections directly in a control's event procedure. Messages are generated as the user goes through the process of selecting a pop-up menu item.

MSG-INIT-MENU (value 16398)

This event occurs immediately prior to the display of a control’s pop-up menu. EVENT-DATA-2 contains the control’s menu handle. The control’s event procedure can use this event to update any state information in the menu, such as enabling/disabling items or setting/ removing check marks. If the event procedure sets EVENT-ACTION to EVENT-ACTION-FAIL, or sets the control’s menu handle to NULL, then the menu is not displayed. In this case, any host-defined built-in menu for the control class will display instead (e.g., Windows Cut/Copy/Paste/Undo menu associated with entry fields). If there is no host-defined menu, then no menu is shown.

MSG-INIT-MENU applies to windows in the same manner that it does for controls. When a window’s pop-up menu is about to appear, you can pass the information that came with this event to the window’s event procedure to update the menu’s state before the menu is shown. You can also prevent the menu from being seen by setting EVENT-ACTION to EVENT-ACTION-FAIL.

MSG-MENU-INPUT (value 16397)

This event occurs when the user has activated a control’s pop-up menu and selected an item on the menu. For windows, the information from this message event is passed to a window’s event procedure when the user does any of the following:

  1. selects an item from the window’s pop-up menu bar,
  2. selects an item from the window’s pop-up menu,
  3. selects an item from a pop-up menu owned by a control contained in the window, and that control’s event procedure did not stop further processing of the menu selection, or
  4. selects the Close option from the initial window’s system menu (or clicks the Close button), and you have set the configuration option QUIT-MODE to a positive value. This configuration option causes the runtime to treat the close operation as if it were an item on the initial window’s menu bar.

EVENT-DATA-2 contains the menu item’s ID. Setting EVENT-ACTION to EVENT-ACTION-CONTINUE prevents further processing of the menu selection. Otherwise, the menu selection is treated as a normal menu selection from the menu bar (i.e., it terminates the ACCEPT with an exception value equal to the menu

item’s ID).

MSG-END-MENU (value 16399)

This event occurs when the pop-up menu of either a control or a window has been removed from the screen. EVENT-DATA-2 contains the control’s (or window’s) menu handle. The only normal reason for processing this event would be to undo some effect created in response to MSG-INIT-MENU.