Toolbars?

This is a discussion on Toolbars? within the Windows Programming forums, part of the Platform Specific Boards category; Ok, so I've been trying for an entire week to get a toolbar to work in one of my applications, ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    27

    Toolbars?

    Ok, so I've been trying for an entire week to get a toolbar to work in one of my applications, and no matter how hard I try, it's just not working.

    I've been to msdn, theForger's tutorial and pretty much anything on the first ten pages of google results for various search terms, and I'm just not getting what the problem is.

    Anyway, the code basically loads a toolbar to the main window, with custom-set bitmaps on the buttons. I've used the obvious techniques of indexing as I'm loading the button bitmaps from one bitmap.

    http://img172.imageshack.us/img172/2873/toolbaruy8.png <- here's the bitmap file I'm using.

    Code:
    IDB_TOOLBAR BITMAP "toolbar.bmp"
    There it is defined.

    Code:
    HWND hTool;
                 TBBUTTON tbb[7];
                 TBADDBITMAP tbab;
                 
                 tbab.hInst=GetModuleHandle(NULL);
                 tbab.nID=IDB_TOOLBAR;
            				
                 ZeroMemory(tbb, sizeof(tbb));
                 tbb[0].iBitmap = 0;
                 tbb[0].fsState = TBSTATE_ENABLED;
                 tbb[0].fsStyle = TBSTYLE_BUTTON;
                 tbb[0].idCommand = ID_FILE_NEW;
                 tbb[1].iBitmap = 1;
                 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_SAVE;
                 tbb[3].iBitmap = 3;
                 tbb[3].fsState = TBSTATE_ENABLED;
                 tbb[3].fsStyle = TBSTYLE_BUTTON;
                 tbb[3].idCommand = ID_FILE_SAVEAS;
                 tbb[4].iBitmap = 0;
                 tbb[4].fsState = TBSTATE_ENABLED;
                 tbb[4].fsStyle = TBSTYLE_SEP;
                 tbb[4].idCommand = 0;
                 tbb[5].iBitmap = 4;
                 tbb[5].fsState = TBSTATE_ENABLED;
                 tbb[5].fsStyle = TBSTYLE_BUTTON;
                 tbb[5].idCommand = ID_EDIT_BMP;
                 tbb[6].iBitmap = 5;
                 tbb[6].fsState = TBSTATE_ENABLED;
                 tbb[6].fsStyle = TBSTYLE_BUTTON;
                 tbb[6].idCommand = ID_EDIT_MAP;
                 
                 SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
                 
                 hTool = CreateToolbarEx(hwnd,WS_VISIBLE | WS_CHILD | WS_BORDER,IDC_MAIN_TOOL,NUMBUTTONS,hInst,IDB_TOOLBAR,tbb,NUMBUTTONS,16, 15, 16, 15, sizeof(TBBUTTON));	
                            MessageBox(hwnd, "Could not create tool bar.", "Error", MB_OK | MB_ICONERROR);
    I'm using the compiler Dev-C++, and when running the application, it experiences a Windows error and closes instantly.

    Help?

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    27
    Just fixed this, dont worry, it appears I've been referencing my bitmap resource incorrectly.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Put a bitmap in a toolbars background
    By Joelito in forum Windows Programming
    Replies: 2
    Last Post: 06-30-2007, 02:27 PM
  2. Rebar and ToolBars
    By underline_bruce in forum Windows Programming
    Replies: 4
    Last Post: 05-25-2007, 09:48 PM
  3. How do I implement Toolbars?
    By shanedudddy2 in forum C++ Programming
    Replies: 0
    Last Post: 01-26-2003, 08:23 PM
  4. Dynamic Toolbars
    By nvoigt in forum Windows Programming
    Replies: 1
    Last Post: 01-11-2002, 09:21 AM
  5. Toolbars ... Rebars... whatever!... ...
    By Unregistered in forum Windows Programming
    Replies: 2
    Last Post: 11-19-2001, 07:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21