When creating a toolbar manually...
Hello, I tried in my program to create a toolbar manually (I have a
class that derives from CToolBar) instead of modifying what the app
wizard generates for me. Everything works, except for one small thing:
The string associated with each button is only displayed in the status
bar while the button is being pressed, not when hovering above it. Can
that be fixed easily somehow? This was just an experiment and it's a bit
annoying that I could get everything working except when the button
string is displayed in status bar.
Here's how its created:
void
MyToolBar::Create(CWnd *parent)
{
VERIFY(CreateEx(parent, WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT |
CBRS_FLYBY));
bitmap1 = load_button_image(IDB_BITMAP1);
bitmap2 = load_button_image(IDB_BITMAP2);
bitmap3 = load_button_image(IDB_BITMAP3);
bitmap4 = load_button_image(IDB_BITMAP4);
VERIFY(imagelist.Create(16, 15, ILC_COLOR24, 4, 1));
VERIFY(imagelist.Add(bitmap1, (CBitmap *)NULL) == 0);
VERIFY(imagelist.Add(bitmap2, (CBitmap *)NULL) == 1);
VERIFY(imagelist.Add(bitmap3, (CBitmap *)NULL) == 2);
VERIFY(imagelist.Add(bitmap4, (CBitmap *)NULL) == 3);
GetToolBarCtrl().SetImageList(&imagelist);
const UINT button_ids[] = { ID_BUTTON_1, ID_BUTTON_2, ID_BUTTON_3,
ID_SEPARATOR, ID_BUTTON_4 };
VERIFY(SetButtons(button_ids, sizeof(button_ids) /
sizeof(button_ids[0])));
}
- Eric