-
Toolbar color
In an application im creating my toolbar is white for some reason, I copied and pasted to code from another application, and there the color was beige? (the usual color that a toolbar should be).
What caused my toolbar to change color? Also how can I change the toolbar's color to any color I want?
here is my code for creating the toolbar:
Code:
toolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT,
0, 0, 0, 0, hwnd, (HMENU)MAIN_TOOLBAR, HInstance, NULL);
SendMessage(toolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
SendMessage(toolbar, TB_SETBITMAPSIZE, NULL, MAKELONG(20, 24));
TBBUTTON tbb[6];
TBADDBITMAP tbab;
HBITMAP hbitmap = LoadBitmap(HInstance, MAKEINTRESOURCE(IDB_STANDARD));
tbab.hInst = NULL;
tbab.nID = (UINT_PTR)hbitmap;
SendMessage(toolbar, TB_ADDBITMAP, 6, (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 = 1;
tbb[1].fsState = TBSTATE_ENABLED;
tbb[1].fsStyle = TBSTYLE_BUTTON;
tbb[1].idCommand = ID_OPEN;
tbb[2].iBitmap = 2;
tbb[2].fsState = TBSTATE_ENABLED;
tbb[2].fsStyle = TBSTYLE_BUTTON;
tbb[2].idCommand = ID_SAVEAS;
tbb[3].iBitmap = 3;
tbb[3].fsState = TBSTATE_ENABLED;
tbb[3].fsStyle = TBSTYLE_BUTTON;
tbb[3].idCommand = ID_ALIGN_LEFT;
tbb[4].iBitmap = 4;
tbb[4].fsState = TBSTATE_ENABLED;
tbb[4].fsStyle = TBSTYLE_BUTTON;
tbb[4].idCommand = ID_ALIGN_CENTER;
tbb[5].iBitmap = 5;
tbb[5].fsState = TBSTATE_ENABLED;
tbb[5].fsStyle = TBSTYLE_BUTTON;
tbb[5].idCommand = ID_ALIGN_RIGHT;
SendMessage(toolbar, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);
-
Toolbars with the TBSTYLE_FLAT style are essentially transparent so will possess the same 'background' colour as whatever is underneath. So, if the parent of the toolbar, or some other window immediately below the toolbar, is white, you'll need to change the background colour beneath the toolbar to whatever colour you want (if you want default behaviour then use GetSysColor(COLOR_BTNFACE) for that colour). Alternatively, just lose the TBSTYLE_FLAT toolbar style.
-
Works perfectly,
Thank you.