Re: How to put limits on frame resizing when using splitter window?
As far as I know, you will have to override the WM_MOUSEMOVE message and do
your limiting there.
Basically what you will have to do is copy the content of
CSplitterWnd::OnMouseMove into your CSplitterWnd::OnMouseMove method and
limit the size when the size is being set.
For example this code will limit the left hand panel of the splitter to 400
pixels. (this code is for demonstration purposes. There is no error
checking and It assumes that the pane's initial size is less than 400)
void CLockSplitterWnd::OnMouseMove(UINT nFlags, CPoint pt)
{
enum HitTestValue
{
noHit = 0,
vSplitterBox = 1,
hSplitterBox = 2,
bothSplitterBox = 3, // just for keyboard
vSplitterBar1 = 101,
vSplitterBar15 = 115,
hSplitterBar1 = 201,
hSplitterBar15 = 215,
splitterIntersection1 = 301,
splitterIntersection225 = 525
};
if (GetCapture() != this)
StopTracking(FALSE);
if (m_bTracking)
{
// move tracker to current cursor position
pt.Offset(m_ptTrackOffset); // pt is the upper right of hit detect
// limit the point to the valid split range
if (pt.y < m_rectLimit.top)
pt.y = m_rectLimit.top;
else if (pt.y > m_rectLimit.bottom)
pt.y = m_rectLimit.bottom;
if (pt.x < m_rectLimit.left)
pt.x = m_rectLimit.left;
else if (pt.x > m_rectLimit.right)
pt.x = m_rectLimit.right;
if (m_htTrack == vSplitterBox ||
m_htTrack >= vSplitterBar1 && m_htTrack <= vSplitterBar15)
{
if (m_rectTracker.top != pt.y)
{
OnInvertTracker(m_rectTracker);
m_rectTracker.OffsetRect(0, pt.y - m_rectTracker.top);
OnInvertTracker(m_rectTracker);
}
}
else if (m_htTrack == hSplitterBox ||
m_htTrack >= hSplitterBar1 && m_htTrack <= hSplitterBar15)
{
if (m_rectTracker.left != pt.x)
{
//if the pane is getting smaller or getting bigger and the size is less
then 400 then proceed
if (m_rectTracker.left > pt.x || (m_rectTracker.left < pt.x && pt.x <
400))
{
OnInvertTracker(m_rectTracker);
m_rectTracker.OffsetRect(pt.x - m_rectTracker.left, 0);
OnInvertTracker(m_rectTracker);
}
}
}
else if (m_htTrack == bothSplitterBox ||
(m_htTrack >= splitterIntersection1 &&
m_htTrack <= splitterIntersection225))
{
if (m_rectTracker.top != pt.y)
{
OnInvertTracker(m_rectTracker);
m_rectTracker.OffsetRect(0, pt.y - m_rectTracker.top);
OnInvertTracker(m_rectTracker);
}
if (m_rectTracker2.left != pt.x)
{
OnInvertTracker(m_rectTracker2);
m_rectTracker2.OffsetRect(pt.x - m_rectTracker2.left, 0);
OnInvertTracker(m_rectTracker2);
}
}
}
else
{
// simply hit-test and set appropriate cursor
int ht = HitTest(pt);
SetSplitCursor(ht);
}
}
AliR.
"Bogdan" <bogdan@company.com> wrote in message
news:ODOPIk%239IHA.3612@TK2MSFTNGP04.phx.gbl...
Hi,
I have a static splitter window in SDI. The right pane of the splitter is
a CScrollView. The main frame is resizable.
How do I prevent a user from resizing the frame so the right pane does not
go beyond a given size?. The left pane's size is not important.
I keep the frame size in check on splitter bar drag by calling
ResizeParentToFit(TRUE) .
Thanks,
Bogdan