Sizing TabControlBar

Download Source Code and Example


This article extends the article “Resizable Docking Window 2” by
Cristi Posea.

Features


Control bar like in DevStudio, which has TabControls with different Views (like TreeViews)
and it can be docked and resized.

Instructions

Add the following class to your project:

CSizingControlBar

CSizingTabCtrlBar

Add a member variable to CMainFrame (in mainfrm.h).

CSizingTabCtrlBar m_wndSTCBar;

Create the bar in CMainFrame::OnCreate(). Then set bar styles, enable it to dock… like any
control bar. Be sure to add IDW_PROP_BAR to the “resource.h” and to add the bitmap IDB_TABIMAGES
to your resources.

// SizingControlBar
m_wndSTCBar.Create(this, CSize(200, 1), IDW_PROP_BAR);
m_wndSTCBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
	CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndSTCBar.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndSTCBar, AFX_IDW_DOCKBAR_LEFT);

m_wndSTCBar.AddView("Database", RUNTIME_CLASS(CClassView));
m_wndSTCBar.AddView("Files", RUNTIME_CLASS(CFileView));

As you can see, the different views are added by calling

m_wndSTCBar.AddView("Files", RUNTIME_CLASS(CFileView));

Thats the only thing you have to do, to add a view!

Override CMainFrame::RecalcLayout().
Note: use the base framewnd class member function, ie if you have an SDI application
replace CMDIFrameWnd with CFrameWnd below.

void CMainFrame::RecalcLayout(BOOL bNotify)
{
	CMDIFrameWnd::RecalcLayout(bNotify);
	CMDIFrameWnd::RecalcLayout(bNotify);
}

To call a view from the Mainframe:

CFileView* pView = (CFileView*)
	m_wndSTCBar.GetView(RUNTIME_CLASS(CFileView));
pView->UpdateView();	// or do anything else
m_wndSTCBar.SetActiveView(RUNTIME_CLASS(CFileView));

Last updated: 14 May 1998

More by Author

Must Read