Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Small HitTest Issue with CXTPTabWorkspace
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Small HitTest Issue with CXTPTabWorkspace

 Post Reply Post Reply
Author
Message
vladsch View Drop Down
Newbie
Newbie


Joined: 04 February 2004
Location: Canada
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote vladsch Quote  Post ReplyReply Direct Link To This Post Topic: Small HitTest Issue with CXTPTabWorkspace
    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.

 



Edited by vladsch
Back to Top
vladsch View Drop Down
Newbie
Newbie


Joined: 04 February 2004
Location: Canada
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote vladsch Quote  Post ReplyReply Direct Link To This Post 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);
}

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.