You can use the bitmap for the WHOLE Toolbar, that is possible
(if you want to change the bitmap of one single button you need to change the whole bitmap as well):
- Make a 256 color bitmap that has all your icons lined (touching) up in a row
using your favourite paint program. I suggest calling the file TOOLBAR.BMP.
- Import the bitmap as a resource. Call it IDB_TOOLBAR.
- Add this to your dialog class's header:
CBitmap m_bitmapToolbar;
CToolBar m_Toolbar;
void CreateToolbar();
- Add a the following function to your dialog class:
static int iToolbarIconWidth = 32;
static int iToolbarIconHeight = 32;
void CMyDialog::CreateToolbar()
{
const UINT ids[] = { IDC_YOUR_ACTION1, IDC_YOUR_ACTION2, IDC_YOUR_ACTION3 };
m_Toolbar.CreateEx(this, TBSTYLE_FLAT | TBSTYLE_TOOLTIPS);
m_bitmapToolbar.LoadBitmap(IDB_TOOLBAR);
m_Toolbar.SetBitmap((HBITMAP)m_bitmapToolbar);
m_Toolbar.SetButtons((const UINT *)&ids, sizeof(ids) / sizeof(ids[0]));
m_Toolbar.ShowWindow(SW_SHOW);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
m_Toolbar.SetSizes(CSize(iToolbarIconWidth+7, iToolbarIconHeight+6), CSize(iToolbarIconWidth, iToolbarIconHeight));
m_Toolbar.SetHeight(0);
}
- Call it from your dialog class's InitDialog()