BiSplitter 1.1


CBiSplitterWnd is an MFC-compatible class for creating a binary splitter window that looks like a Microsoft Outlook window. This class splits the window into two parts, called panes. Each pane can be split into two parts also and so on. In that way, you divide a window into as many panes as you need. The binary splitting gives you the opportunity to arrange the panes in any order except for the most exotic. A special bar, called a splitter or gap, separates one pane from another. The gap can be oriented vertically or horizontally. Gap orientation is specified in the BiSplitter window styles and can be changed at any time. There are numerous properties that are responsible for panels look as well.

What Is New in BiSplitter 1.1

  1. The Unicode Character Set support was added.
  2. The compatibility with VC 6.0 was added.
  3. The BiSplitter incorporation into the C++ project was simpler.

A pane is the container for the view; it displays application-dependent information. The view has to be derived from the CView or CWnd classes. The view is developed by the programmer in accordance with standard MFC conventions. A pane also can contain a view derived from the CBiSplitterWnd class. In that case, the pane is split into two subpanes. On the internal level of the application, this process looks like the building of a binary tree. The root and nodes of the tree are objects derived from the CBiSplitterWnd class. Leaves are objects derived from the CView or CWnd classes. For example, the splitter window, shown in Figure 1, defines the tree in Figure 2.

Figure 1

Figure 2

A pane can contain no view or subpanes. In that case, a background color fills it. Multiple views are allowed for every pane. Besides the view, a pane consists of a border and a caption bar with a Close button and caption text that is drawn on it. All these items are optional. The BiSplitter window supports pane gripping as well. The grip buttons for both panes are positioned on the gap. Pane gripping is not the same as pane closing. When a pane is closed, for example by clicking the Close button, there is no simple way to open it, for example by clicking some control in BiSplitter window. To open a closed pane, the application should call a special function of the CBiSplitter class. Unlike the Close button, the grip button acts in both grip the pane and to expand the gripped pane. But, the disadvantage of gripping is that the gripped pane takes some space in the BiSplitter window; this space is needed to draw the grip button. Unlike this, the Close pane is entirely invisible. The BiSplitter window panes and buttons can be drawn in various styles, both 3D and flat.

You create a BiSplittter window by using the Create function specified in the CBiSplitterWnd class.

Set the BiSplitter initial styles when you create one. You can retrieve and change the styles after creating the BiSplitter window by using the AcquireStyles and ChangeStyles functions. Styles are combined with the bitwise OR operator. After creating a BiSplitter window, you have to create views. You can create any quantity of views, but only two views can be displayed at the same time. There are three kinds of views. The first kind is the view derived from the CView class. For applications that support doc/view architecture, most views will be derived from this class. The second kind is the view derived from the CWnd class. Such views are most appropriate for non-doc/view applications. The third kind is the views derived from the CBiSplitterWnd class. These special-purpose views are destined to split a pane into two subpanes. To create a view of any kind, you have to call the CreateView function.

There are three CreateView functions that have differents set of parameters. These functions are responsible for creating the different kinds of views. After the views have been created, you have to create two panes by using the CreatePane function. Strictly speaking, the CreatePane function does not create a pane; it only initializes the specified pane, assigning a style, view, and caption title. These two panes always exist and you can’t delete any of them or create a new pane. To receive or modify the set of styles, you have to call the AcquirePaneStyles and ChangePaneStyles functions accordingly. The GetPaneView function returns a pointer to the view of the specified pane. Call the GetPaneViewID function if only a view identifier is needed. To receive or change pane caption text, use the GetCaptionText and SetCaptionText functions accordingly. After pane initialization, you can change the pane view by calling the AssignViewToPane function. The following example creates a BiSplitter window with many views.

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
   // create splitter window
   if (!m_wndBiSplitter.Create(this, VSPLITTER | FIXED0 | VIEW3D ))
   return FALSE;

   m_wndBiSplitter.CreateView(RUNTIME_CLASS(CPaneTreeView), 0,
   m_wndBiSplitter.CreateView(RUNTIME_CLASS(CPaneListView), 1,
   m_wndBiSplitter.CreateView(RUNTIME_CLASS(CPaneEditView), 2,
   m_wndBiSplitter.CreateView(RUNTIME_CLASS(CPaneFormView), 3,
   m_wndBiSplitter.CreateView(RUNTIME_CLASS(CPaneTreeView), 10,
   m_wndBiSplitter.CreateView(RUNTIME_CLASS(CPaneListView), 11,
   m_wndBiSplitter.CreateView(RUNTIME_CLASS(CPaneEditView), 12,
   m_wndBiSplitter.CreateView(RUNTIME_CLASS(CPaneFormView), 13,

  if (
   !m_wndBiSplitter.CreatePane(0, THICK_BORDER | SMCAPTION |
                               THICK_CAPTIONBORDER | CLOSEBTN |
                               FLAT_BUTTON | GRIPBTN
   , "First pane", m_wndBiSplitter.GetView(0) )


   !m_wndBiSplitter.CreatePane(1, THICK_BORDER | SMCAPTION |
                               THICK_CAPTIONBORDER | FLAT_BUTTON
   , "Second pane", m_wndBiSplitter.GetView(11))

      return FALSE;

   return TRUE;

After the panes have been created, you can set the gap position and width by using the SetSplitterPos and SetSplitterGap functions. The HidePane and ShowPane functions allow you to hide or show either of the panes.

Creating a BiSplitter Project

You can use the current version of BiSplitter in the VC++.NET 2003 or VC++ 6.0 environment. To create a BiSplitter application, you should create an MFC project, write code for the BiSplitter initialization, and attach the BiSplitter.h and BiSplitter.cpp files.

It’s easiest to create the BiSplitter project by using the MFC Application Wizard. You start to create a BiSplitter application by creating an MFC application in the Windows Explorer style. After this, go to the MainFrm.h file and replace the following line:

CSplitterWnd m_wndSplitter;

with this line:

CBiSplitterWnd m_wndSplitter;

Then, go to the CMainFrame::OnCreateClient function and rewrite its body to create a BiSplitter window. After this, go to the CMainFrame::GetRightPane function and replace this line:

CWnd* pWnd = m_wndSplitter.GetPane(0, 1);

with the new line:

CWnd* pWnd = m_wndSplitter.GetPaneView(1);

Then, include the BiSplitter.h file in the MainFrm.cpp and <application name>.cpp files. You have to include this file before the #include “MainFrm.h” line.

More by Author

Must Read