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 » Context menu (Right click) on a CExtButton Collapse All
Subject Author Date
John Kiernan Aug 8, 2006 - 9:39 AM

I would like to display a popup menu when I right click on a CExtButton.
What is the best way to do this?

Technical Support Aug 8, 2006 - 9:55 AM

If you want to display a right click based popup menu only over the client area of the CExtButton window, we would recommend you create and use a CExtButton button class like as follows:

class CYourButton : public CExtButton
{
protected:
    virtual LRESULT WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
    {
        if( message == WM_RBUTTONDOWN )
        {
            CPoint pointClient( LOWORD(lParam), HIWORD(lParam) );
            CPoint pointScreen = pointClient;
            ClientToScreen( &pointScreen );
            CExtPopupMenuWnd * pPopup = new CExtPopupMenuWnd;
            if( ! pPopup->LoadMenu( . . . ) )
            {
                delete pPopup;
                return 0L;
            }
            if( ! pPopup->TrackPopupMenu( pointScreen.x, pointScreen.y ) )
            {
                delete pPopup;
                return 0L;
            }
            return 0L;
        }
        LRESULT lResult = CExtButton::WindowProc( UINT message, WPARAM wParam, LPARAM lParam );
        return lResult;
    }
};

John Kiernan Aug 8, 2006 - 12:37 PM

Thank you. That is exactly what I was looking for.