I searched everywhere for an answer to this, but I cant find anything. I have a .bmp file with 5 16 x 16 toolbar images. In my .rc file I have this line (ID_BITMAP is defined in one of my header files as 1111 and NUM_TOOLS is defined as 5):
ID_BITMAP BITMAP "toolbar.bmp"
And then I have this code to create the toolbar:
And what I get is 5 all black toolbar buttons. Is there something I'm doing wrong? Also, I'd prefer to have large icons (like 50 x 50 and maybe larger, I havent decided). Would I just make the bitmap larger or what would I have to change? Thanks for any help.
HWND hTool = CreateWindowEx(0,TOOLBARCLASSNAME,NULL,WS_CHILD|WS_VISIBLE,0,0,0,0,hWnd,(HMENU)ID_TOOLBAR,hInst,NULL);
SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
tbab.hInst = hInst;
tbab.nID = ID_BITMAP;
SendMessage(hTool, TB_ADDBITMAP, (WPARAM)5, (LPARAM)&tbab);
tbb[a].fsState = TBSTATE_ENABLED;
tbb[a].fsStyle = TBSTYLE_BUTTON | TBSTYLE_CHECKGROUP;
tbb.iBitmap = 0;
tbb.idCommand = ID_COMMAND1;
tbb.iBitmap = 1;
tbb.idCommand = ID_COMMAND2;
tbb.iBitmap = 2;
tbb.idCommand = ID_COMMAND3;
tbb.iBitmap = 3;
tbb.idCommand = ID_COMMAND4;
tbb.iBitmap = 4;
tbb.idCommand = ID_COMMAND5;
SendMessage(hTool, TB_ADDBUTTONS, (WPARAM)NUM_TOOLS, (LPARAM)&tbb);
I dont know what I did, but I went to compile my code again and amazingly it worked. I wish I could remember what I changed, but I dont remember changing anything. Either way, I got it working. I just need to figure out how to get larger icons and I'm all set.
I think hitting the Rebuild All button instead of Compile was the magic trick...
Whoo Hoo. I answered my own questions. For those wondering the same question:
SendMessage(hTool, TB_SETBITMAPSIZE, 0, (LPARAM)MAKELONG(width, height));
Put that before you add any bitmaps to your toolbar. It will load width X height of the bitmap (I'm not a great explainer). I hope someone can use this for a learning experience such as I did.