Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » How to override the context menu for a grid cell in a Property Grid Collapse All
Subject Author Date
Andrew Banks May 8, 2007 - 4:09 PM

Also, I see two different paths on the right click. One where the cell is focused and one where it is not and a right click occurs in the cell.

I see the path when the right click occurs and the cell is not focused. But, I dont want this.

So, how can I:
1) Right click on the cell and make it focused.
2) Then using one path of code, override the edit context menu for the cell when it is focused.

Thanks,

Technical Support May 10, 2007 - 9:01 AM

If you want to implement custom context menus from scratch, you should override the following virtual method of the CExtPropertyGridCtrl class:

virtual void OnPgcContextMenuTrack(
      CWnd * pWndHit,
      CPoint ptScreen,
      CExtGridHitTestInfo * pHtInfo, // can be NULL
      CExtPropertyItem * pPropertyItem, // can be NULL
      CExtPropertyGridWnd * pPGW // can be NULL
      );
Your method should construct and track your popup menu and not invoke parent class method.

But if you want to reconstruct context menus created by default, you should override the following virtual method of the CExtPropertyGridCtrl class:
 virtual bool OnPgcContextMenuReconstruct(
       CExtPopupMenuWnd * pPopup,
       CWnd * pWndHit,
       CPoint ptScreen,
       CExtGridHitTestInfo * pHtInfo, // can be NULL
       CExtPropertyItem * pPropertyItem, // can be NULL
       CExtPropertyGridWnd * pPGW // can be NULL
       );
The pPopup menu is constructed and contains default context menu items. You should modify your menu and return true if the menu has been successfuly initialized. If your method returns false, the pPopup menu will not be displayed.