Popup - cCJContextMenu
The method that is used to invoke a context menu
Type: Procedure
Syntax
Procedure Popup
Call Example
Send Popup
Description
Sending Popup to a context menu invokes that context menu. The top left hand corner of the menu will be located at your mouse cursor position.
There is a standard interface built into most of the classes for invoking context menus. If the Floating_Menu_object property is non-zero, the right mouse event Mouse_Down2 is augmented to send the popup message to the object handle stored in that property. Therefore setting Floating_Menu_object to your context menu is all that is needed to bind a context menu to a control.
The Popup Process
When popup is sent to a context menu the following occurs:
-
This message CreatePopupComInstance is sent. This creates all of the COM popup menu objects, makes sure all menu items are in a proper state (enabled, checked, visible) and it provides events for complete customization of the process. See CreatePopupComInstance for more.
-
It displays the context menu at the current mouse position (SetPopupLocation can be used to override the popup location of a context menu) by sending the ComShowPopup message. The menu is active until a choice is made or it is canceled. If a choice is made, the item's OnExecute event is called. See Execute for a complete description of the execute process.
-
The COM objects are destroyed. The DataFlex proxy objects are no longer bound to a COM object.
Augmenting Popup
This message is suitable for augmentation. If you augment before the forward send, the menu has not yet been invoked. If you agument after the forward send, the menu will have been invoked and an action, if selected, will have been exected. Note that normally all augmentations are better handled by OnCreate and OnPopupInit.
Sample
This sample creates a context menu, which is then used by the oSalesp_Name object. DEOs already have a standard context menu. In this case we will use our own custom menu. The context menu could have also been placed inside the oSalesp_Name object (before the set Floating_Menu_Object) message.
Object oSmallContextMenu is a cCJContextMenu
Object oPromptMenuItem is a cCJPromptMenuItem
End_Object
Object oClearMenuItem is a cCJClearMenuItem
Set pbControlBeginGroup to True
End_Object
Object oSaveMenu is a cCJSaveMenuItem
End_Object
Object oDeleteMenu is a cCJDeleteMenuItem
End_Object
End_Object
:
Object oSalesp_Name is a dbForm
Entry_Item Salesp.Name
Set Label to "Sales Person Name:"
Set Size to 13 156
Set Location to 20 70
Set Label_Col_Offset to 2
Set Label_Justification_Mode to jMode_Right
Set Floating_Menu_Object to oSmallContextMenu
End_Object // oSalesp_Name