The CExtControlBar::DockControlBarIntoTabbedContainer()
performs the tabbed bar docking. You should dock or float one bar initially and then tab-dock other bars with it. Here is the sample code:
m_wndBarA.DockControlBarInnerOuter(
AFX_IDW_DOCKBAR_LEFT, true );
wndBarA.DockControlBarIntoTabbedContainer(
&wndBarB, -1, NULL, false );
wndBarA.DockControlBarIntoTabbedContainer(
&wndBarC, -1, NULL, false );
wndBarA.DockControlBarIntoTabbedContainer(
&wndBarD, -1, NULL, false );
This source code docks the
m_wndBarA
bar to the left inner part of the main frame window. Then the
m_wndBarB
,
m_wndBarC
and
m_wndBarD
bars are tab-docked into the
m_wndBarA
bar’s area.
Here is the declaration of the
CExtControlBar::DockControlBarIntoTabbedContainer()
method:
virtual bool DockControlBarIntoTabbedContainer(
CExtControlBar * pBar,
INT nIndex = -1, // append
CFrameWnd * pDockSite = NULL, // can be NULL only if bar already was at once docked
bool bRecalcLayout = true
);
The
nIndex
parameter allows you to specify where the newly tab-docked bar should appear. The
CExtControlBar::DockControlBarIntoTabbedContainer()
method can be used both for initial docking and for re-docking with re-arranging the tab order. Detecting the tab-order is a bit more complex task. First of all you should include the following file:
#include <../Src/ExtControlBarTabbedFeatures.h>
This is essential because we will detect the type of bar’s parent window:
CWnd * pWndParent = m_wndBarA.GetParent();
if( ! pWndParent->IsKindOf( RUNTIME_CLASS( CExtDockDynTabBar ) ) )
return; // bar A is not inside the tabbed bar container
Now we can get a pointer to the tabbed control bar window which is also derived from the
CExtControlBar
class:
CExtDynTabControlBar * pTabbedBar =
STATIC_DOWNCAST( CExtDynTabControlBar, pWndParent->GetParent() );
Now we can detect how much bars are inside the tabbed bar group, traverse them and detect whether each of them is visible (the tabbed bar group may contain invisible bars and tabs):
LONG nBarIndex, nBarCount = pTabbedBar->GetSwitcherItemCount();
for( nBarIndex = 0; nBarIndex < nBarCount; nBarIndex ++ )
{
CExtControlBar * pBar = pTabbedBar->GetBarAt( nBarIndex, false );
BOOL bBarIsVisible = pBar->IsVisible();
}
We can also get the selection and change it:
LONG nSel = pTabbedBar->GetSwitcherSelection();
pTabbedBar->SetSwitcherSelection( new_selected_index, true, true );