Restricting the size of a splitter pane


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

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);
   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


  • How to Restrict the splitter from being moved after a particular size

    Posted by Legacy on 11/30/2002 08:00am

    Originally posted by: Muthukumar K.

    Hi Guys,

    As a whole I have learnt a lot from codeguru. Its really a GURU (teacher in Sanskrit).

    As a need, I have to restrict the splitter from being resized after the pane of a splitter window(two panes) has reached a particular size (on either side i.e. left as well as right side).

    Could you suggest a method ? I tried using many options but it didn't work out for me.

    Bye & Thanks

  • help! How to do??

    Posted by Legacy on 11/01/2002 08:00am

    Originally posted by: zhangsifang

    I want to do splitter windows:
    | | |
    | | |
    | | |
    | | |
    | |
    | |
    | |

    How to do ? email to me zhangsifang@163.net Thanks!

  • More simple method. Just one line...

    Posted by Legacy on 10/29/2002 08:00am

    Originally posted by: JoonKyu Choi



  • static splitter...need help!!!

    Posted by Legacy on 10/29/2002 08:00am

    Originally posted by: Paulo

    i need to do a static splitter with 2 view, one to draw and another with scrooll to display the images i draw in the first view...

  • A quick way

    Posted by Legacy on 11/11/2001 08:00am

    Originally posted by: Shaun

    Just override WM_NCHITTEST message, from your derived CSplitterWnd class, then I add a member variable called m_bLock, and the following functions:

    // public

    void CSplitterWndEx::Lock( BOOL bLock )
    m_bLock = bLock;

    // override the WM_NCHITTEST message

    UINT CSplitterWndEx::OnNcHitTest( CPoint point )
    if( m_bLock )
    return HTNOWHERE; // if locked
    return CSplitterWnd::OnNcHitTest( point );

    Also remember to init m_bLock with a default from the contructor, after creating your splitter and views, call

    m_wndSplitterWnd.Lock( TRUE ); // to lock splitter

    Have fun...



  • It was not Influenced Window..

    Posted by Legacy on 04/09/2001 07:00am

    Originally posted by: Donbu

    I was Implement CXSplitterWnd And Test That.
    But CXSplitterWnd Class was not Influence to the Window..
    They were moved and Resize by mouse Click...
    and.... They can't Set Size Because GetClientRect(&rect)
    may be set the rect struct at all value is 0..
    my English Avility is not so good... But...
    this Example is so Strange... (I wanna use none-Resize Splitter....)

    If Anyone knows this Problem.... Please to Teach me by
    E-Mail ....

    My Address : donbu_com@hanmail.net

  • How can I derive new class from CSplitterWnd ?

    Posted by Legacy on 02/16/2001 08:00am

    Originally posted by: Namkyeong Lee

    I couldn't find CSplitterWnd in Base Class section of New Class Wizard...

    How can I do this??

  • GetClientRect needs ?

    Posted by Legacy on 02/24/2000 08:00am

    Originally posted by: Denis Flotat

    I can't understand the need for GetClientRect function because it always Zero-initialize RECT structure.
    So pane index 0 is always the default size !!!

  • VC 6.0 problems

    Posted by Legacy on 04/06/1999 07:00am

    Originally posted by: Eric Hammond

    It was a real fight to get VC 6.0 to support CSplitterWnd at all.
    I finally got the message support, but the splitter is still re-sizeable.
    What am I missing?


  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date