Toolbar with two colums
-
Mark_VC wrote:
Can anyone help me with building a toolbar with two vertical columns?
Depending on what you need, I can think of a couple ways. One is to just use two toolbars. Another option is to use a "dialog bar" and make the dialog template provide two vertical columns of buttons. Nathan
-
A toolbar will wrap the buttons if you set its size appropriately. A problem, unless there's enough buttons, is that when you resize it to the right size, it may not fill an entire side of a window. To get around this, I personally embed the toolbar in a control bar - the control bar always stays the height of the window and the width of two columns of buttons. The embedded toolbar is sized appropriately to get the two columns. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
A toolbar will wrap the buttons if you set its size appropriately. A problem, unless there's enough buttons, is that when you resize it to the right size, it may not fill an entire side of a window. To get around this, I personally embed the toolbar in a control bar - the control bar always stays the height of the window and the width of two columns of buttons. The embedded toolbar is sized appropriately to get the two columns. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Mark_VC wrote:
Can anyone help me with building a toolbar with two vertical columns?
Depending on what you need, I can think of a couple ways. One is to just use two toolbars. Another option is to use a "dialog bar" and make the dialog template provide two vertical columns of buttons. Nathan
-
I would really like toolbar by itself so that the program looks professional. I may use calcFixedlayout. If you have a neat way how to do it, please do help. thanks.
Mark_VC wrote:
I would really like toolbar by itself so that the program looks professional. I may use calcFixedlayout. If you have a neat way how to do it, please do help. thanks.
I'm afraid I don't understand what your saying. How would a dialog bar look nonprofesional? Nathan
-
how can i resize it so that the buttons inside it wrap itself. As far as I know, it always aligns button in a single column in vertical toolbar. I tried resizing it, it still shows the buttons in single column. Help please. Mark
Make sure the toolbar control has the TBSTYLE_WRAPABLE style. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Use Separator at the place from where you need to wrap. I think this will help you.
Anurag Gandhi. http://www.softgandhi.co.nr Life is a computer program and every one is the programmer of his own life.
-
Make sure the toolbar control has the TBSTYLE_WRAPABLE style. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
I tried TBSTYLE_WRAPABLE. It probably works only when the toolbar is floating. When the toolbar is docked, it aligns itself in single column again. I know i have to use calcDynamicLayout and CalcFixedLayout. I do not know who to override them and what code to put in it. Thanks every one for help though :)
-
Use Separator at the place from where you need to wrap. I think this will help you.
Anurag Gandhi. http://www.softgandhi.co.nr Life is a computer program and every one is the programmer of his own life.
-
I tried TBSTYLE_WRAPABLE. It probably works only when the toolbar is floating. When the toolbar is docked, it aligns itself in single column again. I know i have to use calcDynamicLayout and CalcFixedLayout. I do not know who to override them and what code to put in it. Thanks every one for help though :)
It doesn't have to be floating. You didn't mention MFC before, but now that you've mentioned it - Override CalcFixedLayout()... If you return the proper size for the bar it will work. The width should be the size of two buttons (for two columns). The height should be the height of the client area of the parent. For CalcDynamicLayout() I often just route the call to CalcFixedLayout() unless I need different functionality there - something like:
CSize CMyControlBar::CalcDynamicLayout(int nLength, DWORD dwMode) { return CalcFixedLayout(dwMode & LM_STRETCH, dwMode & LM_HORZ); }
MarkMark Salsbery Microsoft MVP - Visual C++ :java:
-
It doesn't have to be floating. You didn't mention MFC before, but now that you've mentioned it - Override CalcFixedLayout()... If you return the proper size for the bar it will work. The width should be the size of two buttons (for two columns). The height should be the height of the client area of the parent. For CalcDynamicLayout() I often just route the call to CalcFixedLayout() unless I need different functionality there - something like:
CSize CMyControlBar::CalcDynamicLayout(int nLength, DWORD dwMode) { return CalcFixedLayout(dwMode & LM_STRETCH, dwMode & LM_HORZ); }
MarkMark Salsbery Microsoft MVP - Visual C++ :java:
What to put in CalcFixedLayout override. I though i have to set flag for each toolbar buttion in the CalcFixedLaout function(weather the buttion is to be wrapped or not). What would that code be? Or I should simply use TBSTYLE_WRAPABLE style for Toolbar without any code in CalcFixedLayout and it should work? Thanks again. Mark
-
What to put in CalcFixedLayout override. I though i have to set flag for each toolbar buttion in the CalcFixedLaout function(weather the buttion is to be wrapped or not). What would that code be? Or I should simply use TBSTYLE_WRAPABLE style for Toolbar without any code in CalcFixedLayout and it should work? Thanks again. Mark
Mark_VC wrote:
What to put in CalcFixedLayout override.
All you need is to return the size you want. For vertical, two columns, something like this maybe...
CRect CliRect;
GetParent()->GetClientRect(&CliRect);CRect ButtonRect;
GetToolBarCtrl().GetItemRect(0, &ButtonRect);return CSize(ButtonRect.Width() * 2, CliRect.Height());
The wrapable style only needs to be set on the toolbar itself. You also don't need separators although they can be used to aid wrapping in some instances. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Mark_VC wrote:
What to put in CalcFixedLayout override.
All you need is to return the size you want. For vertical, two columns, something like this maybe...
CRect CliRect;
GetParent()->GetClientRect(&CliRect);CRect ButtonRect;
GetToolBarCtrl().GetItemRect(0, &ButtonRect);return CSize(ButtonRect.Width() * 2, CliRect.Height());
The wrapable style only needs to be set on the toolbar itself. You also don't need separators although they can be used to aid wrapping in some instances. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: