How to add separator to CToolBar?

Hi,
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");
      button.cy += size.cy;
      
      m_mainToolBar.SetSizes(button,bitmap);

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

      while ( !(m_mainToolBar.GetButtonStyle(i) & TBBS_SEPARATOR) )
      {
            m_mainToolBar.SetButtonStyle(i,TBBS_CHECKGROUP);

            buttonText.LoadString(toolbarTextIds[index]);

            m_mainToolBar.SetButtonText(i,buttonText);

            index++;
            i++;
      }

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

//Ramesh - TL_C1_4_FEA_09 - XC Support of IP DCN Mgmt - Start
      m_mainToolBar.SetButtonStyle(7,TBBS_CHECKBOX);
      buttonText.LoadString(IDS_ENABLESCAN);
      m_mainToolBar.SetButtonText(7,buttonText);
//Ramesh - TL_C1_4_FEA_09 - XC Support of IP DCN Mgmt - End

      CSize tbSize;
      tbSize.cy = button.cy;
      tbSize.cx = 0;

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

      return tbSize;
static UINT toolbarTextIds[] =
{
//Ramesh - TL_C1_4_FEA_012 - Usability Enhancements - Start
    IDS_TOOLBAR_NW,          
    IDS_TOOLBAR_SWPL,
      IDS_TOOLBAR_TSK,
    IDS_TOOLBAR_ERR ,        
    IDS_TOOLBAR_LOGS,
      IDS_NODE_SOFTVIEW,
      IDS_ENABLESCAN
};
so please to add sepatrator between buttons..

srikadiAsked:
Who is Participating?
 
ZoppoConnect With a Mentor Commented:
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,

ZOPPO

0
 
srikadiAuthor Commented:
wow..its worked perfectly..
thanx..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.