getting toolbar buttons onto a window

This is a discussion on getting toolbar buttons onto a window within the Windows Programming forums, part of the Platform Specific Boards category; If I create a regular window ready to be a floating toolbar using WS_EX_TOOLWINDOW, how do I then get toolbar ...

  1. #1
    Registered User eth0's Avatar
    Join Date
    Dec 2003
    Posts
    164

    getting toolbar buttons onto a window

    If I create a regular window ready to be a floating toolbar using WS_EX_TOOLWINDOW, how do I then get toolbar buttons onto it?

    I'm using C and the Win32 API.

    Thanks
    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

  2. #2
    Registered User
    Join Date
    Feb 2006
    Posts
    71

    ...

    did you put in the window styles? such as WS_OVERLAPPEDWINOW or WS_SYSMENU on the toolwindow your declaring?

    (im not sure what you mean)

  3. #3
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    Send a TB_INSERTBUTTON message to the toolbar window.

  4. #4
    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

  5. #5
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    Code:
    SendMessage(hFloatTool, TB_INSERTBUTTON, iImageOffset, (LPARAM) &StdButtons);
    should be
    Code:
    SendMessage(hFloatTool, TB_INSERTBUTTON, 0, (LPARAM) StdButtons[i]);
    The image offset is determined by the iBitmap member of the TBBUTTON structure, are you sure you're filling that correctly?

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, 09: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, 01:34 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM

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