Print Page | Close Window

Toolbar button rectangles

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=2753
Printed Date: 08 November 2025 at 7:15pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Toolbar button rectangles
Posted By: Jeff1
Subject: Toolbar button rectangles
Date Posted: 19 August 2005 at 10:01am
Do you know how to get the rectangle of the toolbar button that is right clicked on so that a menu can be displayed and aligned with the bottom left corner of the button?

Something like:
get the right click point
find the rect of the button that was right clicked on
appendmenu items to a menu
track the menu and draw it  at bottom left of button

Thanks.



Replies:
Posted By: Jeff1
Date Posted: 22 August 2005 at 4:27pm
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
    switch (pMsg->message)
    {
    case WM_RBUTTONDOWN: // if right mouse down on a controlbar, display a menu
        {
            m_ptButtonRightClick.x=LOWORD(pMsg->lParam);
            m_ptButtonRightClick.y=HIWORD(pMsg->lParam);

            CWnd* pWnd = CWnd::FromHandlePermanent(pMsg->hwnd); if (pWnd == NULL) break;
            CXTPToolBar* pBar = DYNAMIC_DOWNCAST(CXTPToolBar, pWnd);    if (pBar == NULL) break;
            CXTPControl* pControl = pBar->GetControls()->HitTest(m_ptButtonRightClick);     if (pControl == NULL) break;

            CRect rButton;
            rButton=pControl->GetRect();
            pBar->ClientToScreen(&rButton);

            m_ptButtonRightClick.x=rButton.left;
            m_ptButtonRightClick.y=rButton.bottom;
            m_uButtonRightClickID=pControl->GetID();

            PostMessage(WM_COMMAND, m_uButtonRightClickID);
            return TRUE;
        }
        break;
    }

    return MAINFRAME_BASE::PreTranslateMessage(pMsg);
}




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net