关闭

一个工具条停放在另一个工具条的右边

283人阅读 评论(0) 收藏 举报

step1:

             在CMainFream头文件(.h)中加:

            CTrueColorToolBar m_wndToolBar;
            CTrueColorToolBar m_meauserToolBar;

            void DockControlBarLeftOffset(CToolBar* right,CToolBar* left);

step2:

            在CMainFream源文件(.cpp)中加:

            if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | /*WS_VISIBLE | */CBRS_TOP
                  | 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
          }

           if (!m_meauserToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD/* | WS_VISIBLE */| CBRS_TOP | CBRS_ALIGN_TOP
                   | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
                   !m_meauserToolBar.LoadToolBar(IDR_TOOLBAR_MEASURE))
          {
                   TRACE0("Failed to create toolbar\n");
                   return -1;      // fail to create
          }

          m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
          EnableDocking(CBRS_ALIGN_ANY);
          DockControlBar(&m_wndToolBar);

          m_meauserToolBar.EnableDocking(CBRS_ALIGN_ANY);
          DockControlBarLeftOffset(&m_meauserToolBar,&m_wndToolBar);

 

step3:

          在CMainFream源文件(.cpp)中加:

          void CMainFrame::DockControlBarLeftOffset(CToolBar* right,CToolBar* left)

          {
                   CRect rect;
                   DWORD dw;
                   UINT n;
                   RecalcLayout();
                   left->GetWindowRect(&rect);
                   rect.OffsetRect(1,0);
                   dw = left->GetBarStyle();
                   n = 0;
                   n = (dw & CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : n;
                   n = (dw & CBRS_ALIGN_BOTTOM) ? AFX_IDW_DOCKBAR_BOTTOM : n;
                   n = (dw & CBRS_ALIGN_LEFT) ? AFX_IDW_DOCKBAR_LEFT : n;
                   n = (dw & CBRS_ALIGN_RIGHT) ? AFX_IDW_DOCKBAR_RIGHT : n;
                   DockControlBar(right,n,&rect);
           }

step4:

           run

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:109384次
    • 积分:1560
    • 等级:
    • 排名:千里之外
    • 原创:37篇
    • 转载:35篇
    • 译文:0篇
    • 评论:15条
    文章分类
    最新评论