DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Zack Moore Guest

    TBSTYLE_CHECKGROUP


    I feel like this is a really novice question, but it has been driving me up
    the wall and I can't find an example or any fleshed out documentation.

    I'm writing an app. that has to dynamicly create buttons on a toolbar that
    is contained in a CFormView. I'm using CToolBar::AddButtons().

    My problem is that some of the buttons are supposed to be in "groups" (you
    click one button, it stayes pressed all the others unpress). I've tried
    all sorts of combinations with TBSTYLE_CHECKGROUP but I can't get it to work
    properly. Mostly the buttons act kind of like single check buttons, but
    won't uncheck. Mostly they just don't work right.

    Here is a code snipet. If someone has an idea what I'm doing wrong, please
    let me know. This is driving me nuts.

    nSize=m_asGroups.GetSize();
    pGroupButtons=new TBBUTTON[nSize+2];

    for(nCount=0;nCount<nSize;nCount++)
    {
    pGroupButtons[nCount].iString=0;
    pGroupButtons[nCount].iBitmap=nCount+1
    pGroupButtons[nCount].dwData=nCount;
    pGroupButtons[nCount].fsState=TBSTATE_ENABLED;
    pGroupButtons[nCount].fsStyle=TBSTYLE_CHECKGROUP;
    // all dynamic group btns route to the same command handler
    // which btn was clicked is determined by calling GetMessagePos
    // and HitTest()
    pGroupButtons[nCount].idCommand=ID_TOOLBAR_GROUP_DYNBTNS;
    }
    pGroupButtons[nSize].iString=0; //nSize+nIndex;
    pGroupButtons[nSize].iBitmap=nSize+1;
    pGroupButtons[nSize].dwData=nSize;
    pGroupButtons[nSize].fsState=TBSTATE_ENABLED;
    pGroupButtons[nSize].fsStyle=TBSTYLE_SEP;
    pGroupButtons[nSize].idCommand=ID_TOOLBAR_GROUP_DYNBTNS;



  2. #2
    Zack Moore Guest

    Re: TBSTYLE_CHECKGROUP


    minor correction.

    I'm using CToolBarCtrl::AddButtons() not CToolBar::AddButtons()

    and the call at the end of the code snippet should be

    refToolBarCtrl.AddButtons(nSize+1,pGroupButtons);





  3. #3
    Zack Moore Guest

    Re: TBSTYLE_CHECKGROUP


    Solved my own problem. If the buttons don't all have unique command Ids, then
    the grouping doesn't work right.

    "Zack Moore" <ormico@netscape.net> wrote:
    >
    >minor correction.
    >
    >I'm using CToolBarCtrl::AddButtons() not CToolBar::AddButtons()
    >
    >and the call at the end of the code snippet should be
    >
    >refToolBarCtrl.AddButtons(nSize+1,pGroupButtons);
    >
    >
    >
    >



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links