Tabbed views within a splitter window | CodeGuru

Tabbed views within a splitter window

This article presents a class which can be used to create tabbed views within a splitter window. As a starting point, I used Daniel Harth’s article about tabbed views within frame windows (SDI frame window or MDI child window). Since splitter window dynamically creates a view object (based on RUNTIME_CLASS information), tabbed window is created […]

Written By
CodeGuru Staff
CodeGuru Staff
Jan 15, 1999
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

This article presents a class which can be used to create
tabbed views within a splitter window. As a starting point,
I used Daniel Harth’s article
about tabbed views within frame windows (SDI frame window
or MDI child window).

Since splitter window dynamically creates a view object
(based on RUNTIME_CLASS information), tabbed window is
created in the same way. In order to perform the creation
of all the views (tabs) within a tab window, this class
contains a virtual function DoCreateView(…) which is
called from within a Create() member function that actually
creates a tab window. Default implementation of DoCreateView(…)
function simply asserts since the actual creation of all the
views is delegated to an overloaded function in the derived class.

Besides this technique, there are several other functions:

(1) virtual function called after the view (tab) is changed

(2) virtual function which is called to determine whether the
switch to another view is allowed or not (by default it is allowed)

(3) function to change the label in runtime

(4) several informational function to get the pointer to the
current view, get the current tab index, get the label etc.

Here is a pseudo code that shows how to use this class:

Declare a derived class specific to your project:

class TMyTab : public TVisualTabInSplitter
{
protected:
 DECLARE_DYNCREATE(TMyTab)
public:
 virtual ~TMyTab();
 virtual void DoCreateView(CCreateContext *pContext);
};

Class implementation:

IMPLEMENT_DYNCREATE(TMyTab,TVisualTabInSplitter)
TMyTab::~TMyTab()
{
}
void TMyTab::DoCreateView(CCreateContext *pContext)
{
 CreateView(Page 1, RUNTIME_CLASS(CTreeView), pContext);
 CreateView(Page 2, RUNTIME_CLASS(CListView), pContext);
}

If you are creatng an SDI application, then use the
following code as a sample:

BOOL DerivedFromCFrameWnd::OnCreateClient(…, CCreateContext *pContext)
{
 Splitter.CreateStatic(this,1,2);
 Splitter.CreateView(0,0,RUNTIME_CLASS(TTreeView),CSize(150,0),pContext);
 Splitter.CreateView(0,1,RUNTIME_CLASS(TMyTab),CSize(0,0),pContext);
 return TRUE;
}

Of course, you could also use a nested splitter window.

I intend to design a tabbed views class that can be used as
a child to frame window and that can contain a splitter window
on one of the tabs. You may collect the latest version of the
class from my Web site:
www.scasoftware.com.

Last updated: January 15, 1999.

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.