Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - splitter class CXTSplitterWndEx
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

splitter class CXTSplitterWndEx

 Post Reply Post Reply
Author
Message
Maye Johnson View Drop Down
Groupie
Groupie


Joined: 16 October 2004
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote Maye Johnson Quote  Post ReplyReply Direct Link To This Post Topic: splitter class CXTSplitterWndEx
    Posted: 04 June 2005 at 9:47pm
I wanted a class to specify the border colors of the splitter bar, and to specify minimum and maximum sizes of views, so I created CXTSplitterWndEx2.


.H file

class CXTSplitterWndEx2 : public CXTSplitterWndEx
{
public:
    CXTSplitterWndEx2();

    virtual void            SetColors                        (COLORREF crTL, COLORREF crBR, COLORREF crInside);
    virtual void            SetMinMax                        (UINT nMin, UINT nMax);
    virtual void            OnDrawSplitter                    (CDC* pDC, ESplitType nType, const CRect& rectArg);
    virtual void            StartTracking                    (int ht);

protected:
    COLORREF                m_crTopLeft, m_crBottomRight, m_crInside;
    UINT                    m_nMin, m_nMax;
};



.CPP file

CXTSplitterWndEx2::CXTSplitterWndEx2()
{
    m_crTopLeft = RGB(255, 255, 255);
    m_crBottomRight = RGB(173, 170, 156);
    m_crInside = RGB(239, 235, 222);
    m_nMin = m_nMax = 0;
}

void CXTSplitterWndEx2::SetMinMax(UINT nMin, UINT nMax)
{
    m_nMin = nMin;
    m_nMax = nMax;
}

void CXTSplitterWndEx2::SetColors(COLORREF crTL, COLORREF crBR, COLORREF crInside)
{
    m_crTopLeft = crTL;
    m_crBottomRight = crBR;
    m_crInside = crInside;
}

void CXTSplitterWndEx2::StartTracking(int ht)
{
    CXTSplitterWndEx::StartTracking(ht);

    // horizontal splitter, undocumented Microsoft values
    if (ht >= 101 && ht <= 115)
    {
        m_rectLimit.top += m_nMin;
        if (m_nMax != 0)
            m_rectLimit.bottom -= (m_rectLimit.bottom - m_nMax);
    }
    // vertical splitter, undocumented Microsoft values
    else if (ht >= 201 && ht <= 215)
    {
        m_rectLimit.left += m_nMin;
        if (m_nMax != 0)
            m_rectLimit.right -= (m_rectLimit.bottom - m_nMax);
    }
}

void CXTSplitterWndEx2::OnDrawSplitter(CDC* pDC, ESplitType nType, const CRect& rectArg)
{
    if (pDC == NULL)
    {
        RedrawWindow(rectArg, NULL, RDW_INVALIDATE | RDW_NOCHILDREN);
        return;
    }

    ASSERT_VALID(pDC);

    if (nType == splitBar)
    {
        CRect    rect = rectArg;
        // Draw outside of rectangle.
        pDC->Draw3dRect(rect, m_crTopLeft, m_crBottomRight);
        rect.InflateRect(-GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
        // Draw inside of rectangle.
        pDC->FillSolidRect(rect, m_crInside);
        return;
    }
}



Edited by Maye Johnson
Back to Top
Maye Johnson View Drop Down
Groupie
Groupie


Joined: 16 October 2004
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote Maye Johnson Quote  Post ReplyReply Direct Link To This Post Posted: 06 June 2005 at 1:53pm
Had a bug in StartTracking(), with vertical splitter subtracking from bottom instead of right.  it should be:


void CXTSplitterWndEx2::StartTracking(int ht)
{
    CXTSplitterWndEx::StartTracking(ht);

    // horizontal splitter, undocumented Microsoft values
    if (ht >= 101 && ht <= 115)
    {
        m_rectLimit.top += m_nMin;
        if (m_nMax != 0)
            m_rectLimit.bottom -= (m_rectLimit.bottom - m_nMax);
    }
    // vertical splitter, undocumented Microsoft values
    else if (ht >= 201 && ht <= 215)
    {
        m_rectLimit.left += m_nMin;
        if (m_nMax != 0)
            m_rectLimit.right -= (m_rectLimit.right - m_nMax);
    }
}


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.063 seconds.