Recently, I have been doing interfaces, using Toolbar, a little careful. code show as below:
IF (! m_wndtoolbar.createex (AFXGETMAINWND (), TBStyle_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC)) / / ||
// !_wndtoolbar.loadtoolbar(IDR_MAINFRAME)))
{
Trace0 ("Failed to Create Toolbar / N);
}
M_WndToolBar.SetButtons (NULL, 7);
Bitmap.LoadBitmap (IDB_PHONEBAR);
INT i = imagelist.create (16, 15, ILC_COLOR24, 13, 1);
ImageList.add (& Bitmap, (cbitmap *) null;
M_WndToolBar.sendMessage (tb_setimagelist, 0, (lparam) imagelist.m_himagelist);
M_WndToolBar.sendMessage (TB_SETDISABEDIMAGELIST, 0, (LPARAM) imagelist.m_himagelist);
Imagelist.detach ();
Bitmap.detach ();
m_wndtoolbar.setButtontext (0, "Connect");
m_wndtoolbar.setButtonText (2, "Play");
m_wndtoolbar.setButtonText (3, "Save");
m_wndtoolbar.setButtonTontext (5, "All Choice");
m_wndtoolbar.setButtonText (6, "Delete");
M_WndToolBar.setsizes (CSIZE (50, 40), CSIZE (20, 20));
m_wndtoolbar.gettoolbarctrl (). setButtonWidth (40, 50);
M_WndtoolBar.SetButtonInfo (0, ID_CONNECT, TBSTYLE_BUTTON, 0);
M_WndtoolBar.SetButtonInfo (1, 0, TBBS_SEPARATOR, 0);
M_WndToolBar.SetButTonInfo (2, ID_Video_Play, TBStyle_Button, 1);
M_WndToolBar.setButtonInfo (3, ID_Video_save, TBStyle_Button, 2);
m_wndtoolbar.setButtonInfo (4, 0, TBBS_SEPARATOR, 0);
m_wndtoolbar.setButtonInfo (5, ID_Video_SELECTALL, TBSTYLE_BUTTON, 3);
M_WndtoolBar.SetButtonInfo (6, ID_Video_Delete, TBStyle_Button, 4);
among them
m_wndtoolbar.setButtons (NULL, 7); Set the number of buttons for Toolbar (including
Separator) .m_wndtoolbar.sendMessage (tb_setimagelist, 0, (lparam) imagelist.m_himagelist);
M_WndToolBar.sendMessage (TB_SETDISABEDIMAGELIST, 0, (LPARAM) imagelist.m_himagelist);
The image list when setting up normal and invalid, and a TB_SETHOTIMAGELIST setting When the mouse is on the button, the Image List .SetButtonText Setting button text.
Setsizes Settings buttons and images, this function must be called after setButtonText, or you will not see text.
GetToolbarCtrl (). SetButtonWidth (40, 50); Setting button width must be called, otherwise the toolbar button is invalid, but the width of Button will have the width of the maximum Button text length, not the width you expected.
SetButtonInfo Sets the image of Button and NID (used to use the message to be used in ON_COMMOND)