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 );
}