COX3DTabViewContainer
Copyright © The Code Project 1997 - 1999, All Rights Reserved

For most applications it's not enough to use only one window to provide its all output. There are different solutions for this problem like splitters or docking windows. But they usually have common inconvenience: all windows are shown at the same time. They take a precious screen space while could be rarely used. 

COXShortcutBar control can be used in order to show a number of child windows while keeping active (fully displayed) only one at a time. But COXShortcutBar was primarily designed to show icons and have a set of notifications that make sense only while using such controls as treeview or listview. 

Very good example of how the problem could be resolved can be found in Microsoft Visual Studio IDE. For instance "Output" window (with "Build", "Debug", "Find in Files..." panes) or "Result List" window (with "Search", "Lookup", "See Also" and "History" panes). We call them TabViews. 

TabViews can be a good alternative for splitter window when you need to have more than one view per document. Also TabViews can be used within a docking window and used as a container for associated windows (pages) that usually implemented as dialog bars. 

We already have in the library COXTabViewContainer class that implements the TabViews paradigm. In terms of graphical representation this class duplicates the functionality that can be found in such products as Microsoft Visual Studio IDE (Output window) or Microsoft Excel (multiple sheets in the same book). Tab buttons are positioned at the bottom of the window on the same line as the horizontal scroll bar. 

Here we introduce new implementation of the TabViews. The paradigm remains the same but we've changed the way associated windows (pages) represented in the container. We used standard Tab control and displayed a tab button for each page. When a user clicks a button the corresponding page is activated and displayed. Tab buttons can be positioned at any side of the container window by means of applying corresponding Tab control styles (refer to Create() function for details). 

The new class is called COX3DTabViewContainer. It is derived from the standard CTabCtrl and implements all functionality needed to support tab views. 
COX3DTabViewContainer is easy to use. If you previously worked with COXTabViewContainer class then you are already know ho to use this class because we decide to implement it as close as possible to the existing COXTabViewContainer  class. If you haven't used this class yet then the closest comparison would be splitter windows. 

Here is the list of steps that should be taken in order to deploy TabViews in your application: 

First Case: COX3DTabViewContainer will be used as a container for document view(s). 

1) Embed a COX3DTabViewContainer member variable in the parent frame (main frame window for SDI application, MDIChild window for MDI application). 

2) Override the parent frame's CFrameWnd::OnCreateClient() member function. 

3) From within the overridden OnCreateClient, call the Create() member function of COX3DTabViewContainer. In this function you have to specify the parent window and optionally you can specify the initial rectangle, window styles and window ID. This function is the place where you can specify Tab control styles that defines the way tab buttons are positioned and displayed. 

4) If you plan to assign images to TabView pages then you have to create and load image list with images and associate it with COX3DTabViewContainer object using CTabCtrl::SetImageList() function.

5) After COX3DTabViewContainer window was successfully created you can populate it with window objects using AddPage() or InsertPage() functions. If you are inserting view object you have to specify runtime class and context information in order to keep the document/view architecture in place. If you are adding a window object that is not a document view then you have to create it before adding it to COX3DTabViewContainer window. In AddPage() or InsertPage() functions you can specify text that will be used as page title in the corresponding tab button. Also you can specify the index of image in the tab control image list that should be displayed in the tab button. 

Second Case: COX3DTabViewContainer will be used as a container for windows within a control bar. 

1) Create your own CControlBar-derived class (you can use our COXSizeControlBar as parent class if you need sizable docking windows). Let's call it CMyControlBar. 

2) Embed a COX3DTabViewContainer member variable in this class. 

3) Override CMyControlBar::OnCreate() member function. 

4) From within the overridden OnCreate(), call the Create() member function of COX3DTabViewContainer. In this function you have to specify the parent window and optionally you can specify the initial rectangle, window styles and window ID. This function is the place where you can specify Tab control styles that defines the way tab buttons are positioned and displayed. 

5) If you plan to assign images to TabView pages then you have to create and load image list with images and associate it with COX3DTabViewContainer object using CTabCtrl::SetImageList() function.

6) After COX3DTabViewContainer window was successfully created you can populate it with window objects using AddPage() or InsertPage() function. You have to create window object before adding it to COX3DTabViewContainer. In AddPage or InsertPage functions you can specify text that will be used as page title in tab button. Also you can specify the index of image in the tab control image list that should be displayed in the tab button. 

7) Override CMyControlBar::OnSize() member function and resize in it COX3DTabViewContainer object as appropriate

Note, that any child window can be used as COX3DTabViewContainer page.

The steps that should be taken in order to implement COX3DTabViewContainer in CControlBar derived window can be applied in general case too. We just decided to show it using CControlBar derived window because we think it's going to be used as parent window for COX3DTabViewContainer in most cases. 
Above we described the process of creating and populating of COX3DTabViewContainer object. In most cases that would be all the code you need. For those who need to change dynamically the contents of COX3DTabViewContainer object we provide a set of the following functions. 

In order to remove any page at run time you have to use DeletePage() function. 

To set/retrieve page title that is displayed in corresponding tab button use GetPageTitle() and SetPageTitle() functions. 

To set/retrive active page index call GetActivePageIndex() and SetActivepageIndex() functions. 

Refer to the class reference for the list and description of all public functions.