Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Toolbar with two colums

Toolbar with two colums

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
14 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sharp_k
    wrote on last edited by
    #1

    Can anyone help me with building a toolbar with two vertical columns? Mark

    N M A 3 Replies Last reply
    0
    • S sharp_k

      Can anyone help me with building a toolbar with two vertical columns? Mark

      N Offline
      N Offline
      Nathan Holt at EMOM
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • S sharp_k

        Can anyone help me with building a toolbar with two vertical columns? Mark

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        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:

        S 1 Reply Last reply
        0
        • M Mark Salsbery

          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:

          S Offline
          S Offline
          sharp_k
          wrote on last edited by
          #4

          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

          M 1 Reply Last reply
          0
          • N Nathan Holt at EMOM

            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

            S Offline
            S Offline
            sharp_k
            wrote on last edited by
            #5

            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.

            N 1 Reply Last reply
            0
            • S sharp_k

              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.

              N Offline
              N Offline
              Nathan Holt at EMOM
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • S sharp_k

                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

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                Make sure the toolbar control has the TBSTYLE_WRAPABLE style. Mark

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                S 1 Reply Last reply
                0
                • S sharp_k

                  Can anyone help me with building a toolbar with two vertical columns? Mark

                  A Offline
                  A Offline
                  Anurag Gandhi
                  wrote on last edited by
                  #8

                  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.

                  S 1 Reply Last reply
                  0
                  • M Mark Salsbery

                    Make sure the toolbar control has the TBSTYLE_WRAPABLE style. Mark

                    Mark Salsbery Microsoft MVP - Visual C++ :java:

                    S Offline
                    S Offline
                    sharp_k
                    wrote on last edited by
                    #9

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

                    M 1 Reply Last reply
                    0
                    • A Anurag Gandhi

                      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.

                      S Offline
                      S Offline
                      sharp_k
                      wrote on last edited by
                      #10

                      may be yes but i am looking for a photoshop type of application where you see a vertical toolblar on the left side. Same as MS Paint type toolbar. Thanks.

                      1 Reply Last reply
                      0
                      • S sharp_k

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

                        M Offline
                        M Offline
                        Mark Salsbery
                        wrote on last edited by
                        #11

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

                        Mark Salsbery Microsoft MVP - Visual C++ :java:

                        S 1 Reply Last reply
                        0
                        • M Mark Salsbery

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

                          Mark Salsbery Microsoft MVP - Visual C++ :java:

                          S Offline
                          S Offline
                          sharp_k
                          wrote on last edited by
                          #12

                          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

                          M 1 Reply Last reply
                          0
                          • S sharp_k

                            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

                            M Offline
                            M Offline
                            Mark Salsbery
                            wrote on last edited by
                            #13

                            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:

                            S 1 Reply Last reply
                            0
                            • M Mark Salsbery

                              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:

                              S Offline
                              S Offline
                              sharp_k
                              wrote on last edited by
                              #14

                              I will try this code. I did try using the width function of the toolbar but that increased the width but did not wrap the buttions. I will use this approach now. I will update you how did it go.

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups