I made custom buttons for my toolbar, but I dont know how to make the background of the buttons transparent. Like what color does the background need to be so the background is transparent?
Printable View
I made custom buttons for my toolbar, but I dont know how to make the background of the buttons transparent. Like what color does the background need to be so the background is transparent?
I don't know if it would work, but you could try making the toolbar a layered window.
How do toolbars like the google toolbar make their buttons then? Like I can make the buttons a certain background color and it would work, but if I change my style from like the default XP style to another style, its not transparent anymore, but thats not the case with the google toolbar.
Your using the default XP style's background color, and changing the style/theme changes it, your program needs to get the bgcolor from the system.
If I do get the background color from the system (which I'm not sure how to do, but I could google it), how would I change the background color of the bitmap to the color from the system?
Thanks for your help so far.
Hmm...
Have you tried making the background of your custom toolbar image an RGB of 192,192,192?
I seems to work on my win2kpro OS, no matter what the desktop style/theme is. (This is without making the window layered.)
I just tried that, but that didnt work.
Just before you paint backgrnd, use GetSysColor( COLOR_3DFACE ); to get the color.
likewise there many COLOR_XXXXXXXXXXX values you can substitute.
Hope this helps.
I think every time the visual style changes, you get a 'WM_' message. not sur which one.
What would I do with this color? Its not like I can change the background color of the bitmap to this color from within the program. I didnt think this was that complicated because almost every program has transparent toolbar buttons.
Does your toolbar have the TBSTYLE_FLAT window style bit set?
Owner draw them?
>> I just tried that, but that didnt work.
Are you saving your custom toolbar image as a 16bit bitmap?
I have TBSTYLE_FLAT style set so that the separator line thing is visible. I'm assuming owner-drawn is within the application. Everything is owner-drawn except I use a resource file to load the .bmp file (or whatever the proper vocabulary is). I used 32-bit to save my bitmap because I thought that was the best option. The default was 24-bit, but the toolbar buttons were black squares, so I changed it to 32-bit. Trying 16-bit with RGB(192,192,192) as background had the same result as 24-bit, where all the toolbar buttons are black squares.
Here is the code I use to create the toolbar if that helps:
Code:HWND hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD|WS_VISIBLE|WS_BORDER|TBSTYLE_FLAT, 0, 0, 0, 0, hWnd, (HMENU)ID_TOOLBAR, hInst, NULL);
SendMessage(hTool, TB_SETBITMAPSIZE, 0, (LPARAM)MAKELONG(60,45));
SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
TBBUTTON tbb[NUM_TOOLS]; // NUM_TOOLS == 12
TBADDBITMAP tbab;
tbab.hInst = hInst;
tbab.nID = ID_BITMAP;
SendMessage(hTool, TB_ADDBITMAP, (WPARAM)10, (LPARAM)&tbab);
ZeroMemory(&tbb, sizeof(tbb));
for(int x=0; x<NUM_TOOLS; x++) {
tbb[x].fsState = TBSTATE_ENABLED;
tbb[x].fsStyle = TBSTYLE_BUTTON | TBSTYLE_CHECKGROUP;
}
tbb[0].iBitmap = 0;
tbb[0].idCommand = ID_HOME;
tbb[0].iString = (int)SendMessage(hTool, TB_ADDSTRING, (WPARAM)0, (LPARAM)(LPSTR)"Home");
tbb[1].fsStyle = TBSTYLE_SEP | TBSTYLE_CHECKGROUP;
tbb[2].iBitmap = 1;
tbb[2].idCommand = ID_UPLOAD;
tbb[2].iString = (int)SendMessage(hTool, TB_ADDSTRING, (WPARAM)0, (LPARAM)(LPSTR)"Upload");
tbb[3].iBitmap = 2;
tbb[3].idCommand = ID_BATCH;
tbb[3].iString = (int)SendMessage(hTool, TB_ADDSTRING, (WPARAM)0, (LPARAM)(LPSTR)"Batch Upload");
tbb[4].iBitmap = 3;
tbb[4].idCommand = ID_DOWNLOAD;
tbb[4].iString = (int)SendMessage(hTool, TB_ADDSTRING, (WPARAM)0, (LPARAM)(LPSTR)"Download");
tbb[5].iBitmap = 4;
tbb[5].idCommand = ID_MANAGE;
tbb[5].iString = (int)SendMessage(hTool, TB_ADDSTRING, (WPARAM)0, (LPARAM)(LPSTR)"Manage");
tbb[6].iBitmap = 5;
tbb[6].idCommand = ID_REQUEST;
tbb[6].iString = (int)SendMessage(hTool, TB_ADDSTRING, (WPARAM)0, (LPARAM)(LPSTR)"Request");
tbb[7].iBitmap = 6;
tbb[7].idCommand = ID_PM;
tbb[7].iString = (int)SendMessage(hTool, TB_ADDSTRING, (WPARAM)0, (LPARAM)(LPSTR)"PM");
tbb[8].fsStyle = TBSTYLE_SEP | TBSTYLE_CHECKGROUP;
tbb[9].iBitmap = 7;
tbb[9].idCommand = ID_SETTINGS;
tbb[9].iString = (int)SendMessage(hTool, TB_ADDSTRING, (WPARAM)0, (LPARAM)(LPSTR)"Settings");
tbb[10].iBitmap = 8;
tbb[10].idCommand = ID_HELP;
tbb[10].iString = (int)SendMessage(hTool, TB_ADDSTRING, (WPARAM)0, (LPARAM)(LPSTR)"Help");
tbb[10].fsStyle = TBSTYLE_BUTTON;
tbb[11].iBitmap = 9;
tbb[11].idCommand = ID_EXIT;
tbb[11].iString = (int)SendMessage(hTool, TB_ADDSTRING, (WPARAM)0, (LPARAM)(LPSTR)"Exit");
SendMessage(hTool, TB_ADDBUTTONS, (WPARAM)NUM_TOOLS, (LPARAM)&tbb);
SendMessage(hTool, TB_CHECKBUTTON, (WPARAM)ID_HOME, (LPARAM)MAKELONG(true,0));
Maybe you could destroy and create your whole toolbar every time a kind of wm_syscommand or somthing like that is called.
I download the source to a program that uses a toolbar how I'm using a toolbar (like a tab type system). The only images I could find in the source were .ico images. I can easily make all the button images into a .ico format, but how would I put a .ico file as the image of the button?