CreateContextMenu - cCJGrid
Creates and returns a context menu to be used for rows. Is called when the object is created.
Type: Function
Return Data Type: Handle
Syntax
Function CreateContextMenu Returns Handle
Call Example
Get CreateContextMenu to HandleVariable
Description
When a grid is created, it needs to create a default context menu to be used when a user right clicks on a row. This context menu is created in CreateContextMenu, which is called inside of the object's constructor. CreateContextMenu returns the handle of the object, which is set in phoContextMenu.
This message can only be augmented in subclasses. If added to an object, it will not be called when the object is created.
By making this a function, it provides a hook for developers to augment so they can create their own context menus.
A cCJGrid class object has no default context menu and CreateContextMenu looks like this:
Function CreateContextMenu Returns Handle
Function_Return 0
End_Function
The cDbCJGrid is assigned a default data-entry context menu (Find, Save, Delete, Clear, etc.) and it looks like this:
Function CreateContextMenu Returns Handle
Handle hoMenu hoMenu1
Get Create (RefClass(cCJContextMenu)) to hoMenu
Get Create of hoMenu (RefClass(cCJPromptMenuItem)) to hoMenu1
Set pbControlBeginGroup of hoMenu1 to True
Get Create of hoMenu (RefClass(cCJFindNextMenuItem)) to hoMenu1
Set pbControlBeginGroup of hoMenu1 to True
Get Create of hoMenu (RefClass(cCJFindPreviousMenuItem)) to hoMenu1
Get Create of hoMenu (RefClass(cCJClearMenuItem)) to hoMenu1
Set pbControlBeginGroup of hoMenu1 to True
Get Create of hoMenu (RefClass(cCJClearAllMenuItem)) to hoMenu1
Get Create of hoMenu (RefClass(cCJSaveMenuItem)) to hoMenu1
Get Create of hoMenu (RefClass(cCJDeleteMenuItem)) to hoMenu1
Function_Return hoMenu
End_Function.
The context menu handle stored in phoContextMenu is the default menu that will be used. It is possible to choose to use a different context menu based on the column selected. When the user right clicks on a data cell, phoContextMenu contains the handle of the context menu to be displayed. Before this menu is displayed, the column function ContextMenu is called. It is passed the value of phoContextMenu and it returns the object handle to actually be used. This allows grid column object to supply custom context menus at the column or even the cell level. See the cCJGridColumn ContextMenu function for a complete description of the context menu display process.
See Also
Return Value
Returns a context menu handle to be used for rows.