Solved

multi row CToolBarCtrl

Posted on 2001-09-06
2
1,080 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 60
Turn a spreadsheet into a vba executable. 2 85
matchUp  challenge 6 60
has77  challenge 9 83
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

776 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