Print Page | Close Window

Small HitTest Issue with CXTPTabWorkspace

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=423
Printed Date: 23 December 2024 at 8:11am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Small HitTest Issue with CXTPTabWorkspace
Posted By: vladsch
Subject: Small HitTest Issue with CXTPTabWorkspace
Date Posted: 05 February 2004 at 5:27pm

The CXTPTabWorkspace control does not exclude the button region from the tab hit test. This makes a partial tab displayed under the button area show as Hovering over when the mouse is in the button area. Also allows you to Drag a tab when starting the drag in the button area.

Solution:

Add protected int m_nButtonWidth member to CXTPTabWorkspace. In paint manager DrawTabControlXXXXX functions at the top of each function clear this variable to 0 and after caclulating the nButtonWidth local variable assign the value to pCtrlTab->m_nButtonWidth. In every style of paint manager DrawTabControlXXXX.

Change HitTest to exclude that area from a valid tab button area.

int CXTPTabWorkspace::HitTest(CPoint point)
{
    CRect rc;

    GetClientRect(&rc);
    rc.right -= m_nButtonWidth;

    if (rc.PtInRect(point))
    {
        for (int i = 0; i < m_arrTab.GetSize(); i++)
        {
             if (m_arrTab.rcItem.PtInRect(point))
             {
                 return i;
             }
        }
    }
    return -1;
}

Add the same wrapper in CXTPTabWorkspace::OnMouseMove

void CXTPTabWorkspace::OnMouseMove(UINT nFlags, CPoint point)
{
    CRect rc;

    GetClientRect(&rc);
    rc.right -= m_nButtonWidth;

    if (rc.PtInRect(point))
    {
        if (m_nItemTracking != -1)
        {
           . . .

        }
    }

    else

    {

        if (TRUE)//if (m_dwStyle & CBRS_ALIGN_TOP)
        {
             m_btnClose.CheckForMouseOver(this, point);
             m_btnLeft.CheckForMouseOver(this, point);
             m_btnRight.CheckForMouseOver(this, point);
        }
    }

    HighlightFocused();

    CWnd::OnMouseMove(nFlags, point);
}

The tabs will stop seeing the mouse in the button area as over the tab. Someone who is more familiar with the toolkit should review this fix. I could have easily missed something critical.

 




Replies:
Posted By: vladsch
Date Posted: 05 February 2004 at 6:37pm

I missed adding the same exclusion test in CXTPTabWorkspace::LButtonDown around the for loop, this disables dragging of a tab by starting in the button area:

    CRect rc;
   
    GetClientRect(&rc);
    rc.right -= m_nButtonWidth;
   
    if (rc.PtInRect(point))
    {
        for (int i = 0; i < m_arrTab.GetSize(); i++)
        {
             if (m_arrTab.rcItem.PtInRect(point))
             {
                 for (int j = 0; j < m_arrTab.GetSize(); j++)
                     m_lstRects.Add(m_arrTab[j].rcItem);
                
                 m_nItemTracking = i;
                 SetCapture();
                 Invalidate(FALSE);
                 break;
             }
        }
    }

    CWnd::OnLButtonDown(nFlags, point);
}




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