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 disable/customize the context menu of CExtPropertyGridCtrl? Collapse All
Subject Author Date
Andreas Werner Nov 27, 2006 - 3:28 AM

Hello all,

I want to disable/customize the context menu in my custom property grid. I have subclassed the CExtPropertyGridCtrl class. In my derived class I have overwritten the OnPgcContextMenuTrack method. If I do a right click on an item in the name column of the property grid then the overwritten method is invoked and the context menu for the name column does not appear. If I do a right click on an item in the value column the overwritten method is not invoked and the default context menu for the value column appears.

I have also overwritten the OnPgcContextMenuReconstruct method in my CExtPropertyGridCtrl derived class but it never gets invoked.

How can I disable or customize the context menu for the value column of a property grid?

With best regards Andreas Werner

Technical Support Nov 28, 2006 - 9:17 AM


There is the following property in the CMainDlg class in the PropertyGrid sample:

CExtPropertyGridCtrl m_PGC;
We replaced it with:
CMyPGC m_PGC;
We also defined the following class in this sample and set two break points on both ASSERT_VALID( this ); lines:
    class CMyPGC : public CExtPropertyGridCtrl
    {
    public:
        virtual void OnPgcContextMenuTrack(
            CWnd * pWndHit,
            CPoint ptScreen,
            CExtGridHitTestInfo * pHtInfo, // can be NULL
            CExtPropertyItem * pPropertyItem, // can be NULL
            CExtPropertyGridWnd * pPGW // can be NULL
            )
        {
            ASSERT_VALID( this );
            CExtPropertyGridCtrl::OnPgcContextMenuTrack(
                pWndHit,
                ptScreen,
                pHtInfo,
                pPropertyItem,
                pPGW
                );
        }
        virtual bool OnPgcContextMenuReconstruct(
            CExtPopupMenuWnd * pPopup,
            CWnd * pWndHit,
            CPoint ptScreen,
            CExtGridHitTestInfo * pHtInfo, // can be NULL
            CExtPropertyItem * pPropertyItem, // can be NULL
            CExtPropertyGridWnd * pPGW // can be NULL
            )
        {
            ASSERT_VALID( this );
            bool bRetVal =
                CExtPropertyGridCtrl::OnPgcContextMenuReconstruct(
                    pPopup,
                    pWndHit,
                    ptScreen,
                    pHtInfo,
                    pPropertyItem,
                    pPGW
                    );
            return bRetVal;
        }
    }; // class CMyPGC
After that we rebuilt the PropertyGrid sample application and debugged it. Regardles of where context menus were invoked, we saw both break points invoked in the debug session. So, we guess the problem described in your message may be specific to your project only. Please provide us with more details about your project and property grid control in it. Did you implement any other virtual methods and/or windows message handlers in your property grid class?

Andreas Werner Nov 28, 2006 - 10:18 AM

Hallo support Team,

After comparing your code line by line with my code I found my error. I copied the method signature for the OnPgcContextMenuTrack method form the API specification. In the API specification the 4th parameter is described as reference but in the implementation it as a pointer:

bool CPropertyGridLayerConfig::OnPgcContextMenuReconstruct(
        CExtPopupMenuWnd* pPopup,
        CWnd* pWndHit,
        CPoint ptScreen,
        CExtGridHitTestInfo& htInfo, <== Referenze in the API documentation
        CExtPropertyItem* pPropertyItem,
        CExtPropertyGridWnd* pPGW
    )

In the implementation the signature is:
bool CPropertyGridLayerConfig::OnPgcContextMenuReconstruct(
        CExtPopupMenuWnd* pPopup,
        CWnd* pWndHit,
        CPoint ptScreen,
        CExtGridHitTestInfo* pHtInfo, <== Pointer in the implementation
        CExtPropertyItem* pPropertyItem,
        CExtPropertyGridWnd* pPGW
    )

For this reason I have overloaded the function instead of overwriting it. With the correct signature the overwritten method OnPgcContextMenuReconstruct also gets invoked in my project.

I still have the problem that the overwritten methods only get invoked if the context menu with the "Reset" item is shown. If I click into an editor in the value column and do a right click in an active editor, then the context menu with undo, cut, copy ... etc is shown and the overwritten methods are not invoked.
What is necessary to influence the context menu of the editors in the value column?

I only implement the window message OnCreate.

With best regards Andreas Werner


Technical Support Nov 30, 2006 - 8:44 AM

Thank you for the interesting question. Here are some important notes that should clarify the issue. When some in-place editor is active (so you can actually edit something, e.g. text ) for any grid cell in any grid control, this means the following:

1) The grid control is tracking a local in-thread message loop until the editor is not closed.

2) Everything outside the editor window is considered to be inactive and not relating to it.

3) The context menu displayed by the editor window has to do only to the editor window.

The feature of resynchronization/integration of both context menus (parent control’s menu and editor’s menu) is not supported in Prof-UIS. So if you need to disable the context menu in the editor, you should do this in the editor.

Andreas Werner Nov 30, 2006 - 9:35 AM

Dear support team,

Thank for your explanation of the issue. I have already suspected that the answer would point to this direction.
How can I access the context menu of the editor? The CExtGridCell class does not provide overwritable methods like OnContextMenuTrack or OnContextMenuReconstruct.
Please give me a short instruction of the steps I have to take.

With best regards Andreas Werner

Technical Support Nov 30, 2006 - 12:25 PM

You should use one of the following solutions:

1) Code a custom cell class which implements the CExtGridCell::OnInplaceControlCreate() virtual method.

2) Override the CExtGridWnd::OnGridInplaceControlCreate() virtual method.

Both methods return an HWND handle which is used as the in-place editor for a cell. The instance of the CExtGridInplaceEdit class is created by default. In a CExtGridInplaceEdit-derived class, implement the CWnd::WindowProc() virtual method for handling the WM_CONTEXTMENU standard Windows message.