Print Page | Close Window

splitter class CXTSplitterWndEx

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=2323
Printed Date: 08 November 2025 at 11:35am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: splitter class CXTSplitterWndEx
Posted By: Maye Johnson
Subject: splitter class CXTSplitterWndEx
Date 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;
    }
}




Replies:
Posted By: Maye Johnson
Date 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);
    }
}





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