COX3DTabViewContainer Overview

Dundas

COX3DTabViewContainer Overview

Copyright © Dundas Software Ltd. 1997 - 1999, All Rights Reserved

Class Reference

Dependencies and Related Files


Example of a 3DTabViewContainer:

 
For most applications it's not enough to use only one window to provide output. There are different solutions for this problem like splitters or docking windows but they usually have one common inconvenience: all of the windows are shown at the same time, taking up precious screen space while being unused.

A good example of how this problem can be resolved can be found in the Microsoft Visual Studio IDE with its "Output" window (with "Build", "Debug", "Find in Files..." panes) and "Result List" window (with "Search", "Lookup", "See Also" and "History" panes). We call these windows TabViews.

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

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

COX3DTabViewContainer is derived from the standard CTabCtrl and implements all of the functionality needed to support tab views.

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

First Case Scenario: 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 the COX3DTabViewContainer. You will have to specify the parent window and you can optionally specify the initial rectangle, window styles and the window ID. This is where you can specify the Tab control styles that define the way tab buttons are positioned and displayed.

4) To assign images to TabView pages you will have to create and load an image list and associate it with a COX3DTabViewContainer object using the CTabCtrl::SetImageList() function.

5) After the COX3DTabViewContainer window is successfully created you can populate it with window objects using the AddPage() or InsertPage() functions. If you are inserting a view object you have to specify the 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 will have to create it before adding it to the COX3DTabViewContainer window. In the AddPage() or InsertPage() functions you can specify the text that will be used as the page title in the corresponding tab button. You can also specify the index of the image in the tab control's image list that should be displayed in the tab button.

For example:

BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)

 

{
// TODO: Add your specialized code here and/or call the base class

UNREFERENCED_PARAMETER(lpcs);

if(!m_TabViewContainer.Create(this))

  return FALSE;

VERIFY(m_ilTabView.Create(IDB_IL_TABVIEWS,16,0,RGB(255,0,255)));

m_TabViewContainer.SetImageList(&m_ilTabView);

if(!m_TabViewContainer.AddPage(pContext->m_pNewViewClass,
  pContext,_T("Primary View"),0))

{
    return FALSE;

}

if
(!m_TabViewContainer.AddPage(RUNTIME_CLASS(CMyView2),

    pContext,_T("View2"),1))

{
    return FALSE;

}

m_TabViewContainer.SetActivePageIndex(0);


return
TRUE;

 

}

 

Second Case Scenario: The 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 a parent class if you need sizable docking windows). Let's call it CMyControlBar.

2) Embed a COX3DTabViewContainer member variable in this class.

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

4) From within the overridden OnCreate(), call the Create member function of the COX3DTabViewContainer object. You have to specify the parent window and you can optionally specify the initial rectangle, window styles and window ID. This is 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 an image list and associate it with the COX3DTabViewContainer using the CTabCtrl::SetImageList() function.

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

7) Override the CMyControlBar::OnSize() member function and resize the COX3DTabViewContainer object.

For example:

int CMyControlBar::OnCreate(LPCREATESTRUCT lpCreateStruct)

 

{

if (COXSizeControlBar::OnCreate(lpCreateStruct) == -1)

    return -1;

if(!m_TabViewContainer.Create(this))

    return -1;

VERIFY(m_ilTabView.Create(IDB_IL_TABVIEWS,16,0,RGB(255,0,255)));

m_TabViewContainer.SetImageList(&m_ilTabView);

 
// edit control

if(!edit.Create(WS_CHILD|ES_MULTILINE|ES_AUTOHSCROLL|
    ES_AUTOVSCROLL|WS_HSCROLL|WS_VSCROLL,CRect(0,0,0,0),

    &m_TabViewContainer,1))

{

    return -1;

}

m_TabViewContainer.AddPage(&edit,_T("Edit"),0);

 
// list box

if(!listBox.Create(WS_CHILD|WS_HSCROLL|WS_VSCROLL,
    CRect(0,0,0,0),&m_TabViewContainer,2))

{

    return -1;

}

m_TabViewContainer.AddPage(&listBox,_T("ListBox"),1);

 
// list control

if(!listCtrl.Create(WS_CHILD|LVS_REPORT,
    CRect(0,0,0,0),&m_TabViewContainer,3))

{

    return -1;

}

m_TabViewContainer.AddPage(&listCtrl,_T("List"),2);

 
// tree control

if(!treeCtrl.Create(WS_CHILD|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS,
    CRect(0,0,0,0),&m_TabViewContainer,4))

{

    return -1;

}

m_TabViewContainer.AddPage(&treeCtrl,_T("Tree"),3);

m_TabViewContainer.SetActivePageIndex(0);

return 0;

}

 

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

The steps to be taken in order to implement COX3DTabViewContainer in a CControlBar derived window should be used in general cases as well. A CControlBar derived window was used above since it is a likely choice for the parent window.

The following functions have been provided for those who need to dynamically change the contents of a COX3DTabViewContainer object:

In order to remove any page at run time call the DeletePage() function.

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

To set/retrieve the active page index call GetActivePageIndex() and SetActivepageIndex().

For more information examine the sample found in: <INSTALLDIR>\3DTabVws\Samples\Gui\3DTabView\TabViews.dsw