How to make two toolbars dock in a row

Please have a look at this code and tell me how to make the two toolbars appear one after the other instead of one below the other. The two toolbars are m_wndToolBar and m_sortToolbar :-

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_sortToolbar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||!m_sortToolbar.LoadToolBar(IDR_SORT_TOOLBAR))
      {
            TRACE0("Failed to create sort toolbar\n");
            return -1;      // fail to create
      }


      m_wndToolBar.EnableDocking(CBRS_ALIGN_TOP);
      m_sortToolbar.EnableDocking(CBRS_ALIGN_TOP);
      EnableDocking(CBRS_ALIGN_TOP);

      DockControlBar(&m_wndToolBar);
      DockControlBar(&m_sortToolbar);

***********************************************************
rupak_khuranaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

naveenkohliCommented:
Here is the sample code for doing that. You calculate the rectangle of docking frame. Offset the rectangle by 1 unit. And then in call to DockCintrolBAr specify the side to which you want to dock the new bar with respect to existing one.

You can make use of this code and write a helper function to do this job.

********************************

CRect rect;
CToolBar *pExistingToolBar, *pNewToolBar;

CFrameWnd *pFrame = pExistingToolBar->GetDockingFRame ();

pFrame->ReCalcLayout ();

pExistingToolBar->GetWindowRect (&rect);

rect.Offset (1,1);

pFrame->DockControlBar (pNewToolBar, nToolBarID, &rect);



0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rupak_khuranaAuthor Commented:
Thanks Naveen.. It really worked.... !!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.