创建四个工具栏 //第一个工具栏 if (!m_wndToolBarOne.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBarOne.LoadToolBar(IDR_TOOLBAR_ONE))
{
TRACE0("Failed to Create ToolBarOne\n");
return -1;      // fail to create
}
//第二个工具栏
if (!m_wndToolBarTwo.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBarTwo.LoadToolBar(IDR_TOOLBAR_TWO))
{
TRACE0("Failed to Create ToolBarTwo\n");
return -1;      // fail to create
}
//第三个工具栏
if (!m_wndToolBarThree.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBarThree.LoadToolBar(IDR_TOOLBAR_THREE))
{
TRACE0("Failed to Create ToolBarThree\n");
return -1;      // fail to create
}
//LOGO工具栏
if (!m_wndToolBarFour.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBarFour.LoadToolBar(IDR_LOGO_TOOLBAR))
{
TRACE0("Failed to Create ToolBarFour\n");
return -1;      // fail to create
}
m_wndToolBarOne.LoadTrueColorToolBar( 24, IDB_TOOLBAR_ONE, IDB_TOOLBAR_ONE, IDB_TOOLBAR_ONE);
m_wndToolBarTwo.LoadTrueColorToolBar( 24, IDB_TOOLBAR_TWO, IDB_TOOLBAR_TWO, IDB_TOOLBAR_TWO_DISABLE);
m_wndToolBarThree.LoadTrueColorToolBar( 24, IDB_TOOLBAR_ONE, IDB_TOOLBAR_ONE, IDB_TOOLBAR_ONE);
m_wndToolBarFour.LoadTrueColorToolBar( 24, IDB_TOOLBAR_TWO, IDB_TOOLBAR_TWO, IDB_TOOLBAR_TWO_DISABLE);
停靠
//docking the first toolbar
    m_wndToolBarOne.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndToolBarOne); //docking the second toolbar
m_wndToolBarTwo.EnableDocking(CBRS_ALIGN_ANY);
CRect rectone;
EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarOne.GetWindowRect( &rectone );
rectone.OffsetRect(1, 0);
TRACE("rectone left%d, right%d top%d ,bott%d\n",rectone.left,rectone.right,rectone.top,rectone.bottom);
RecalcLayout(TRUE);//重排
DockControlBar(&m_wndToolBarTwo, AFX_IDW_DOCKBAR_TOP, &rectone);
//docking the third toolbar
m_wndToolBarThree.EnableDocking(CBRS_ALIGN_ANY);
CRect recttwo;
m_wndToolBarTwo.GetWindowRect( &recttwo );
recttwo.OffsetRect(1,0);
TRACE("recttwo left%d, right%d top%d ,bott%d\n",recttwo.left,recttwo.right,recttwo.top,recttwo.bottom);
RecalcLayout(TRUE);
DockControlBar(&m_wndToolBarThree, AFX_IDW_DOCKBAR_TOP, &recttwo);
//docking the fourth toolbar
m_wndToolBarFour.EnableDocking(CBRS_ALIGN_ANY);
CRect rectthree;
    EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarThree.GetWindowRect( &rectthree );
RecalcLayout(TRUE); 
rectthree.OffsetRect(2000, 0);
TRACE("rectthree left%d, right%d top%d ,bott%d\n",rectthree.left,rectthree.right,rectthree.top,rectthree.bottom);
    DockControlBar(&m_wndToolBarFour, AFX_IDW_DOCKBAR_TOP, &rectthree);
onsizevoid CUPEMSMDIFrame::OnSize(UINT nType, int cx, int cy)
{
__super::OnSize(nType, cx, cy); //docking the first toolbar
m_wndToolBarOne.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBarOne); //docking the second toolbar
m_wndToolBarTwo.EnableDocking(CBRS_ALIGN_ANY);
CRect rect;
EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarOne.GetWindowRect( &rect );
rect.OffsetRect(1, 0);
TRACE("1rect left%d, right%d top%d ,bott%d\n",rect.left,rect.right,rect.top,rect.bottom);

RecalcLayout(TRUE);//重排
DockControlBar(&m_wndToolBarTwo, AFX_IDW_DOCKBAR_TOP, &rect);
//docking the third toolbar
m_wndToolBarThree.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarTwo.GetWindowRect( &rect );
rect.OffsetRect(1,0);
TRACE("2rect left%d, right%d top%d ,bott%d\n",rect.left,rect.right,rect.top,rect.bottom);
RecalcLayout(TRUE);
DockControlBar(&m_wndToolBarThree, AFX_IDW_DOCKBAR_TOP, &rect);
//docking the fourth toolbar
m_wndToolBarFour.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarThree.GetWindowRect( &rect );
RecalcLayout(TRUE); 
rect.OffsetRect(2000, 0);
DockControlBar(&m_wndToolBarFour, AFX_IDW_DOCKBAR_TOP, &rect); TRACE("3rect left%d, right%d top%d ,bott%d\n",rect.left,rect.right,rect.top,rect.bottom);
}