Professional User Interface Suite, Copyright FOSS Software Inc. Help Published with Permission.

First of all, to specify initial positions of the toolbars (CExtToolControlBar), you need to use the CFrameWnd::DockControlBar() method rather than CExtControlBar::DockControlBar(). This is also true for the menu bar (CExtMenuControlBar) and panel control bars (CExtPanelControlBar).

Let's assume you have two toolbars (m_wndToolBar1 and m_wndToolBar2 toolbars which you want to dock into one row and either of them may be initially invisible.

1. Both control bars are initially visible:

CRect wrAlredyDockedBar;
DockControlBar( &m_wndToolBar1 );
RecalcLayout();
m_wndToolBar1.GetWindowRect(
   &wrAlredyDockedBar
);
wrAlredyDockedBar.OffsetRect( 1, 0 );
DockControlBar(
   &m_wndToolBar2,
   AFX_IDW_DOCKBAR_TOP,
   &wrAlredyDockedBar
);

2. The second control bar is invisible:

CRect wrAlredyDockedBar;
DockControlBar( &m_wndToolBar2 );
RecalcLayout();
m_wndToolBar2.GetWindowRect(
   &wrAlredyDockedBar 
);
DockControlBar(
   &m_wndToolBar1,
   AFX_IDW_DOCKBAR_TOP,
   &wrAlredyDockedBar
);
ShowControlBar(
   &m_wndToolBar2,
   FALSE,
   FALSE
);

You may have noticed that we docked it in the reverse order. This is required in order to place m_wndToolBar2 after m_wndToolBar1.

3. The first control bar is invisible:

CRect wrAlredyDockedBar;
DockControlBar( &m_wndToolBar1 );
RecalcLayout();
m_wndToolBar1.GetWindowRect(
   &wrAlredyDockedBar
);
DockControlBar(
   &m_wndToolBar2,
   AFX_IDW_DOCKBAR_TOP,
   &wrAlredyDockedBar
);
ShowControlBar(
   &m_wndToolBar1,
   FALSE,
   FALSE
);

4. Both control bars are invisible:

CRect wrAlredyDockedBar;
DockControlBar( &m_wndToolBar1 );
RecalcLayout();
m_wndToolBar1.GetWindowRect(
   &wrAlredyDockedBar
);
wrAlredyDockedBar.OffsetRect( 1, 0 );
DockControlBar(
   &m_wndToolBar2,
   AFX_IDW_DOCKBAR_TOP,
   &wrAlredyDockedBar
);
ShowControlBar(
   &m_wndToolBar1,
   FALSE,
   FALSE
);
ShowControlBar(
   &m_wndToolBar2,
   FALSE,
   FALSE
);