Simple Splitter


I have seen many programmers asking how to create a splitter window in a dialog box. Unfortunately MFC does not provide a splitter control that can be directly embedded into a dialog box. CSplitterWnd is somehow designed to be used only inside a frame window. I have also seen a few attempts, but none is generic and easy to use.

The class I am presenting is designed for general purpose. The name is CSplitterBar, the function is to provide a splitter bar that can be embedded into any kind of windows, such as a frame, a view or a dialog box.

The example I am giving here is to create a CSplitterbar control in a dialog box. If you would like to use CSplitterBar in other kinds of windows, the procedure described here can be easily adapted.

  1. Firstly, declare an object of CSplitterBar in your dialog class:

CSplitterBar m_wndSplitterBar;

2. Secondly, create the m_wndSplitterBar object in the InitDialog function:


//Create a splitter bar

CRect rect(0,0,0,0);

m_wndSplitterBar.Create(WS_CHILD|WS_BORDER|WS_DLGFRAME|WS_VISIBLE, rect,this,999);


3. Finally, setup the windows on the left pane and right pane of the splitter bar:

//Insert the splitter bar between a tree and a list control



That is all your need to do, and let the CSplitterBar handle all of the rest. The full source code can be downloaded from here:

To use CSplitterBar in your own project, you only need to include two files: SplitterBar.h and SplitterBar.cpp.


There is also a message "WM_SPLITTER_MOVED" is generated by the splitter bar whenever the control is dragged then dropped. If you want to do something special when the splitter is repositioned, then provide a message handler for this message.

Download Documentation and Source (48.5k)


  • Nike Air Max+instagram, will you hold the color to step on your feet!

    Posted by madytreathy on 04/20/2013 07:20am

    Call to mind in 2008, if not earlier, when Nike launched on of the separated shoe color projects, the war cry "Scion Your Colours", "Nike PhotoiD" layout, [url=]nike air max 90[/url] reply has not been as enthusiastic as expected. Have in mind, 2008 Canon IXUS 80 IS Digital card arcade but purely 8 million pixels, Nokia, the mobile phone retail is the exclusively administration, NikeiD was boost to color in the photos as a basis quest of sneakers duty color, although gripping, but does bother some. Instagram which cause this article hold up to ridicule and elemental, Nike PHOTOiD homeopathic upgrade customization services, recently [url=]nike huarache free[/url] released a new plan. That such iD can you implement pictures as instagram account shoe color, the meanwhile make available Nike Air Max shoes and Nike Air Max 1, Nike Feeling Max 90 953 options. Interested in children's shoes, you [url=]nike free uk[/url] can without exception conform with each other's legitimate website, in beyond to skim through other people's creative sweat, or you can hear to upload your own instagram photo, base your own Nike Air Max.

  • Right drag fix

    Posted by christig on 12/25/2004 11:05pm

    void CSplitterBar::OnLButtonUp(UINT nFlags, CPoint point) ... else { ... if(point.x < pointLeftMost.x) point.x=pointLeftMost.x; if(point.x > pointRightMost.x) point.x=pointRightMost.x-m_rectSplitter.Width();//fix

  • Saying thanks then another big question.

    Posted by Legacy on 02/17/2004 12:00am

    Originally posted by: Kimjuhoon

    This is exactly what i wanted to find out. thanks so much for posting this class. but I have one more big difficult problem.

    Originally, I was supposed to put some buttons on / under the splitterbar. but I really don't know how to make it.

    good example is MSN messanger that is conversation dialog.

    There's some buttons under splitter bar such as smiley and fond setting and so on.

  • Can it be used in an ATL composite control?

    Posted by Legacy on 10/10/2003 12:00am

    Originally posted by: Joar Vatnaland

    I have an ATL view class based on CComCompositeControl. Is it possible to use the splitterbar there? I haven't been able to make it work.

  • Invisible Splitter Bars Please!

    Posted by Legacy on 02/28/2003 12:00am

    Originally posted by: Jimmy


    Is there any way to create fully functional splitter bars that are invisible?

    Basically everything is great, BUT I don't want the splitter bars to display. Not setting WS_VISIBLE makes the control invisible, but also disables any use of the control.


  • Cursor disappered when using staticly linked MFC

    Posted by Legacy on 11/12/2002 12:00am

    Originally posted by: Hacker

    So you must add cursor resource to your project by hand when using staticly linked MFC. Or any other resolutions I don't know?

  • dragger drawn outside pane

    Posted by Legacy on 10/17/2002 12:00am

    Originally posted by: Christian Utama

    A little fix to prevent the dragger to be drawn outside its client panes:

    // add this function

    BOOL CSplitterBar::isInside(CPoint pt)
    CRect left, right, total;
    total = left | right;
    CPoint temp = pt;
    if (total.PtInRect(temp))
    return TRUE;
    return FALSE;

    void CSplitterBar::DrawDraggingBar(CPoint point,DRAGFLAG df)

    // add this line
    if (!isInside(point)) return;

  • Overlapping Splitter Bars

    Posted by Legacy on 01/30/2002 12:00am

    Originally posted by: Ulrike Scheibner

    I'm using CSplitterBar in my dialog. There are two splitter bars around a button. On the left hand side is a tree control. A vertical splitter bar separates the tree control and the button. On bottom is another tree control. A horizontal splitter bar separates the tree control and the button. It looks like Outlook.
    When I move the vertical splitter bar right and the horizontal splitter bar up (both splitter bars are overlapped in a range) the display isn't correct. The vertical splitter bar isn't drawn completely. (A screenshot would explain the problem better.)
    Is this problem known or does anybody know a solution?

  • How to restore "CSplitterWnd"?

    Posted by Legacy on 10/31/2001 12:00am

    Originally posted by: Henry

    "CSplitterWnd" can creat in "Frame::OnCreateClient",
    and can destroy by "DeleteView","DeleteRow".

    How to restore it?

  • Buggy Code

    Posted by Legacy on 05/31/2001 12:00am

    Originally posted by: Colin MacKenzie

    Problems using as horizontal splitter between two static derived controls.

    No ability to set splitter range - though a simple func can be written. Range is also computed in error. It thinks 100 pixels is the max for the top window?????

    Right pane is not resized properly, its bottom member is not set to bottom of window. However, it does set it to the same as the top member on creation???? (why)

    Sorry, making my own...

  • Loading, Please Wait ...

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

Top White Papers and Webcasts

Most Popular Programming Stories

More for Developers

RSS Feeds

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