How to set location of MFC application toolbars under VC++5.0

I want to set the location of several toobars ie

TB1............
_______________T
Document View__B
_______________2

_______________T
_______________B
_______________3

I am able to manually place (dock) the tool bars where I want them, but how do I make these positions the default?

The come up like this instead

TB1
TB2
TB3
Document View
sherwingwAsked:
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.

sherwingwAuthor Commented:
Edited text of question
0
sherwingwAuthor Commented:
Edited text of question
0
sherwingwAuthor Commented:
Edited text of question
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tommy HuiEngineerCommented:
If you look at the generated code for the toolbars. In that section, you'll see SetBarStyle(...., CBRS_SIZE_DYNAMIC);
Add either  
  | CBRS_TOP  or
  | CBRS_RIGHT to the style of the toolbar you want to position.

For example,

  .SetBarStyle(...., CBRS_SIZE_DYNAMIC | CBRS_RIGHT) to position it to the right of the view.
0
sherwingwAuthor Commented:
Causes an assertion failure:
m_wndTestToolBar.SetBarStyle(m_wndTestToolBar.GetBarStyle() |
            CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC |             CBRS_RIGHT);

Does Not cause failure but requires manual position:
m_wndTestToolBar.SetBarStyle(m_wndTestToolBar.GetBarStyle() |
            CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

0
sherwingwAuthor Commented:
Well, I'm part way there,  I can now get one toolbar at the top-left and one along the right by using:

m_wndTestToolBar1.SetBarStyle(0);
 m_wndTestToolBar1.SetBarStyle(CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_TOP);

m_wndTestToolBar2.SetBarStyle(0);
 m_wndTestToolBar2.SetBarStyle(CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_RIGHT);

But If I try to add additional toolbars along the right side, they stack beside each other instead of below the preceeding one.

I know that if I can manually dock them to the correct position, there has to be a way.

INCIDENTLY:  The GetaBarStyle() call causes CBRS_RIGHT to clash with CBRS_TOP, They are mutually exclusive acording to the .h file
0
sherwingwAuthor Commented:
Adjusted points to 250
0
sherwingwAuthor Commented:
Adjusted points to 300
0
TiutinCommented:
The MFC Documentation contains ToolBar Samples, one of them being DOCKTOOL. It demonstrates dockable toolbar support.
As the documentation says:
"...A dockable toolbar can be attached, or docked, to any side of its parent window, or it can be detached, or floated, in its own mini-frame window using CMiniFrameWnd. The following three steps are necessary to place a dockable toolbar in your application:

Enable docking for the frame window or destination using the CFrameWnd::EnableDocking function. One DWORD parameter indicates which side of the frame window accepts docking. To dock control bars anywhere, pass CBRS_ALIGN_ANY to EnableDocking.
Enable docking for the toolbar or source by calling CControlBar::EnableDocking for each toolbar.
Specify the destination sides to which the toolbar should dock. If none of the sides specified match the sides enabled for docking in the frame window, the toolbar cannot dock — it will float. Once it has been floated, it remains a floating toolbar, unable to dock to the frame window.
Dock the toolbar to the frame window by calling CFrameWnd::DockControlBar. Conversely, call CFrameWnd::FloatControlBar to detach a dockable toolbar from the frame window.
If you do not complete all three steps, your application will display a standard toolbar. The last two steps must be performed for each dockable toolbar in your application.

To retain the state of dockable toolbars (whether docked or floating) between invocations of your application, use the CControlBar::SetBarStyle and CControlBar::GetBarStyle functions to retrieve and restore the settings of any particular control bar.
Normally, this information is stored in the application's .ini file using CFrameWnd::SaveBarState and retrieved using CFrameWnd::LoadBarState...".

Below is description of CFrameWnd::DockControlBar fuction (just for notice).

void DockControlBar( CControlBar * pBar, UINT nDockBarID = 0, LPCRECT lpRect = NULL );
Parameters
pBar   Points to the control bar to be docked.
nDockBarID   Determines which sides of the frame window to consider for docking.
It can be 0, or one or more of the following:

AFX_IDW_DOCKBAR_TOP   Dock to the top side of the frame window.
AFX_IDW_DOCKBAR_BOTTOM   Dock to the bottom side of the frame window.
AFX_IDW_DOCKBAR_LEFT   Dock to the left side of the frame window.
AFX_IDW_DOCKBAR_RIGHT   Dock to the right side of the frame window.

If 0, the control bar can be docked to any side enabled for docking in the destination frame window.

lpRect   Determines, in screen coordinates, where the control bar will be docked in the nonclient area of the destination frame window.

Remarks

Causes a control bar to be docked to the frame window. The control bar will be docked to one of the sides of the frame window specified in the calls to both CControlBar::EnableDocking and CFrameWnd::EnableDocking. The side chosen is determined by nDockBarID.

See Also   CFrameWnd::FloatControlBar

May be this is an answer?
Regards.

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
sherwingwAuthor Commented:
I want to fix the location of the toolbars.
I do not want to have the user dock them I do not want to dock
them.  I do not want the user to be able to change them.  I want
them to go where I want them to go.  Can I dock them using:

void DockControlBar( CControlBar * pBar, UINT nDockBarID = 0, LPCRECT lpRect = NULL );

and then disable docking somehow?  How do I determine the correct
value for lpRect?

I want the toolbars arranged as follows.

              ToolBar1 Along the top edge, starting in the
              left corner (THIS IS EASY,Its the default Top
              position as shown in the code fragrement above)

              ToolBar2 Along the Right edge, starting at the
              top corner.  (This also easy as shown in the
              code fragment above)

NOW COMES THE TROUBLE

              ToolBar3 Butted against the lower edge of ToolBar2

AND MORE TROUBLE

              ToolBar4 Below Toolbar3 with space between them

AND FINALY    ToolBar5 Butted against the lower edge of toolBar4
              ( If we solve ToolBar3 then this will be the same)

ADDITIONAL INFO:

              ToolBar2 and Toolbar4 have a different aspect ratio
              than ToolBars 3 and 5 so they can't be made as one
              long tool bar
0
sherwingwAuthor Commented:
void DockControlBar( CControlBar * pBar,
                     UINT nDockBarID = 0,
                     LPCRECT lpRect = NULL );
works SORT OF:

The bars do not position where you would expect them to.
However, by properly ordering the dock calls for each ToolBar(bottom to top) and using 0,0 for the upper left corner of each bar, and width,height for the lower right corner of each bar I can get the bars to stack in the proper order.  I can not get them to leave space between bars.  I got around this by using yet another ToolBar as a spacer.

This is a GIGANTIC CLUDGE. and what is more, it does not provide a stable position for the ToolBars.  If the user resizes the window, too small, the ToolBars again do their own thing.

Reminder:  I realy do not want dockable bars.  I want them in a fixed position. I do not want the user to have the option of moving them.  I do not want Windows to rearage them.
0
TiutinCommented:
General MFC Samples include DOCKTOOL that demonstrates dockable toolbar support. A dockable toolbar can be attached, or docked, to any side of its parent window, or it can be detached, or floated, in its own mini-frame window using CMiniFrameWnd. The following three steps are necessary to place a dockable toolbar in your application:

(1) Enable docking for the frame window or destination using the CFrameWnd::EnableDocking function. One DWORD parameter indicates which side of the frame window accepts docking. To dock control bars anywhere, pass CBRS_ALIGN_ANY to EnableDocking.

(2) Enable docking for the toolbar or source by calling CControlBar::EnableDocking for each toolbar. Specify the destination sides to which the toolbar should dock. If none of the sides specified match the sides enabled for docking in the frame window, the toolbar cannot dock — it will float. Once it has been floated, it remains a floating toolbar, unable to dock to the frame window.

(3) Dock the toolbar to the frame window by calling CFrameWnd::DockControlBar. Conversely, call CFrameWnd::FloatControlBar to detach a dockable toolbar from the frame window.

If you do not complete all three steps, your application will display a standard toolbar. The last two steps must be performed for each dockable toolbar in your application.

To retain the state of dockable toolbars (whether docked or floating) between invocations of your application, use the CControlBar::SetBarStyle and CControlBar::GetBarStyle functions to retrieve and restore the settings of any particular control bar. Normally, this information is stored in the application's .ini file using CFrameWnd::SaveBarState and retrieved using CFrameWnd::LoadBarState.

The docking, floating, and tool tips calls are optional. You can remove those lines from OnCreate if you prefer. The result is a toolbar that remains fixed, unable to float or redock and unable to display tool tips.

If you wish I may send you the whole bunch.
Regards.
0
sherwingwAuthor Commented:
I know how to produce dockable ToolBars!  What I can not figure out is how to position FIXED ToolBars. or for that matter how to predictably position multiple Dockable ToolBars.  If you read the history of this question, you will see that I already have been using dockable bars.  The problem is I DON"T WANT DOCKABLE
BARS! I WANT FIXED BARS!  in the position I have designed.
0
sherwingwAuthor Commented:
Adjusted points to 400
0
TiutinCommented:
400 points won't go. Now it is your problem to look at DOCKTOOL example while taking into consideration the following comment:
"...  The docking, floating, and tool tips calls are optional. You can remove those lines from OnCreate if you prefer. The result is a toolbar that remains fixed, unable to float or redock and unable to display tool tips...".
I am finished.
Good luck.
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
Microsoft Development

From novice to tech pro — start learning today.