第一个工具栏:
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_FLOAT_MULTI | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndToolBar.SetWindowText(_T("标准工具栏"));
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
第二个工具栏:
if (!m_wndExtendBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_FLOAT_MULTI | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndExtendBar.LoadToolBar(IDR_EXTEND_BAR))
{
TRACE0(_T("Failed to create extend toolbar\n"));
return -1;
}
m_wndExtendBar.SetWindowText(_T("扩展工具栏"));
m_wndExtendBar.EnableDocking(CBRS_ALIGN_ANY);
CRect rect;
m_wndExtendBar.GetWindowRect(&rect);
rect.OffsetRect(1, 0);
this->RecalcLayout(); //关键的一步,重新排列
DockControlBar(&m_wndExtendBar, AFX_IDW_DOCKBAR_TOP, &rect);
本文地址:http://com.8s8s.com/it/it26081.htm