Solved

multi row CToolBarCtrl

Posted on 2001-09-06
2
1,073 Views
Last Modified: 2013-11-20
I wanted to create a square block of buttons and thought
that CToolBarCtrl would be a good start, but I could not get SetRows to work. Eventually I found that creating the control with the CCS_NORESIZE is necessary, and that contary to the documentation TBSTYLE_WRAPABLE has no effect.

BOOL CDlg::OnInitDialog()
{
  TBBUTTON  v[] = {
    {0, 1000, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, NULL},  
    {0, 1001, TBSTATE_ENABLED, TBSTYLE_BUTTON,  0, NULL},
    {0, 1002, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, NULL},  
    {0, 1003, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, NULL}
    };

  CDialog::OnInitDialog();

  CToolBarCtrl* pctrl = new CToolBarCtrl;
  CRect rect(20,30,60,70);
  //This works
  //pctrl->Create(WS_CHILD|WS_VISIBLE|CCS_NOPARENTALIGN|CCS_NODIVIDER|CCS_NORESIZE, rect, this, 100);
  //This doesn't
  pctrl->Create(WS_CHILD|WS_VISIBLE|CCS_NOPARENTALIGN|CCS_NODIVIDER|TBSTYLE_WRAPABLE, rect, this, 100);
  pctrl->AddButtons(4, v);
  pctrl->SetRows(2, true, &rect);

     return TRUE;
  }

Can someone explain what is going on, or point me at documentation which would have saved me hours of grief?
Cheers Greg
0
Comment
Question by:GGRUNDY
2 Comments
 
LVL 2

Accepted Solution

by:
BogdyPtr earned 100 total points
ID: 6460786
    CToolBarCtrl* pctrl = new CToolBarCtrl;
     CRect rect(20,30,70,80);
     //This works
     //     pctrl->Create(WS_CHILD|WS_VISIBLE|CCS_NOPARENTALIGN|CCS_NODIVIDER|CCS_NORESIZE, rect, this, 100);
     //This too, toolbar style TBSTYLE_WRAPABLE works only with CCS_NORESIZE else the toolbar is autoresized to so buttons can fit
     pctrl->Create(WS_CHILD|WS_VISIBLE|CCS_NOPARENTALIGN|CCS_NODIVIDER|CCS_NORESIZE|TBSTYLE_WRAPABLE, rect, this, 100);
     pctrl->AddButtons(5,v);
     //you don't need to set rows anymore    
0
 
LVL 3

Author Comment

by:GGRUNDY
ID: 6460885
Thanks,

>TBSTYLE_WRAPABLE works only with CCS_NORESIZE
Have you found this documented anywhere?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

895 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

18 Experts available now in Live!

Get 1:1 Help Now