There are many articles about docking toolbars, however, I felt that this was important enough to mention here. The same information can be found at Microsofts MSDN site, here it is in a nutshell: Add the following method to your CMainFrame class:
void CMainFrame::DockControlBarBottomOf(CControlBar* Bar,CControlBar* BottomOf)
{
CRect rect;
DWORD dw;
UINT n;
RecalcLayout();
BottomOf->GetWindowRect(&rect);
rect.OffsetRect(0,1);
dw=BottomOf->GetBarStyle();
n = 0;
n = (dw&CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : n;
n = (dw&CBRS_ALIGN_BOTTOM && n==0) ? AFX_IDW_DOCKBAR_BOTTOM : n;
n = (dw&CBRS_ALIGN_LEFT && n==0) ? AFX_IDW_DOCKBAR_LEFT : n;
n = (dw&CBRS_ALIGN_RIGHT && n==0) ? AFX_IDW_DOCKBAR_RIGHT : n;
DockControlBar(Bar,n,&rect);
}
void CMainFrame::DockControlBarLeftOf(CControlBar* Bar,CControlBar* LeftOf)
{
CRect rect;
DWORD dw;
UINT n;
RecalcLayout();
LeftOf->GetWindowRect(&rect);
rect.OffsetRect(1,0);
dw=LeftOf->GetBarStyle();
n = 0;
n = (dw&CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : n;
n = (dw&CBRS_ALIGN_BOTTOM && n==0) ? AFX_IDW_DOCKBAR_BOTTOM : n;
n = (dw&CBRS_ALIGN_LEFT && n==0) ? AFX_IDW_DOCKBAR_LEFT : n;
n = (dw&CBRS_ALIGN_RIGHT && n==0) ? AFX_IDW_DOCKBAR_RIGHT : n;
DockControlBar(Bar,n,&rect);
}
Now, in your CMainFrame::OnCreate, instead of using DockControlBar, use DockControlBarLeftOf:
This will dock m_wndToolBar2 left of m_wndToolBar1.