Sizing TabControlBar | CodeGuru

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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Aug 7, 1998
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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

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.