-
Toolbar problem
Code:
INITCOMMONCONTROLSEX InitCtrlEx;
InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCtrlEx.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&InitCtrlEx);
toolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
hwnd, (HMENU)MAIN_TOOLBAR, GetModuleHandle(NULL), NULL);
SendMessage(toolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
SendMessage(toolbar, TB_SETBITMAPSIZE, NULL, MAKELONG(20, 24));
TBBUTTON tbb[3];
TBADDBITMAP tbab;
HBITMAP hbitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_STANDARD));
tbab.hInst = NULL;
tbab.nID = (INT)hbitmap;
SendMessage(toolbar, TB_ADDBITMAP, 0, (LPARAM)&tbab);
ZeroMemory(tbb, sizeof(tbb));
tbb[0].iBitmap = 0;
tbb[0].fsState = TBSTATE_ENABLED;
tbb[0].fsStyle = TBSTYLE_BUTTON;
tbb[0].idCommand = ID_NEW;
tbb[1].iBitmap = MAKELONG(1,0);
tbb[1].fsState = TBSTATE_ENABLED;
tbb[1].fsStyle = TBSTYLE_BUTTON;
tbb[1].idCommand = ID_FILE_OPEN;
tbb[2].iBitmap = 2;
tbb[2].fsState = TBSTATE_ENABLED;
tbb[2].fsStyle = TBSTYLE_BUTTON;
tbb[2].idCommand = ID_FILE_SAVEAS;
SendMessage(toolbar, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);
BTW everything has been defined either higher up in the function or as a global variable so that is not a problem
hbitmap is a handle to an image that is 60x24 pixels and it contains the images for the 3 buttons.
I have that code, it pretty much works just fine except that the 2nd and 3rd images dont show. Why won't they show up?
What am i doing wrong?
Also, I dont want to use CreateToolbarEx to creat the tool bar.
-
Set the wParam to the number of button images when you send the TB_ADDBITMAP message.
-
Perfect!
Thank you
I dont know how i've missed that...