Docking Toolbars and CControlBar, Side-By-Side, EnableDocking

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:
Docking Toolbars and CControlBar, Side-By-Side, EnableDocking - 蓝色火焰 - 水木博客
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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值