How do I add icons and text in the toolbar?

Source: Internet
Author: User
A) .How to add values and text in the toolbar? (How To Add Icon And Text)

/*************************************** *****************************/

/**/

/* Function name: CreateHotToolBar */

/* Description: Create the main toolbar .*/

/**/

/*************************************** *****************************/

BOOL CMainFrame: CreateHotToolBar ()

{

If (! M_wndToolBar.CreateEx (this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP

| CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC/* | CBRS_GRIPPER */) |

! M_wndToolBar.LoadToolBar (IDR_TOOLBAR1 ))

{

TRACE0 ("Failed to create toolbar \ n ");

Return FALSE; // fail to create

}

// Set the text for each button

CToolBarCtrl & bar = m_wndToolBar.GetToolBarCtrl ();

Int nIndex = 0;

TBBUTTON tb;

For (nIndex = m_wndToolBar.GetToolBarCtrl (). GetButtonCount ()-1; nIndex> = 0; nIndex --)

{

ZeroMemory (& tb, sizeof (TBBUTTON ));

M_wndToolBar.GetToolBarCtrl (). GetButton (nIndex, & tb );

// Do we have a separator?

If (tb. fsStyle & TBSTYLE_SEP) = TBSTYLE_SEP)

Continue;

// Have we got a valid command id?

If (tb. idCommand = 0)

Continue;

// Get the resource string if there is one.

CString strText;

LPCTSTR lpszButtonText = NULL;

CString strButtonText (_ T (""));

_ TCHAR seps [] = _ T ("\ n ");

StrText. LoadString (tb. idCommand );

If (! StrText. IsEmpty ())

{

LpszButtonText = _ tcstok (LPTSTR) (LPCTSTR) strText, seps );

While (lpszButtonText)

{

StrButtonText = lpszButtonText;

LpszButtonText = _ tcstok (NULL, seps );

}

}

If (! StrButtonText. IsEmpty ())

M_wndToolBar.SetButtonText (nIndex, strButtonText );

}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.