Restricting the size of a splitter pane

CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

I find the solution about restrict the size of the pane.

    First derive class XSplitterWnd from CSplitterWnd,
    Then handle the WM_ONSIZE,call the SetColInfo() and SetRowInfo() in OnSize function.
    And handle the WM_MOUSEMOVE and WM_SETCURSOR to prevent user from changing size.


void XSplitterWnd::OnSize(UINT nType, int cx, int cy)
{
RECT rect;
int Height;
GetClientRect( &rect );

Height = rect.bottom – rect.top – 36;

if ( m_pRowInfo != NULL )
if ( Height < 0 ) SetRowInfo( 0, 1, 1); else SetRowInfo( 0, Height, Height ); CSplitterWnd::OnSize(nType, cx, cy); // TODO: Add your message handler code here } void XSplitterWnd::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default //CSplitterWnd::OnMouseMove(nFlags, point); } void XSplitterWnd::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default //CSplitterWnd::OnLButtonDown(nFlags, point); } BOOL XSplitterWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { // TODO: Add your message handler code here and/or call default //return CSplitterWnd::OnSetCursor(pWnd, nHitTest, message); return FALSE; }

Any comments and suggests, please let me know.

Regards, Sesame

Date Last Updated: March 24, 1999

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read