Thread: Toolbar Question

  1. #1
    Registered User
    Join Date
    Aug 2004

    Toolbar Question

    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:

    SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
    tbab.hInst = hInst;
    tbab.nID = ID_BITMAP;
    SendMessage(hTool, TB_ADDBITMAP, (WPARAM)5, (LPARAM)&tbab);
    ZeroMemory(&tbb, sizeof(tbb));
    for(a=0;a<NUM_TOOLS;a++) {
    	tbb[a].fsState = TBSTATE_ENABLED;
    tbb[0].iBitmap = 0;
    tbb[0].idCommand = ID_COMMAND1;
    tbb[1].iBitmap = 1;
    tbb[1].idCommand = ID_COMMAND2;
    tbb[2].iBitmap = 2;
    tbb[2].idCommand = ID_COMMAND3;
    tbb[3].iBitmap = 3;
    tbb[3].idCommand = ID_COMMAND4;
    tbb[4].iBitmap = 4;
    tbb[4].idCommand = ID_COMMAND5;
    SendMessage(hTool, TB_ADDBUTTONS, (WPARAM)NUM_TOOLS, (LPARAM)&tbb);
    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.

  2. #2
    Registered User
    Join Date
    Aug 2004
    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...
    Last edited by stickman; 09-14-2006 at 10:03 PM.

  3. #3
    Registered User
    Join Date
    Aug 2004
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Toolbar Buttons
    By G'n'R in forum Windows Programming
    Replies: 2
    Last Post: 10-02-2003, 05:35 AM
  2. What toolbar editor do you use?
    By _Elixia_ in forum Windows Programming
    Replies: 1
    Last Post: 08-09-2003, 05:57 AM
  3. Question...
    By TechWins in forum A Brief History of
    Replies: 16
    Last Post: 07-28-2003, 10:47 PM
  4. Tooltip won't display over toolbar button
    By minesweeper in forum Windows Programming
    Replies: 5
    Last Post: 06-20-2003, 02:21 AM
  5. Wild toolbar effect in MFC
    By Guardian in forum Windows Programming
    Replies: 0
    Last Post: 05-15-2002, 06:12 PM
Website Security Test