Solved

multi row CToolBarCtrl

Posted on 2001-09-06
2
1,063 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
Comment Utility
    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
Comment Utility
Thanks,

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
DCOM problem accessing from Linux an OPC server running on Windows machine 4 111
has22 challenge 11 70
haveThree challenge 22 100
pre4 challenge 19 87
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 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

12 Experts available now in Live!

Get 1:1 Help Now