Thread: getting toolbar buttons onto a window

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Send a TB_INSERTBUTTON message to the toolbar window.

  2. #2
    Registered User eth0's Avatar
    Join Date
    Dec 2003
    Posts
    164
    I'm not really sure where I'm going wrong here.

    I'll post my relevant code sections on here in the hope that someone can point me in the right direction.

    I'll use standard buttons to make it simpler

    First of all, here is my simple button structure


    Code:
    TBBUTTON StdButtons [NUM_BUTTONS] =
    {
    /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
        {STD_FILENEW,  ID_NEW,      TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0},   
        {STD_FILEOPEN, ID_OPEN,     TBSTATE_ENABLED, BTNS_BUTTON,    {0}, 0, 0},    
        {STD_FILESAVE, ID_SAVE,     TBSTATE_INDETERMINATE, BTNS_BUTTON,    {0}, 0, 0},
    };
    Next I create my floating toolbar using WS_EX_TOOLWINDOW which successfully returns the handle hFloatTool.

    Then I attempt send the images to the toolbar

    Code:
    /* Send the TB_BUTTONSTRUCTSIZE message, which is required for backward compatibility */
    SendMessage(hFloatTool, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
     
    
    /* Add standard images */
    tbab.hInst = HINST_COMMCTRL;
    tbab.nID = IDB_STD_SMALL_COLOR;
    iImageOffset = (INT)SendMessage(hFloatTool, TB_ADDBITMAP, NUM_BUTTONS, (LPARAM)&tbab);
     
    
    /* Add buttons to toolbar */
    SendMessage(hFloatTool, TB_INSERTBUTTON, iImageOffset, (LPARAM) &StdButtons);
     
    
    /* Show toolbar */
     ShowWindow(hFloatTool, SW_SHOW);
    When run, I just get a blank floating toolbar.

    Any ideas?

    Cheers.
    Open source isn't a matter of life or death......
    .......its much more important than that!!


    SuSE Linux - GCC 3.4.2
    XP Pro - Visual Studio 2005 TS, MinGW 3.4.2

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  2. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  3. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM