Solved

Dock ToolBar.

Posted on 2004-04-30
4
652 Views
Last Modified: 2013-11-20
How do I dock 2 toolbars and align them horizontally. I tried it but one of the tool bar is always shifted down to the second line.

Thanks.
0
Comment
Question by:pcssecure
  • 3
4 Comments
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 500 total points
ID: 10958627
Use this function..

void CMainFrame::DockControlBarLeftOf(CToolBar* Bar,CToolBar* LeftOf)
{
      CRect rect;
      DWORD dw;
      UINT n;

      // get MFC to adjust the dimensions of all docked ToolBars
      // so that GetWindowRect will be accurate
      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;

      // When we take the default parameters on rect, DockControlBar will dock
      // each Toolbar on a seperate line.  By calculating a rectangle, we in effect
      // are simulating a Toolbar being dragged to that location and docked.
      DockControlBar(Bar,n,&rect);
}



And call this function from "CMainFrame::OnCreate", like this
DockControlBarLeftOf(&m_firstToolBar,&m_secondToolBar);

Good Luck
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 10984938
Hope your problem has solved..
:)
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 10995317
Is this code working?

Waiting for your reply
Rosh :)
0
 

Author Comment

by:pcssecure
ID: 11001414
Yes it works.
Thanks a lot. Sorry I forgot about this.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now