docking toolbars problem

In my application I dock toolbars one next to the other. I have several set of toolbars for every document type.
when the user switches between views, I save in a data structure the position of all the toolbars of the de-activate document, and "load" the position of the toolbars of the activated document.

For re-docking the toolbars (when switching views), I'm using these functions :
DockControlBar (given the CRect of each toolbar).

The problem is that sometimes the docking toolbars starts a new line.

Can someone give me a hint what can cause this ?

Who is Participating?
naveenkohliConnect With a Mentor Commented:
This problem is similar to the one you asked before i.e. wrapping the toolbars. To solve this problem, you can write a utility function which docks the toolbars next to each other (if space is available).

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);

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.