How to add separator to CToolBar?

Posted on 2008-11-06
Last Modified: 2013-11-20
i added some button in CtoolBar after separator.but it s not showing names for the buttons.
now i have separator before IDS_ENABLESCAN id which isTBBS_CHECKGROUP.but i was adding simple buttons after sepearator.with out separator its working fine..
      CDC* dc = m_mainToolBar.GetDC();
      CSize size;
      size = dc->GetTextExtent("Test"); +=;

      //setting the buttons to be radio style
      int i =0;

      while ( !(m_mainToolBar.GetButtonStyle(i) & TBBS_SEPARATOR) )




      //the following buttons is used to start/pause the network scanning

//Ramesh - TL_C1_4_FEA_09 - XC Support of IP DCN Mgmt - Start
//Ramesh - TL_C1_4_FEA_09 - XC Support of IP DCN Mgmt - End

      CSize tbSize; =; = 0;

      CRect butRect;
      for (i=0;i<m_mainToolBar.GetCount();i++)
            m_mainToolBar.GetItemRect(i, butRect);
   += butRect.Width();

      return tbSize;
static UINT toolbarTextIds[] =
//Ramesh - TL_C1_4_FEA_012 - Usability Enhancements - Start
    IDS_TOOLBAR_ERR ,        
so please to add sepatrator between buttons..

Question by:srikadi
    LVL 30

    Accepted Solution

    Hi srikadi,

    IMO the problem is the loop:
    > while ( !(m_mainToolBar.GetButtonStyle(i) & TBBS_SEPARATOR) )

    This will run until the first seperator-button is found, then it stops. I guess it should be something like this:

    > for (i=0;i<m_mainToolBar.GetCount();i++)
    > {
    >   if( 0 != (m_mainToolBar.GetButtonStyle(i) & TBBS_SEPARATOR) )
    >   {
    >     // don't add text for seperator
    >     continue;
    >   }
    >   m_mainToolBar.SetButtonStyle(i,TBBS_CHECKGROUP);
    >   buttonText.LoadString(toolbarTextIds[index]);
    >   m_mainToolBar.SetButtonText(i,buttonText);
    >   index++;
    > }

    Hope that helps,



    Author Comment

    wow..its worked perfectly..

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    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.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    760 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

    7 Experts available now in Live!

    Get 1:1 Help Now