Thread: Toolbar problem

  1. #1
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005

    Toolbar problem

    			InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
    			InitCtrlEx.dwICC  = ICC_BAR_CLASSES;
    			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.
    My Website
    Add Color To Your Code!

  2. #2
    Join Date
    Jan 2002
    Set the wParam to the number of button images when you send the TB_ADDBITMAP message.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Thank you

    I dont know how i've missed that...
    My Website
    Add Color To Your Code!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  2. Toolbar problem
    By Ward in forum Windows Programming
    Replies: 0
    Last Post: 12-21-2005, 03:08 PM
  3. Dockable Toolbar (Like taskbar or office toolbar)
    By om3ga in forum Windows Programming
    Replies: 2
    Last Post: 11-20-2005, 03:09 AM
  4. Troubles with ListView and Toolbar
    By cornholio in forum Windows Programming
    Replies: 8
    Last Post: 11-14-2005, 01:26 AM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 05:46 PM