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.
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.
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:
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).
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.