Context Menu
GridEx supports a right-click context menu for both an inactive cell and for an active cell with CGXEditControl . The implementation is based on use of the Feature Pack class CContextMenuManager.
In the handlers for a right-click event, GridEx uses CContextMenuManager::ShowPopupMenu():
CGXGridCoreEx<T>::OnRButtonClickedRowCol (file GXGridCoreEx.h):
ShowPopupMenu(IDR_POPUP_EDIT, pt.x, pt.y, this, TRUE);
NOTE >> Note: SFLWinAppEx is a class implemented in the FoundationEx library.
For an active cell, new class CPopUpMenuEdit derives from CGXEditControl with the code implemented in handler OnContextMenu in files PopUpMenuEdit.h and PopUpMenuEdit.cpp:
ShowPopupMenu( IDR_POPUP_EDIT,point.x,point.y,Grid()->
GridWnd(), TRUE );
Setting a Context Menu in Grid
GridEx provides a default menu IDR_POPUP_EDIT_OGEX, but you can replace it with a custom menu in your application if you wish. The default menu provides Copy, Cut and Paste commands.
1. In CExcelGridApp::InitInstance(), call InitContextMenuManager().
2. In CExcelGridApp::PreLoadState(), call
You can enable or disable a context menu using these CGXGridCoreEx functions:
*In an active cell with an Edit control: EnableContextMenuInEditCell()
*In the current inactive cell or selected range: EnableContextMenuInCurrentCell()
*In both above cases: EnableContextMenu()
User Interaction
*Right-clicking on an inactive cell: The cell becomes the current cell and a context menu displays.
*Right-clicking on a selected range: The upper left cell becomes the current cell in the selected range, and a context menu displays.
Related Samples
The Context Menu is demonstrated in the sample ExcelGrid.