Ignore:
Timestamp:
Sep 5, 2001, 2:05:03 PM (24 years ago)
Author:
bird
Message:

Added $Id:$ keyword.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/toolbar.c

    r6380 r6644  
     1/* $Id: toolbar.c,v 1.29 2001-09-05 12:05:03 bird Exp $ */
    12/*
    23 * Toolbar control
     
    6263    INT nRow;
    6364    RECT rect;
    64 } TBUTTON_INFO; 
     65} TBUTTON_INFO;
    6566
    6667#ifdef __WIN32OS2__
     
    131132#define TOP_BORDER         2
    132133#define BOTTOM_BORDER      2
    133 #define DDARROW_WIDTH      11 
     134#define DDARROW_WIDTH      11
    134135
    135136#define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
     
    147148    else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
    148149        lpText = infoPtr->strings[btnPtr->iString];
    149    
     150
    150151    return lpText;
    151152}
    152153
    153 static BOOL 
     154static BOOL
    154155TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO *infoPtr, INT index)
    155156{
     
    195196 * Draw the text string for this button.
    196197 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
    197  *      is non-zero, so we can simply check himlDef to see if we have
     198 *  is non-zero, so we can simply check himlDef to see if we have
    198199 *      an image list
    199200 */
    200201static void
    201202TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
    202                     HDC hdc, INT nState, DWORD dwStyle)
     203            HDC hdc, INT nState, DWORD dwStyle)
    203204{
    204205    RECT   rcText = btnPtr->rect;
     
    219220    if (lpText) {
    220221
    221         InflateRect (&rcText, -3, -3);
    222 
    223         if (himl && TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
    224                 if ((dwStyle & TBSTYLE_LIST) &&
    225                     ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
    226                     (btnPtr->iBitmap != I_IMAGENONE)) {
    227                     rcText.left += infoPtr->nBitmapWidth;
    228                 }
    229                 else {
    230                     rcText.top += infoPtr->nBitmapHeight;
    231                 }
    232         }
    233 
    234         if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
    235             OffsetRect (&rcText, 1, 1);
    236 
    237         hOldFont = SelectObject (hdc, infoPtr->hFont);
    238         nOldBkMode = SetBkMode (hdc, TRANSPARENT);
    239         if (!(nState & TBSTATE_ENABLED)) {
    240             clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
    241             OffsetRect (&rcText, 1, 1);
    242             DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
    243             SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
    244             OffsetRect (&rcText, -1, -1);
    245             DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
    246         }
    247         else if (nState & TBSTATE_INDETERMINATE) {
    248             clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
    249             DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
    250         }
    251         else {
    252             clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
    253             DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
    254         }
    255 
    256         SetTextColor (hdc, clrOld);
    257         SelectObject (hdc, hOldFont);
    258         if (nOldBkMode != TRANSPARENT)
    259             SetBkMode (hdc, nOldBkMode);
     222    InflateRect (&rcText, -3, -3);
     223
     224    if (himl && TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
     225        if ((dwStyle & TBSTYLE_LIST) &&
     226            ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
     227            (btnPtr->iBitmap != I_IMAGENONE)) {
     228            rcText.left += infoPtr->nBitmapWidth;
     229        }
     230        else {
     231            rcText.top += infoPtr->nBitmapHeight;
     232        }
     233    }
     234
     235    if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
     236        OffsetRect (&rcText, 1, 1);
     237
     238    hOldFont = SelectObject (hdc, infoPtr->hFont);
     239    nOldBkMode = SetBkMode (hdc, TRANSPARENT);
     240    if (!(nState & TBSTATE_ENABLED)) {
     241        clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
     242        OffsetRect (&rcText, 1, 1);
     243        DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
     244        SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
     245        OffsetRect (&rcText, -1, -1);
     246        DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
     247    }
     248    else if (nState & TBSTATE_INDETERMINATE) {
     249        clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
     250        DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
     251    }
     252    else {
     253        clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
     254        DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
     255    }
     256
     257    SetTextColor (hdc, clrOld);
     258    SelectObject (hdc, hOldFont);
     259    if (nOldBkMode != TRANSPARENT)
     260        SetBkMode (hdc, nOldBkMode);
    260261    }
    261262}
     
    275276static void
    276277TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
    277                     HDC hdc, INT x, INT y)
     278            HDC hdc, INT x, INT y)
    278279{
    279280    /* FIXME: this function is a hack since it uses image list
    280               internals directly */
     281          internals directly */
    281282
    282283    HIMAGELIST himl = infoPtr->himlDef;
     
    286287
    287288    if (!himl)
    288         return;
     289    return;
    289290
    290291    /* create new dc's */
     
    301302    SetTextColor (hdcImageList, RGB(0, 0, 0));
    302303    BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
    303               hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
     304          hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
    304305
    305306    /* draw the new mask */
    306307    SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
    307308    BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
    308               hdcMask, 0, 0, 0xB8074A);
     309          hdcMask, 0, 0, 0xB8074A);
    309310
    310311    SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
    311312    BitBlt (hdc, x, y, himl->cx, himl->cy,
    312               hdcMask, 0, 0, 0xB8074A);
     313          hdcMask, 0, 0, 0xB8074A);
    313314
    314315    DeleteObject (hbmMask);
     
    324325    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    325326    BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) &&
    326                             (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
     327                        (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
    327328    RECT rc, rcArrow, rcBitmap;
    328329
    329330    if (btnPtr->fsState & TBSTATE_HIDDEN)
    330         return;
     331    return;
    331332
    332333    rc = btnPtr->rect;
     
    338339    if (hasDropDownArrow)
    339340    {
    340         if (dwStyle & TBSTYLE_FLAT)
     341    if (dwStyle & TBSTYLE_FLAT)
    341342            rc.right = max(rc.left, rc.right - DDARROW_WIDTH);
    342         else
     343    else
    343344            rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2);
    344         rcArrow.left = rc.right;
     345    rcArrow.left = rc.right;
    345346    }
    346347
     
    363364        /* when drawing the vertical bar...      */
    364365        if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */)
    365             TOOLBAR_DrawFlatSeparator (&rc, hdc);
    366         return;
     366        TOOLBAR_DrawFlatSeparator (&rc, hdc);
     367    return;
    367368    }
    368369
    369370    /* disabled */
    370371    if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
    371         if (!(dwStyle & TBSTYLE_FLAT))
    372         {
    373             DrawEdge (hdc, &rc, EDGE_RAISED,
    374                       BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     372    if (!(dwStyle & TBSTYLE_FLAT))
     373    {
     374        DrawEdge (hdc, &rc, EDGE_RAISED,
     375              BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    375376            if (hasDropDownArrow)
    376377            DrawEdge (hdc, &rcArrow, EDGE_RAISED,
    377                       BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    378         }
    379        
     378              BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     379    }
     380
    380381        if (hasDropDownArrow)
    381         {
    382             TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT);
    383             TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW);
    384         }
    385 
    386         if (infoPtr->himlDis &&
     382    {
     383        TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT);
     384        TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW);
     385    }
     386
     387    if (infoPtr->himlDis &&
    387388            TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    388             ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
    389                         rcBitmap.left, rcBitmap.top, ILD_NORMAL);
    390         else
    391             TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
    392 
    393         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    394         return;
     389        ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
     390            rcBitmap.left, rcBitmap.top, ILD_NORMAL);
     391    else
     392        TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
     393
     394    TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
     395    return;
    395396    }
    396397
    397398    /* pressed TBSTYLE_BUTTON */
    398399    if (btnPtr->fsState & TBSTATE_PRESSED) {
    399         if (dwStyle & TBSTYLE_FLAT)
    400         {
    401             DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST);
     400    if (dwStyle & TBSTYLE_FLAT)
     401    {
     402        DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST);
    402403            if (hasDropDownArrow)
    403             DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST);
    404         }
    405         else
    406         {
    407             DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
     404        DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST);
     405    }
     406    else
     407    {
     408        DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
    408409            if (hasDropDownArrow)
    409             DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
    410         }
     410        DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
     411    }
    411412
    412413        if (hasDropDownArrow)
    413             TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
     414        TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
    414415
    415416        if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    416             ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    417                         rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL);
    418 
    419         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    420         return;
     417        ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
     418            rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL);
     419
     420    TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
     421    return;
    421422    }
    422423
    423424    /* checked TBSTYLE_CHECK */
    424425    if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
    425         (btnPtr->fsState & TBSTATE_CHECKED)) {
    426         if (dwStyle & TBSTYLE_FLAT)
    427             DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
    428                         BF_RECT | BF_MIDDLE | BF_ADJUST);
    429         else
    430             DrawEdge (hdc, &rc, EDGE_SUNKEN,
    431                         BF_RECT | BF_MIDDLE | BF_ADJUST);
    432 
    433         TOOLBAR_DrawPattern (hdc, &rc);
    434        
     426    (btnPtr->fsState & TBSTATE_CHECKED)) {
     427    if (dwStyle & TBSTYLE_FLAT)
     428        DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
     429            BF_RECT | BF_MIDDLE | BF_ADJUST);
     430    else
     431        DrawEdge (hdc, &rc, EDGE_SUNKEN,
     432            BF_RECT | BF_MIDDLE | BF_ADJUST);
     433
     434    TOOLBAR_DrawPattern (hdc, &rc);
     435
    435436        if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    436             ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    437                         rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL);
    438         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    439         return;
    440     }
    441 
    442     /* indeterminate */ 
     437        ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
     438            rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL);
     439    TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
     440    return;
     441    }
     442
     443    /* indeterminate */
    443444    if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
    444         DrawEdge (hdc, &rc, EDGE_RAISED,
    445                     BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    446 
    447         TOOLBAR_DrawPattern (hdc, &rc);
    448         TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
    449         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    450         return;
     445    DrawEdge (hdc, &rc, EDGE_RAISED,
     446            BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     447
     448    TOOLBAR_DrawPattern (hdc, &rc);
     449    TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
     450    TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
     451    return;
    451452    }
    452453
     
    454455    if (dwStyle & TBSTYLE_FLAT)
    455456    {
    456         if (btnPtr->bHot)
    457         {
    458             DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
     457    if (btnPtr->bHot)
     458    {
     459        DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
    459460            if (hasDropDownArrow)
    460             DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
    461         }
     461        DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
     462    }
    462463        else
    463         {
     464    {
    464465            FrameRect(hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
    465466            if (hasDropDownArrow)
    466467            FrameRect(hdc, &rcArrow, GetSysColorBrush(COLOR_BTNFACE));
    467         }
     468    }
    468469
    469470        if (hasDropDownArrow)
    470             TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME);
    471 
    472         if (btnPtr->bHot && infoPtr->himlHot &&
     471        TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME);
     472
     473    if (btnPtr->bHot && infoPtr->himlHot &&
    473474            TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    474             ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc,
    475                         rcBitmap.left, rcBitmap.top, ILD_NORMAL);
    476         else if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    477             ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    478                         rcBitmap.left, rcBitmap.top, ILD_NORMAL);
     475        ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc,
     476            rcBitmap.left, rcBitmap.top, ILD_NORMAL);
     477    else if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
     478        ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
     479            rcBitmap.left, rcBitmap.top, ILD_NORMAL);
    479480    }
    480481    else
    481482    {
    482         DrawEdge (hdc, &rc, EDGE_RAISED,
    483                 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     483    DrawEdge (hdc, &rc, EDGE_RAISED,
     484        BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    484485
    485486        if (hasDropDownArrow)
    486         {
    487             DrawEdge (hdc, &rcArrow, EDGE_RAISED,
    488                     BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    489             TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
    490         }
     487    {
     488        DrawEdge (hdc, &rcArrow, EDGE_RAISED,
     489            BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     490        TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
     491    }
    491492
    492493        if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    493             ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    494                         rcBitmap.left, rcBitmap.top, ILD_NORMAL);
     494        ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
     495            rcBitmap.left, rcBitmap.top, ILD_NORMAL);
    495496    }
    496497
     
    537538    if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
    538539         (btnPtr->iString > -1) &&
    539          (btnPtr->iString < infoPtr->nNumStrings)) 
     540         (btnPtr->iString < infoPtr->nNumStrings))
    540541    {
    541542        LPWSTR lpText = infoPtr->strings[btnPtr->iString];
     
    577578
    578579/***********************************************************************
    579 *               TOOLBAR_WrapToolbar
     580*       TOOLBAR_WrapToolbar
    580581*
    581 * This function walks through the buttons and seperators in the 
    582 * toolbar, and sets the TBSTATE_WRAP flag only on those items where 
    583 * wrapping should occur based on the width of the toolbar window. 
    584 * It does *not* calculate button placement itself.  That task 
    585 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage 
    586 * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE 
     582* This function walks through the buttons and seperators in the
     583* toolbar, and sets the TBSTATE_WRAP flag only on those items where
     584* wrapping should occur based on the width of the toolbar window.
     585* It does *not* calculate button placement itself.  That task
     586* takes place in TOOLBAR_CalcToolbar. If the program wants to manage
     587* the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE
    587588* flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
    588 */ 
     589*/
    589590
    590591static void
     
    597598    BOOL bWrap, bButtonWrap;
    598599
    599     /*  When the toolbar window style is not TBSTYLE_WRAPABLE,  */
    600     /*  no layout is necessary. Applications may use this style */
    601     /*  to perform their own layout on the toolbar.             */
     600    /*  When the toolbar window style is not TBSTYLE_WRAPABLE,  */
     601    /*  no layout is necessary. Applications may use this style */
     602    /*  to perform their own layout on the toolbar.         */
    602603    if( !(dwStyle & TBSTYLE_WRAPABLE) )
    603         return;
     604    return;
    604605
    605606    btnPtr = infoPtr->buttons;
     
    616617    for (i = 0; i < infoPtr->nNumButtons; i++ )
    617618    {
    618         bWrap = FALSE;
    619         btnPtr[i].fsState &= ~TBSTATE_WRAP;
    620        
    621         if (btnPtr[i].fsState & TBSTATE_HIDDEN)
    622             continue;
    623 
    624         /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
    625         /* it is the actual width of the separator. This is used for */
    626         /* custom controls in toolbars.                              */
    627         if (btnPtr[i].fsStyle & TBSTYLE_SEP)
    628             cx = (btnPtr[i].iBitmap > 0) ? 
    629                         btnPtr[i].iBitmap : SEPARATOR_WIDTH;
    630         else
    631             cx = infoPtr->nButtonWidth;
    632 
    633         /* Two or more adjacent separators form a separator group.   */
    634         /* The first separator in a group should be wrapped to the   */
    635         /* next row if the previous wrapping is on a button.         */
    636         if( bButtonWrap &&
    637                 (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
    638                 (i + 1 < infoPtr->nNumButtons ) &&
    639                 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
    640         {
    641             btnPtr[i].fsState |= TBSTATE_WRAP;
    642             x = infoPtr->nIndent;
    643             i++;
    644             bButtonWrap = FALSE;
    645             continue;
    646         }
    647 
    648         /* The layout makes sure the bitmap is visible, but not the button. */
    649         if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
    650                  > infoPtr->nWidth )
    651         {
    652             BOOL bFound = FALSE;
    653 
    654             /*  If the current button is a separator and not hidden,  */
    655             /*  go to the next until it reaches a non separator.      */
    656             /*  Wrap the last separator if it is before a button.     */
    657             while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
    658                         (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
    659                         i < infoPtr->nNumButtons )
    660             {
    661                 i++;
    662                 bFound = TRUE;
    663             }
    664    
    665             if( bFound && i < infoPtr->nNumButtons )
    666             {
    667                 i--;
    668                 btnPtr[i].fsState |= TBSTATE_WRAP;
    669                 x = infoPtr->nIndent;
    670                 bButtonWrap = FALSE;
    671                 continue;
    672             }
    673             else if ( i >= infoPtr->nNumButtons)
    674                 break;
    675 
    676             /*  If the current button is not a separator, find the last  */
    677             /*  separator and wrap it.                                  */
    678             for ( j = i - 1; j >= 0  &&  !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
    679             {
    680                 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
    681                         !(btnPtr[j].fsState & TBSTATE_HIDDEN))
    682                 {
    683                     bFound = TRUE;
    684                     i = j;
    685                     x = infoPtr->nIndent;
    686                     btnPtr[j].fsState |= TBSTATE_WRAP;
    687                     bButtonWrap = FALSE;
    688                     break;
    689                 }
    690             }
    691 
    692             /*  If no separator available for wrapping, wrap one of     */
    693             /*  non-hidden previous button.                             */
    694             if (!bFound)
    695             {
    696                 for ( j = i - 1;
    697                         j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
    698                 {
    699                     if (btnPtr[j].fsState & TBSTATE_HIDDEN)
    700                         continue;
    701 
    702                     bFound = TRUE;
    703                     i = j;
    704                     x = infoPtr->nIndent;
    705                     btnPtr[j].fsState |= TBSTATE_WRAP;
    706                     bButtonWrap = TRUE;
    707                     break;
    708                 }
    709             }
    710 
    711             /* If all above failed, wrap the current button. */
    712             if (!bFound) 
    713             {
    714                 btnPtr[i].fsState |= TBSTATE_WRAP;
    715                 bFound = TRUE;
    716                 x = infoPtr->nIndent;
    717                 if (btnPtr[i].fsState & TBSTYLE_SEP )
    718                     bButtonWrap = FALSE;
    719                 else
    720                     bButtonWrap = TRUE;
    721             }               
    722         }
    723         else
    724             x += cx;
     619    bWrap = FALSE;
     620    btnPtr[i].fsState &= ~TBSTATE_WRAP;
     621
     622    if (btnPtr[i].fsState & TBSTATE_HIDDEN)
     623        continue;
     624
     625    /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
     626    /* it is the actual width of the separator. This is used for */
     627    /* custom controls in toolbars.                              */
     628    if (btnPtr[i].fsStyle & TBSTYLE_SEP)
     629        cx = (btnPtr[i].iBitmap > 0) ?
     630            btnPtr[i].iBitmap : SEPARATOR_WIDTH;
     631    else
     632        cx = infoPtr->nButtonWidth;
     633
     634    /* Two or more adjacent separators form a separator group.   */
     635    /* The first separator in a group should be wrapped to the   */
     636    /* next row if the previous wrapping is on a button.         */
     637    if( bButtonWrap &&
     638        (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
     639        (i + 1 < infoPtr->nNumButtons ) &&
     640        (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
     641    {
     642        btnPtr[i].fsState |= TBSTATE_WRAP;
     643        x = infoPtr->nIndent;
     644        i++;
     645        bButtonWrap = FALSE;
     646        continue;
     647    }
     648
     649    /* The layout makes sure the bitmap is visible, but not the button. */
     650    if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
     651         > infoPtr->nWidth )
     652    {
     653        BOOL bFound = FALSE;
     654
     655        /*  If the current button is a separator and not hidden,  */
     656        /*  go to the next until it reaches a non separator.      */
     657        /*  Wrap the last separator if it is before a button.     */
     658        while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
     659            (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
     660            i < infoPtr->nNumButtons )
     661        {
     662        i++;
     663        bFound = TRUE;
     664        }
     665
     666        if( bFound && i < infoPtr->nNumButtons )
     667        {
     668        i--;
     669        btnPtr[i].fsState |= TBSTATE_WRAP;
     670        x = infoPtr->nIndent;
     671        bButtonWrap = FALSE;
     672        continue;
     673        }
     674        else if ( i >= infoPtr->nNumButtons)
     675        break;
     676
     677        /*  If the current button is not a separator, find the last  */
     678        /*  separator and wrap it.                  */
     679        for ( j = i - 1; j >= 0  &&  !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
     680        {
     681        if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
     682            !(btnPtr[j].fsState & TBSTATE_HIDDEN))
     683        {
     684            bFound = TRUE;
     685            i = j;
     686            x = infoPtr->nIndent;
     687            btnPtr[j].fsState |= TBSTATE_WRAP;
     688            bButtonWrap = FALSE;
     689            break;
     690        }
     691        }
     692
     693        /*  If no separator available for wrapping, wrap one of     */
     694        /*  non-hidden previous button.                     */
     695        if (!bFound)
     696        {
     697        for ( j = i - 1;
     698            j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
     699        {
     700            if (btnPtr[j].fsState & TBSTATE_HIDDEN)
     701            continue;
     702
     703            bFound = TRUE;
     704            i = j;
     705            x = infoPtr->nIndent;
     706            btnPtr[j].fsState |= TBSTATE_WRAP;
     707            bButtonWrap = TRUE;
     708            break;
     709        }
     710        }
     711
     712        /* If all above failed, wrap the current button. */
     713        if (!bFound)
     714        {
     715        btnPtr[i].fsState |= TBSTATE_WRAP;
     716        bFound = TRUE;
     717        x = infoPtr->nIndent;
     718        if (btnPtr[i].fsState & TBSTYLE_SEP )
     719            bButtonWrap = FALSE;
     720        else
     721            bButtonWrap = TRUE;
     722        }
     723    }
     724    else
     725        x += cx;
    725726    }
    726727}
     
    728729
    729730/***********************************************************************
    730 *               TOOLBAR_CalcToolbar
     731*       TOOLBAR_CalcToolbar
    731732*
    732 * This function calculates button and separator placement. It first 
    733 * calculates the button sizes, gets the toolbar window width and then 
    734 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap 
     733* This function calculates button and separator placement. It first
     734* calculates the button sizes, gets the toolbar window width and then
     735* calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
    735736* on. It assigns a new location to each item and sends this location to
    736 * the tooltip window if appropriate. Finally, it updates the rcBound 
    737 * rect and calculates the new required toolbar window height. 
    738 */ 
     737* the tooltip window if appropriate. Finally, it updates the rcBound
     738* rect and calculates the new required toolbar window height.
     739*/
    739740
    740741static void
     
    755756    if (dwStyle & TBSTYLE_LIST)
    756757    {
    757         infoPtr->nButtonHeight = max(infoPtr->nBitmapHeight, sizeString.cy) + 6;
    758         infoPtr->nButtonWidth = infoPtr->nBitmapWidth + sizeString.cx + 6;
     758    infoPtr->nButtonHeight = max(infoPtr->nBitmapHeight, sizeString.cy) + 6;
     759    infoPtr->nButtonWidth = infoPtr->nBitmapWidth + sizeString.cx + 6;
    759760    }
    760761    else {
    761762        for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
    762763        {
    763             if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap))
    764                 usesBitmaps = TRUE;
     764        if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap))
     765            usesBitmaps = TRUE;
    765766        }
    766767
     
    768769        {
    769770            if (usesBitmaps)
    770               infoPtr->nButtonHeight = sizeString.cy +
     771          infoPtr->nButtonHeight = sizeString.cy +
    771772                  infoPtr->nBitmapHeight + 6;
    772             else 
     773            else
    773774                infoPtr->nButtonHeight = sizeString.cy + 6;
    774775        }
    775776        else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
    776             infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
     777        infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
    777778
    778779        if (sizeString.cx > infoPtr->nBitmapWidth)
    779             infoPtr->nButtonWidth = sizeString.cx + 6;
     780        infoPtr->nButtonWidth = sizeString.cx + 6;
    780781        else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
    781             infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
     782        infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
    782783    }
    783784
     
    793794
    794795   /*
    795     * We will set the height below, and we set the width on entry 
    796     * so we do not reset them here.. 
     796    * We will set the height below, and we set the width on entry
     797    * so we do not reset them here..
    797798    */
    798799#if 0
     
    829830    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
    830831    {
    831         bWrap = FALSE;
    832         if (btnPtr->fsState & TBSTATE_HIDDEN)
    833         {
    834             SetRectEmpty (&btnPtr->rect);
    835             continue;
    836         }
    837 
    838             /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
    839             /* it is the actual width of the separator. This is used for */
    840             /* custom controls in toolbars.                              */
    841         if (btnPtr->fsStyle & TBSTYLE_SEP)
    842                 cx = (btnPtr->iBitmap > 0) ?
    843                      btnPtr->iBitmap : SEPARATOR_WIDTH;
    844         else
    845         {
    846             if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE) 
     832    bWrap = FALSE;
     833    if (btnPtr->fsState & TBSTATE_HIDDEN)
     834    {
     835        SetRectEmpty (&btnPtr->rect);
     836        continue;
     837    }
     838
     839        /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
     840        /* it is the actual width of the separator. This is used for */
     841        /* custom controls in toolbars.                              */
     842    if (btnPtr->fsStyle & TBSTYLE_SEP)
     843        cx = (btnPtr->iBitmap > 0) ?
     844             btnPtr->iBitmap : SEPARATOR_WIDTH;
     845    else
     846    {
     847            if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE)
    847848            {
    848849              SIZE sz;
     
    851852            }
    852853            else
    853               cx = infoPtr->nButtonWidth;
    854 
    855             if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN))
    856               cx += DDARROW_WIDTH;
    857         }
    858         cy = infoPtr->nHeight;
    859 
    860         if (btnPtr->fsState & TBSTATE_WRAP )
    861                     bWrap = TRUE;
    862 
    863         SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
    864 
    865         if (infoPtr->rcBound.left > x)
    866             infoPtr->rcBound.left = x;
    867         if (infoPtr->rcBound.right < x + cx)
    868             infoPtr->rcBound.right = x + cx;
    869         if (infoPtr->rcBound.bottom < y + cy)
    870             infoPtr->rcBound.bottom = y + cy;
    871 
    872         /* Set the toolTip only for non-hidden, non-separator button */
    873         if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
    874         {
    875             TTTOOLINFOA ti;
    876 
    877             ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    878             ti.cbSize = sizeof(TTTOOLINFOA);
    879             ti.hwnd = hwnd;
    880             ti.uId = btnPtr->idCommand;
    881             ti.rect = btnPtr->rect;
    882             SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
    883                             0, (LPARAM)&ti);
    884         }
    885 
    886         /* btnPtr->nRow is zero based. The space between the rows is    */
    887         /* also considered as a row.                                    */
    888         btnPtr->nRow = nRows + nSepRows;
    889         if( bWrap )
    890         {
    891             if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
    892                 y += cy;
    893             else
    894             {   
    895                 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
    896                 /* it is the actual width of the separator. This is used for */
    897                 /* custom controls in toolbars.                              */
    898                 y += cy + ( (btnPtr->iBitmap > 0 ) ?
    899                         btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
    900              
    901                 /* nSepRows is used to calculate the extra height follwoing  */         
    902                 /* the last row.                                             */
    903                 nSepRows++;
    904             }
    905             x = infoPtr->nIndent;
    906                 nRows++;
    907         }
    908         else
    909             x += cx;
     854          cx = infoPtr->nButtonWidth;
     855
     856        if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN))
     857          cx += DDARROW_WIDTH;
     858    }
     859    cy = infoPtr->nHeight;
     860
     861    if (btnPtr->fsState & TBSTATE_WRAP )
     862            bWrap = TRUE;
     863
     864    SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
     865
     866    if (infoPtr->rcBound.left > x)
     867        infoPtr->rcBound.left = x;
     868    if (infoPtr->rcBound.right < x + cx)
     869        infoPtr->rcBound.right = x + cx;
     870    if (infoPtr->rcBound.bottom < y + cy)
     871        infoPtr->rcBound.bottom = y + cy;
     872
     873    /* Set the toolTip only for non-hidden, non-separator button */
     874    if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
     875    {
     876        TTTOOLINFOA ti;
     877
     878        ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     879        ti.cbSize = sizeof(TTTOOLINFOA);
     880        ti.hwnd = hwnd;
     881        ti.uId = btnPtr->idCommand;
     882        ti.rect = btnPtr->rect;
     883        SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
     884                0, (LPARAM)&ti);
     885    }
     886
     887    /* btnPtr->nRow is zero based. The space between the rows is    */
     888    /* also considered as a row.                    */
     889    btnPtr->nRow = nRows + nSepRows;
     890    if( bWrap )
     891    {
     892        if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
     893            y += cy;
     894        else
     895        {
     896        /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
     897        /* it is the actual width of the separator. This is used for */
     898        /* custom controls in toolbars.                  */
     899        y += cy + ( (btnPtr->iBitmap > 0 ) ?
     900            btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
     901
     902        /* nSepRows is used to calculate the extra height follwoing  */
     903        /* the last row.                         */
     904        nSepRows++;
     905        }
     906        x = infoPtr->nIndent;
     907        nRows++;
     908    }
     909    else
     910        x += cx;
    910911    }
    911912
     
    913914    infoPtr->nRows = nRows + nSepRows + 1;
    914915
    915     /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following   */
    916     /* the last row.                                                    */
    917     infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight + 
    918                         nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
    919                         nSepRows * (infoPtr->nBitmapHeight + 1) +
    920                         BOTTOM_BORDER;
     916    /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following   */
     917    /* the last row.                            */
     918    infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
     919                nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
     920            nSepRows * (infoPtr->nBitmapHeight + 1) +
     921            BOTTOM_BORDER;
    921922    TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth);
    922923}
     
    929930    TBUTTON_INFO *btnPtr;
    930931    INT i;
    931    
     932
    932933    btnPtr = infoPtr->buttons;
    933934    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
    934         if (btnPtr->fsState & TBSTATE_HIDDEN)
    935             continue;
    936 
    937         if (btnPtr->fsStyle & TBSTYLE_SEP) {
    938             if (PtInRect (&btnPtr->rect, *lpPt)) {
    939                 TRACE(" ON SEPARATOR %d!\n", i);
    940                 return -i;
    941             }
    942         }
    943         else {
    944             if (PtInRect (&btnPtr->rect, *lpPt)) {
    945                 TRACE(" ON BUTTON %d!\n", i);
    946                 return i;
    947             }
    948         }
     935    if (btnPtr->fsState & TBSTATE_HIDDEN)
     936        continue;
     937
     938    if (btnPtr->fsStyle & TBSTYLE_SEP) {
     939        if (PtInRect (&btnPtr->rect, *lpPt)) {
     940        TRACE(" ON SEPARATOR %d!\n", i);
     941        return -i;
     942        }
     943    }
     944    else {
     945        if (PtInRect (&btnPtr->rect, *lpPt)) {
     946        TRACE(" ON BUTTON %d!\n", i);
     947        return i;
     948        }
     949    }
    949950    }
    950951
     
    962963    btnPtr = infoPtr->buttons;
    963964    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
    964         if (btnPtr->idCommand == idCommand) {
    965             TRACE("command=%d index=%d\n", idCommand, i);
    966             return i;
    967         }
     965    if (btnPtr->idCommand == idCommand) {
     966        TRACE("command=%d index=%d\n", idCommand, i);
     967        return i;
     968    }
    968969    }
    969970    TRACE("no index found for command=%d\n", idCommand);
     
    979980
    980981    if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
    981         return -1;
     982    return -1;
    982983
    983984    /* check index button */
    984985    btnPtr = &infoPtr->buttons[nIndex];
    985986    if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
    986         if (btnPtr->fsState & TBSTATE_CHECKED)
    987             return nIndex;
     987    if (btnPtr->fsState & TBSTATE_CHECKED)
     988        return nIndex;
    988989    }
    989990
     
    991992    nRunIndex = nIndex - 1;
    992993    while (nRunIndex >= 0) {
    993         btnPtr = &infoPtr->buttons[nRunIndex];
    994         if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
    995             if (btnPtr->fsState & TBSTATE_CHECKED)
    996                 return nRunIndex;
    997         }
    998         else
    999             break;
    1000         nRunIndex--;
     994    btnPtr = &infoPtr->buttons[nRunIndex];
     995    if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
     996        if (btnPtr->fsState & TBSTATE_CHECKED)
     997        return nRunIndex;
     998    }
     999    else
     1000        break;
     1001    nRunIndex--;
    10011002    }
    10021003
     
    10041005    nRunIndex = nIndex + 1;
    10051006    while (nRunIndex < infoPtr->nNumButtons) {
    1006         btnPtr = &infoPtr->buttons[nRunIndex]; 
    1007         if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
    1008             if (btnPtr->fsState & TBSTATE_CHECKED)
    1009                 return nRunIndex;
    1010         }
    1011         else
    1012             break;
    1013         nRunIndex++;
     1007    btnPtr = &infoPtr->buttons[nRunIndex];
     1008    if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
     1009        if (btnPtr->fsState & TBSTATE_CHECKED)
     1010        return nRunIndex;
     1011    }
     1012    else
     1013        break;
     1014    nRunIndex++;
    10141015    }
    10151016
     
    10201021static VOID
    10211022TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
    1022                     WPARAM wParam, LPARAM lParam)
     1023            WPARAM wParam, LPARAM lParam)
    10231024{
    10241025    MSG msg;
     
    10491050    switch (uMsg)
    10501051    {
    1051         case WM_INITDIALOG:
    1052             custInfo = (PCUSTDLG_INFO)lParam;
    1053             SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo);
    1054 
    1055             if (custInfo)
    1056             {
    1057                 char Buffer[256];
    1058                 int i = 0;
    1059                 int index;
    1060 
    1061                 /* send TBN_QUERYINSERT notification */
    1062                 nmtb.hdr.hwndFrom = hwnd;
    1063                 nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1064                 nmtb.hdr.code     = TBN_QUERYINSERT;
    1065                 nmtb.iItem = custInfo->tbInfo->nNumButtons;
    1066 
    1067                 if (!SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1068                                    (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1069                     return FALSE;
    1070 
    1071                 /* add items to 'toolbar buttons' list and check if removable */
    1072                 for (i = 0; i < custInfo->tbInfo->nNumButtons; i++)
    1073                 {
    1074                     btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
    1075                     memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
    1076                     btnInfo->btn.fsStyle = TBSTYLE_SEP;
    1077                     btnInfo->bVirtual = FALSE;
    1078                     LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
    1079 
    1080                     /* send TBN_QUERYDELETE notification */
    1081                     nmtb.hdr.hwndFrom = hwnd;
    1082                     nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1083                     nmtb.hdr.code     = TBN_QUERYDELETE;
    1084                     nmtb.iItem = i;
    1085 
    1086                     btnInfo->bRemovable = SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1087                                                         (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
    1088 
    1089                     index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0);
    1090                     SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1091                 }
    1092 
    1093                 /* insert separator button into 'available buttons' list */
    1094                 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
    1095                 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
    1096                 btnInfo->btn.fsStyle = TBSTYLE_SEP;
    1097                 btnInfo->bVirtual = FALSE;
    1098                 btnInfo->bRemovable = TRUE;
    1099                 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
    1100                 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
    1101                 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1102 
    1103                 /* insert all buttons into dsa */
    1104                 for (i = 0;; i++)
    1105                 {
    1106                     /* send TBN_GETBUTTONINFO notification */
    1107                     nmtb.hdr.hwndFrom = hwnd;
    1108                     nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1109                     nmtb.hdr.code     = TBN_GETBUTTONINFOA;
    1110                     nmtb.iItem = i;
    1111                     nmtb.pszText = Buffer;
    1112                     nmtb.cchText = 256;
    1113 
    1114                     if (!SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1115                                        (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1116                         break;
    1117 
    1118                     TRACE("style: %x\n", nmtb.tbButton.fsStyle);               
    1119 
    1120                     /* insert button into the apropriate list */
    1121                     index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand);
    1122                     if (index == -1)
    1123                     {
    1124                         btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
    1125                         memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
    1126                         btnInfo->bVirtual = FALSE;
    1127                         btnInfo->bRemovable = TRUE;
    1128                         if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
    1129                             strcpy (btnInfo->text, nmtb.pszText);
    1130 
    1131                         index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
    1132                         SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1133                     }
    1134                     else
    1135                     {
    1136                         btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
    1137                         memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
    1138                         if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
    1139                             strcpy (btnInfo->text, nmtb.pszText);
    1140 
    1141                         SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1142                     }
    1143                 }
    1144 
    1145                 /* select first item in the 'available' list */
    1146                 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0);
    1147 
    1148                 /* append 'virtual' separator button to the 'toolbar buttons' list */
    1149                 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
    1150                 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
    1151                 btnInfo->btn.fsStyle = TBSTYLE_SEP;
    1152                 btnInfo->bVirtual = TRUE;
    1153                 btnInfo->bRemovable = FALSE;
    1154                 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
    1155                 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
    1156                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1157 
    1158                 /* select last item in the 'toolbar' list */
    1159                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0);
    1160                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0);
    1161 
    1162                 /* set focus and disable buttons */
    1163                 PostMessageA (hwnd, WM_USER, 0, 0);
    1164             }
    1165             return TRUE;
    1166 
    1167         case WM_USER:
    1168             EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
    1169             EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
    1170             EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE);
    1171             SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX));
    1172             return TRUE;
    1173 
    1174         case WM_CLOSE:
    1175             EndDialog(hwnd, FALSE);
    1176             return TRUE;
    1177 
    1178         case WM_COMMAND:
    1179             switch (LOWORD(wParam))
    1180             {
    1181                 case IDC_TOOLBARBTN_LBOX:
    1182                     if (HIWORD(wParam) == LBN_SELCHANGE)
    1183                     {
    1184                         PCUSTOMBUTTON btnInfo;
    1185                         NMTOOLBARA nmtb;
    1186                         int count;
    1187                         int index;
    1188 
    1189                         count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
    1190                         index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
    1191 
    1192                         /* send TBN_QUERYINSERT notification */
    1193                         nmtb.hdr.hwndFrom = hwnd;
    1194                         nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1195                         nmtb.hdr.code     = TBN_QUERYINSERT;
    1196                         nmtb.iItem = index;
    1197 
    1198                         SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1199                                       (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
    1200 
    1201                         /* get list box item */
    1202                         btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
    1203 
    1204                         if (index == (count - 1))
    1205                         {
    1206                             /* last item (virtual separator) */
    1207                             EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
    1208                             EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
    1209                         }
    1210                         else if (index == (count - 2))
    1211                         {
    1212                             /* second last item (last non-virtual item) */
    1213                             EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
    1214                             EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
    1215                         }
    1216                         else if (index == 0)
    1217                         {
    1218                             /* first item */
    1219                             EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
    1220                             EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
    1221                         }
    1222                         else
    1223                         {
    1224                             EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
    1225                             EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
    1226                         }
    1227 
    1228                         EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable);
    1229                     }
    1230                     break;
    1231 
    1232                 case IDC_MOVEUP_BTN:
    1233                     {
    1234                         PCUSTOMBUTTON btnInfo;
    1235                         int index;
    1236                         int count;
    1237 
    1238                         count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
    1239                         index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
    1240                         TRACE("Move up: index %d\n", index);
    1241 
    1242                         /* send TBN_QUERYINSERT notification */
    1243                         nmtb.hdr.hwndFrom = hwnd;
    1244                         nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1245                         nmtb.hdr.code     = TBN_QUERYINSERT;
    1246                         nmtb.iItem = index;
    1247 
    1248                         if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1249                                           (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1250                         {
    1251                             btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
    1252 
    1253                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
    1254                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0);
    1255                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo);
    1256                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0);
    1257 
    1258                             if (index <= 1)
    1259                                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
    1260                             else if (index >= (count - 3))
    1261                                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
    1262 
    1263                             SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
    1264                             SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn));
    1265                         }
    1266                     }
    1267                     break;
    1268 
    1269                 case IDC_MOVEDN_BTN: /* move down */
    1270                     {
    1271                         PCUSTOMBUTTON btnInfo;
    1272                         int index;
    1273                         int count;
    1274 
    1275                         count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
    1276                         index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
    1277                         TRACE("Move up: index %d\n", index);
    1278 
    1279                         /* send TBN_QUERYINSERT notification */
    1280                         nmtb.hdr.hwndFrom = hwnd;
    1281                         nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1282                         nmtb.hdr.code     = TBN_QUERYINSERT;
    1283                         nmtb.iItem = index;
    1284 
    1285                         if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1286                                           (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1287                         {
    1288                             btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
    1289 
    1290                             /* move button down */
    1291                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
    1292                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0);
    1293                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo);
    1294                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0);
    1295 
    1296                             if (index == 0)
    1297                                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
    1298                             else if (index >= (count - 3))
    1299                                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
    1300 
    1301                             SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
    1302                             SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn));
    1303                         }
    1304                     }
    1305                     break;
    1306 
    1307                 case IDC_REMOVE_BTN: /* remove button */
    1308                     {
    1309                         PCUSTOMBUTTON btnInfo;
    1310                         int index;
    1311 
    1312                         index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
    1313                         TRACE("Remove: index %d\n", index);
    1314 
    1315                         /* send TBN_QUERYDELETE notification */
    1316                         nmtb.hdr.hwndFrom = hwnd;
    1317                         nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1318                         nmtb.hdr.code     = TBN_QUERYDELETE;
    1319                         nmtb.iItem = index;
    1320 
    1321                         if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1322                                           (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1323                         {
    1324                             btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
    1325                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
    1326                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0);
    1327 
    1328                             SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
    1329 
    1330                             /* insert into 'available button' list */
    1331                             if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP))
    1332                             {
    1333                                 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
    1334                                 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1335                             }
    1336                             else
    1337                                 COMCTL32_Free (btnInfo);
    1338                         }
    1339                     }
    1340                     break;
    1341 
    1342                 case IDOK: /* Add button */
    1343                     {
    1344                         int index;
    1345                         int count;
    1346 
    1347                         count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
    1348                         index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0);
    1349                         TRACE("Add: index %d\n", index);
    1350 
    1351                         /* send TBN_QUERYINSERT notification */
    1352                         nmtb.hdr.hwndFrom = hwnd;
    1353                         nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1354                         nmtb.hdr.code     = TBN_QUERYINSERT;
    1355                         nmtb.iItem = index;
    1356 
    1357                         if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1358                                           (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1359                         {
    1360                             btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0);
    1361 
    1362                             if (index != 0)
    1363                             {
    1364                                 /* remove from 'available buttons' list */
    1365                                 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0);
    1366                                 if (index == count-1)
    1367                                     SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0);
    1368                                 else
    1369                                     SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0);
    1370                             }
    1371                             else
    1372                             {
    1373                                 PCUSTOMBUTTON btnNew;
    1374 
    1375                                 /* duplicate 'separator' button */
    1376                                 btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON));
    1377                                 memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON));
    1378                                 btnInfo = btnNew;
    1379                             }
    1380 
    1381                             /* insert into 'toolbar button' list */
    1382                             index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
    1383                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0);
    1384                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1385 
    1386                             SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn));
    1387                         }
    1388                     }
    1389                     break;
    1390 
    1391                 case IDCANCEL:
    1392                     EndDialog(hwnd, FALSE);
    1393                     break;
    1394             }
    1395             return TRUE;
    1396 
    1397         case WM_DESTROY:
    1398             {
    1399                 int count;
    1400                 int i;
    1401 
    1402                 /* delete items from 'toolbar buttons' listbox*/
    1403                 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
    1404                 for (i = 0; i < count; i++)
    1405                 {
    1406                     btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0);
    1407                     COMCTL32_Free(btnInfo);
    1408                     SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0);
    1409                 }
    1410                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0);
    1411 
    1412 
    1413                 /* delete items from 'available buttons' listbox*/
    1414                 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
    1415                 for (i = 0; i < count; i++)
    1416                 {
    1417                     btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0);
    1418                     COMCTL32_Free(btnInfo);
    1419                     SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0);
    1420                 }
    1421                 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0);
     1052    case WM_INITDIALOG:
     1053        custInfo = (PCUSTDLG_INFO)lParam;
     1054        SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo);
     1055
     1056        if (custInfo)
     1057        {
     1058        char Buffer[256];
     1059        int i = 0;
     1060        int index;
     1061
     1062        /* send TBN_QUERYINSERT notification */
     1063        nmtb.hdr.hwndFrom = hwnd;
     1064        nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1065        nmtb.hdr.code     = TBN_QUERYINSERT;
     1066        nmtb.iItem = custInfo->tbInfo->nNumButtons;
     1067
     1068        if (!SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
     1069                   (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
     1070            return FALSE;
     1071
     1072        /* add items to 'toolbar buttons' list and check if removable */
     1073        for (i = 0; i < custInfo->tbInfo->nNumButtons; i++)
     1074        {
     1075            btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
     1076            memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
     1077            btnInfo->btn.fsStyle = TBSTYLE_SEP;
     1078            btnInfo->bVirtual = FALSE;
     1079            LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
     1080
     1081            /* send TBN_QUERYDELETE notification */
     1082            nmtb.hdr.hwndFrom = hwnd;
     1083            nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1084            nmtb.hdr.code     = TBN_QUERYDELETE;
     1085            nmtb.iItem = i;
     1086
     1087            btnInfo->bRemovable = SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
     1088                            (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
     1089
     1090            index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0);
     1091            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1092        }
     1093
     1094        /* insert separator button into 'available buttons' list */
     1095        btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
     1096        memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
     1097        btnInfo->btn.fsStyle = TBSTYLE_SEP;
     1098        btnInfo->bVirtual = FALSE;
     1099        btnInfo->bRemovable = TRUE;
     1100        LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
     1101        index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
     1102        SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1103
     1104        /* insert all buttons into dsa */
     1105        for (i = 0;; i++)
     1106        {
     1107            /* send TBN_GETBUTTONINFO notification */
     1108            nmtb.hdr.hwndFrom = hwnd;
     1109            nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1110            nmtb.hdr.code     = TBN_GETBUTTONINFOA;
     1111            nmtb.iItem = i;
     1112            nmtb.pszText = Buffer;
     1113            nmtb.cchText = 256;
     1114
     1115            if (!SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
     1116                       (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
     1117            break;
     1118
     1119            TRACE("style: %x\n", nmtb.tbButton.fsStyle);
     1120
     1121            /* insert button into the apropriate list */
     1122            index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand);
     1123            if (index == -1)
     1124            {
     1125            btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
     1126            memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
     1127            btnInfo->bVirtual = FALSE;
     1128            btnInfo->bRemovable = TRUE;
     1129            if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
     1130                strcpy (btnInfo->text, nmtb.pszText);
     1131
     1132            index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
     1133            SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    14221134            }
    1423             return TRUE;
    1424 
    1425         case WM_DRAWITEM:
    1426             if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
    1427             {
    1428                 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
    1429                 RECT rcButton;
    1430                 RECT rcText;
    1431                 HPEN hOldPen;
    1432                 HBRUSH hOldBrush;
    1433                 COLORREF oldText = 0;
    1434                 COLORREF oldBk = 0;
    1435 
    1436                 /* get item data */
    1437                 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0);
    1438                 if (btnInfo == NULL)
    1439                 {
    1440                     FIXME("btnInfo invalid!\n");
    1441                     return TRUE;
    1442                 }
    1443 
    1444                 /* set colors and select objects */
    1445                 oldBk = SetBkColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
    1446                 if (btnInfo->bVirtual)
    1447                    oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_GRAYTEXT));
    1448                 else
    1449                    oldText = SetTextColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHTTEXT:COLOR_WINDOWTEXT));
    1450                 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
    1451                 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
    1452 
    1453                 /* fill background rectangle */
    1454                 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
    1455                            lpdis->rcItem.right, lpdis->rcItem.bottom);
    1456 
    1457                 /* calculate button and text rectangles */
    1458                 CopyRect (&rcButton, &lpdis->rcItem);
    1459                 InflateRect (&rcButton, -1, -1);
    1460                 CopyRect (&rcText, &rcButton);
    1461                 rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6;
    1462                 rcText.left = rcButton.right + 2;
    1463 
    1464                 /* draw focus rectangle */
    1465                 if (lpdis->itemState & ODS_FOCUS)
    1466                     DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
    1467 
    1468                 /* draw button */
    1469                 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
    1470 
    1471                 /* draw image and text */
    1472                 if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0)
    1473                     ImageList_Draw (custInfo->tbInfo->himlDef, btnInfo->btn.iBitmap, lpdis->hDC,
    1474                                     rcButton.left+3, rcButton.top+3, ILD_NORMAL);
    1475                 DrawTextA (lpdis->hDC,  btnInfo->text, -1, &rcText,
    1476                                DT_LEFT | DT_VCENTER | DT_SINGLELINE);
    1477 
    1478                 /* delete objects and reset colors */
    1479                 SelectObject (lpdis->hDC, hOldBrush);
    1480                 SelectObject (lpdis->hDC, hOldPen);
    1481                 SetBkColor (lpdis->hDC, oldBk);
    1482                 SetTextColor (lpdis->hDC, oldText);
    1483 
    1484                 return TRUE;
    1485             }
    1486             return FALSE;
    1487 
    1488         case WM_MEASUREITEM:
    1489             if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
    1490             {
    1491                 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
    1492 
    1493                 if (custInfo && custInfo->tbInfo)
    1494                     lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8;
    1495                 else
    1496                     lpmis->itemHeight = 15 + 8; /* default height */
    1497 
    1498                 return TRUE;
    1499             }
    1500             return FALSE;
    1501 
    1502         default:
    1503             return FALSE;
     1135            else
     1136            {
     1137            btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
     1138            memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
     1139            if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
     1140                strcpy (btnInfo->text, nmtb.pszText);
     1141
     1142            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1143            }
     1144        }
     1145
     1146        /* select first item in the 'available' list */
     1147        SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0);
     1148
     1149        /* append 'virtual' separator button to the 'toolbar buttons' list */
     1150        btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
     1151        memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
     1152        btnInfo->btn.fsStyle = TBSTYLE_SEP;
     1153        btnInfo->bVirtual = TRUE;
     1154        btnInfo->bRemovable = FALSE;
     1155        LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
     1156        index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
     1157        SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1158
     1159        /* select last item in the 'toolbar' list */
     1160        SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0);
     1161        SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0);
     1162
     1163        /* set focus and disable buttons */
     1164        PostMessageA (hwnd, WM_USER, 0, 0);
     1165        }
     1166        return TRUE;
     1167
     1168    case WM_USER:
     1169        EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
     1170        EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
     1171        EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE);
     1172        SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX));
     1173        return TRUE;
     1174
     1175    case WM_CLOSE:
     1176        EndDialog(hwnd, FALSE);
     1177        return TRUE;
     1178
     1179    case WM_COMMAND:
     1180        switch (LOWORD(wParam))
     1181        {
     1182        case IDC_TOOLBARBTN_LBOX:
     1183            if (HIWORD(wParam) == LBN_SELCHANGE)
     1184            {
     1185            PCUSTOMBUTTON btnInfo;
     1186            NMTOOLBARA nmtb;
     1187            int count;
     1188            int index;
     1189
     1190            count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
     1191            index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
     1192
     1193            /* send TBN_QUERYINSERT notification */
     1194            nmtb.hdr.hwndFrom = hwnd;
     1195            nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1196            nmtb.hdr.code     = TBN_QUERYINSERT;
     1197            nmtb.iItem = index;
     1198
     1199            SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
     1200                      (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
     1201
     1202            /* get list box item */
     1203            btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
     1204
     1205            if (index == (count - 1))
     1206            {
     1207                /* last item (virtual separator) */
     1208                EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
     1209                EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
     1210            }
     1211            else if (index == (count - 2))
     1212            {
     1213                /* second last item (last non-virtual item) */
     1214                EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
     1215                EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
     1216            }
     1217            else if (index == 0)
     1218            {
     1219                /* first item */
     1220                EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
     1221                EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
     1222            }
     1223            else
     1224            {
     1225                EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
     1226                EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
     1227            }
     1228
     1229            EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable);
     1230            }
     1231            break;
     1232
     1233        case IDC_MOVEUP_BTN:
     1234            {
     1235            PCUSTOMBUTTON btnInfo;
     1236            int index;
     1237            int count;
     1238
     1239            count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
     1240            index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
     1241            TRACE("Move up: index %d\n", index);
     1242
     1243            /* send TBN_QUERYINSERT notification */
     1244            nmtb.hdr.hwndFrom = hwnd;
     1245            nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1246            nmtb.hdr.code     = TBN_QUERYINSERT;
     1247            nmtb.iItem = index;
     1248
     1249            if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
     1250                      (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
     1251            {
     1252                btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
     1253
     1254                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
     1255                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0);
     1256                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo);
     1257                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0);
     1258
     1259                if (index <= 1)
     1260                EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
     1261                else if (index >= (count - 3))
     1262                EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
     1263
     1264                SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
     1265                SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn));
     1266            }
     1267            }
     1268            break;
     1269
     1270        case IDC_MOVEDN_BTN: /* move down */
     1271            {
     1272            PCUSTOMBUTTON btnInfo;
     1273            int index;
     1274            int count;
     1275
     1276            count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
     1277            index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
     1278            TRACE("Move up: index %d\n", index);
     1279
     1280            /* send TBN_QUERYINSERT notification */
     1281            nmtb.hdr.hwndFrom = hwnd;
     1282            nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1283            nmtb.hdr.code     = TBN_QUERYINSERT;
     1284            nmtb.iItem = index;
     1285
     1286            if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
     1287                      (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
     1288            {
     1289                btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
     1290
     1291                /* move button down */
     1292                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
     1293                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0);
     1294                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo);
     1295                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0);
     1296
     1297                if (index == 0)
     1298                EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
     1299                else if (index >= (count - 3))
     1300                EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
     1301
     1302                SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
     1303                SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn));
     1304            }
     1305            }
     1306            break;
     1307
     1308        case IDC_REMOVE_BTN: /* remove button */
     1309            {
     1310            PCUSTOMBUTTON btnInfo;
     1311            int index;
     1312
     1313            index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
     1314            TRACE("Remove: index %d\n", index);
     1315
     1316            /* send TBN_QUERYDELETE notification */
     1317            nmtb.hdr.hwndFrom = hwnd;
     1318            nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1319            nmtb.hdr.code     = TBN_QUERYDELETE;
     1320            nmtb.iItem = index;
     1321
     1322            if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
     1323                      (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
     1324            {
     1325                btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
     1326                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
     1327                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0);
     1328
     1329                SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
     1330
     1331                /* insert into 'available button' list */
     1332                if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP))
     1333                {
     1334                index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
     1335                SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1336                }
     1337                else
     1338                COMCTL32_Free (btnInfo);
     1339            }
     1340            }
     1341            break;
     1342
     1343        case IDOK: /* Add button */
     1344            {
     1345            int index;
     1346            int count;
     1347
     1348            count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
     1349            index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0);
     1350            TRACE("Add: index %d\n", index);
     1351
     1352            /* send TBN_QUERYINSERT notification */
     1353            nmtb.hdr.hwndFrom = hwnd;
     1354            nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1355            nmtb.hdr.code     = TBN_QUERYINSERT;
     1356            nmtb.iItem = index;
     1357
     1358            if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
     1359                      (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
     1360            {
     1361                btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0);
     1362
     1363                if (index != 0)
     1364                {
     1365                /* remove from 'available buttons' list */
     1366                SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0);
     1367                if (index == count-1)
     1368                    SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0);
     1369                else
     1370                    SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0);
     1371                }
     1372                else
     1373                {
     1374                PCUSTOMBUTTON btnNew;
     1375
     1376                /* duplicate 'separator' button */
     1377                btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON));
     1378                memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON));
     1379                btnInfo = btnNew;
     1380                }
     1381
     1382                /* insert into 'toolbar button' list */
     1383                index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
     1384                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0);
     1385                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1386
     1387                SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn));
     1388            }
     1389            }
     1390            break;
     1391
     1392        case IDCANCEL:
     1393            EndDialog(hwnd, FALSE);
     1394            break;
     1395        }
     1396        return TRUE;
     1397
     1398    case WM_DESTROY:
     1399        {
     1400        int count;
     1401        int i;
     1402
     1403        /* delete items from 'toolbar buttons' listbox*/
     1404        count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
     1405        for (i = 0; i < count; i++)
     1406        {
     1407            btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0);
     1408            COMCTL32_Free(btnInfo);
     1409            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0);
     1410        }
     1411        SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0);
     1412
     1413
     1414        /* delete items from 'available buttons' listbox*/
     1415        count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
     1416        for (i = 0; i < count; i++)
     1417        {
     1418            btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0);
     1419            COMCTL32_Free(btnInfo);
     1420            SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0);
     1421        }
     1422        SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0);
     1423            }
     1424        return TRUE;
     1425
     1426    case WM_DRAWITEM:
     1427        if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
     1428        {
     1429        LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
     1430        RECT rcButton;
     1431        RECT rcText;
     1432        HPEN hOldPen;
     1433        HBRUSH hOldBrush;
     1434        COLORREF oldText = 0;
     1435        COLORREF oldBk = 0;
     1436
     1437        /* get item data */
     1438        btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0);
     1439        if (btnInfo == NULL)
     1440        {
     1441            FIXME("btnInfo invalid!\n");
     1442            return TRUE;
     1443        }
     1444
     1445        /* set colors and select objects */
     1446        oldBk = SetBkColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
     1447        if (btnInfo->bVirtual)
     1448           oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_GRAYTEXT));
     1449        else
     1450           oldText = SetTextColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHTTEXT:COLOR_WINDOWTEXT));
     1451        hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
     1452        hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
     1453
     1454        /* fill background rectangle */
     1455        Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
     1456               lpdis->rcItem.right, lpdis->rcItem.bottom);
     1457
     1458        /* calculate button and text rectangles */
     1459        CopyRect (&rcButton, &lpdis->rcItem);
     1460        InflateRect (&rcButton, -1, -1);
     1461        CopyRect (&rcText, &rcButton);
     1462        rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6;
     1463        rcText.left = rcButton.right + 2;
     1464
     1465        /* draw focus rectangle */
     1466        if (lpdis->itemState & ODS_FOCUS)
     1467            DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
     1468
     1469        /* draw button */
     1470        DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
     1471
     1472        /* draw image and text */
     1473        if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0)
     1474            ImageList_Draw (custInfo->tbInfo->himlDef, btnInfo->btn.iBitmap, lpdis->hDC,
     1475                    rcButton.left+3, rcButton.top+3, ILD_NORMAL);
     1476        DrawTextA (lpdis->hDC,  btnInfo->text, -1, &rcText,
     1477                   DT_LEFT | DT_VCENTER | DT_SINGLELINE);
     1478
     1479        /* delete objects and reset colors */
     1480        SelectObject (lpdis->hDC, hOldBrush);
     1481        SelectObject (lpdis->hDC, hOldPen);
     1482        SetBkColor (lpdis->hDC, oldBk);
     1483        SetTextColor (lpdis->hDC, oldText);
     1484
     1485        return TRUE;
     1486        }
     1487        return FALSE;
     1488
     1489    case WM_MEASUREITEM:
     1490        if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
     1491        {
     1492        MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
     1493
     1494        if (custInfo && custInfo->tbInfo)
     1495            lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8;
     1496        else
     1497            lpmis->itemHeight = 15 + 8; /* default height */
     1498
     1499        return TRUE;
     1500        }
     1501        return FALSE;
     1502
     1503    default:
     1504        return FALSE;
    15041505    }
    15051506}
     
    15201521    TRACE("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam);
    15211522    if (!lpAddBmp)
    1522         return -1;
     1523    return -1;
    15231524
    15241525    if (lpAddBmp->hInst == HINST_COMMCTRL)
    15251526    {
    1526         if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
    1527             nButtons = 15;
    1528         else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
    1529             nButtons = 13;
    1530         else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
    1531             nButtons = 5;
    1532         else
    1533             return -1;
    1534 
    1535         TRACE ("adding %d internal bitmaps!\n", nButtons);
    1536 
    1537         /* Windows resize all the buttons to the size of a newly added standard image */
    1538         if (lpAddBmp->nID & 1)
    1539         {
    1540             /* large icons */
    1541             /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
    1542              * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this 
     1527    if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
     1528        nButtons = 15;
     1529    else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
     1530        nButtons = 13;
     1531    else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
     1532        nButtons = 5;
     1533    else
     1534        return -1;
     1535
     1536    TRACE ("adding %d internal bitmaps!\n", nButtons);
     1537
     1538    /* Windows resize all the buttons to the size of a newly added standard image */
     1539    if (lpAddBmp->nID & 1)
     1540    {
     1541        /* large icons */
     1542        /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
     1543             * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
    15431544             */
    1544             SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
    1545                           MAKELPARAM((WORD)24, (WORD)24));
    1546             SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
    1547                           MAKELPARAM((WORD)31, (WORD)30));
    1548         }       
    1549         else
    1550         {
    1551             /* small icons */
    1552             SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
    1553                           MAKELPARAM((WORD)16, (WORD)16));
    1554             SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
    1555                           MAKELPARAM((WORD)22, (WORD)22));
    1556         }
    1557        
    1558         TOOLBAR_CalcToolbar (hwnd);
     1545        SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
     1546              MAKELPARAM((WORD)24, (WORD)24));
     1547        SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
     1548              MAKELPARAM((WORD)31, (WORD)30));
    15591549    }
    15601550    else
    15611551    {
    1562         nButtons = (INT)wParam;
    1563         if (nButtons <= 0)
    1564             return -1;
    1565        
    1566         TRACE ("adding %d bitmaps!\n", nButtons);
    1567     }
    1568    
     1552        /* small icons */
     1553        SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
     1554              MAKELPARAM((WORD)16, (WORD)16));
     1555        SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
     1556              MAKELPARAM((WORD)22, (WORD)22));
     1557    }
     1558
     1559    TOOLBAR_CalcToolbar (hwnd);
     1560    }
     1561    else
     1562    {
     1563    nButtons = (INT)wParam;
     1564    if (nButtons <= 0)
     1565        return -1;
     1566
     1567    TRACE ("adding %d bitmaps!\n", nButtons);
     1568    }
     1569
    15691570    if (!(infoPtr->himlDef)) {
    1570         /* create new default image list */
    1571         TRACE ("creating default image list!\n");
    1572 
    1573         infoPtr->himlDef =
    1574             ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
    1575                               ILC_COLOR | ILC_MASK, nButtons, 2);
    1576         infoPtr->himlInt = infoPtr->himlDef;
     1571    /* create new default image list */
     1572    TRACE ("creating default image list!\n");
     1573
     1574    infoPtr->himlDef =
     1575        ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
     1576                  ILC_COLOR | ILC_MASK, nButtons, 2);
     1577    infoPtr->himlInt = infoPtr->himlDef;
    15771578    }
    15781579
     
    15821583    if (lpAddBmp->hInst == (HINSTANCE)0)
    15831584    {
    1584         nIndex =
    1585             ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
    1586                                 CLR_DEFAULT);
     1585    nIndex =
     1586        ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
     1587                CLR_DEFAULT);
    15871588    }
    15881589    else if (lpAddBmp->hInst == HINST_COMMCTRL)
    15891590    {
    1590         /* Add system bitmaps */
    1591         switch (lpAddBmp->nID)
    1592     {
    1593             case IDB_STD_SMALL_COLOR:
    1594                 hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1595                                        MAKEINTRESOURCEA(IDB_STD_SMALL));
    1596                 nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1597                                               hbmLoad, CLR_DEFAULT);
    1598                 DeleteObject (hbmLoad);
    1599                 break;
    1600 
    1601             case IDB_STD_LARGE_COLOR:
    1602                 hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1603                                        MAKEINTRESOURCEA(IDB_STD_LARGE));
    1604                 nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1605                                               hbmLoad, CLR_DEFAULT);
    1606                 DeleteObject (hbmLoad);
    1607                 break;
    1608 
    1609             case IDB_VIEW_SMALL_COLOR:
    1610                 hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1611                                        MAKEINTRESOURCEA(IDB_VIEW_SMALL));
    1612                 nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1613                                               hbmLoad, CLR_DEFAULT);
    1614                 DeleteObject (hbmLoad);
    1615                 break;
    1616 
    1617             case IDB_VIEW_LARGE_COLOR:
    1618                 hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1619                                        MAKEINTRESOURCEA(IDB_VIEW_LARGE));
    1620                 nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1621                                               hbmLoad, CLR_DEFAULT);
    1622                 DeleteObject (hbmLoad);
    1623                 break;
    1624 
    1625             case IDB_HIST_SMALL_COLOR:
    1626                 hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1627                                        MAKEINTRESOURCEA(IDB_HIST_SMALL));
    1628                 nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1629                                               hbmLoad, CLR_DEFAULT);
    1630                 DeleteObject (hbmLoad);
    1631                 break;
    1632 
    1633             case IDB_HIST_LARGE_COLOR:
    1634                 hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1635                                        MAKEINTRESOURCEA(IDB_HIST_LARGE));
    1636                 nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1637                                               hbmLoad, CLR_DEFAULT);
    1638                 DeleteObject (hbmLoad);
    1639                 break;
    1640 
    1641             default:
    1642         nIndex = ImageList_GetImageCount (infoPtr->himlDef);
    1643                 ERR ("invalid imagelist!\n");
    1644                 break;
    1645         }
     1591    /* Add system bitmaps */
     1592    switch (lpAddBmp->nID)
     1593    {
     1594        case IDB_STD_SMALL_COLOR:
     1595        hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1596                       MAKEINTRESOURCEA(IDB_STD_SMALL));
     1597        nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1598                          hbmLoad, CLR_DEFAULT);
     1599        DeleteObject (hbmLoad);
     1600        break;
     1601
     1602        case IDB_STD_LARGE_COLOR:
     1603        hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1604                       MAKEINTRESOURCEA(IDB_STD_LARGE));
     1605        nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1606                          hbmLoad, CLR_DEFAULT);
     1607        DeleteObject (hbmLoad);
     1608        break;
     1609
     1610        case IDB_VIEW_SMALL_COLOR:
     1611        hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1612                       MAKEINTRESOURCEA(IDB_VIEW_SMALL));
     1613        nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1614                          hbmLoad, CLR_DEFAULT);
     1615        DeleteObject (hbmLoad);
     1616        break;
     1617
     1618        case IDB_VIEW_LARGE_COLOR:
     1619        hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1620                       MAKEINTRESOURCEA(IDB_VIEW_LARGE));
     1621        nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1622                          hbmLoad, CLR_DEFAULT);
     1623        DeleteObject (hbmLoad);
     1624        break;
     1625
     1626        case IDB_HIST_SMALL_COLOR:
     1627        hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1628                       MAKEINTRESOURCEA(IDB_HIST_SMALL));
     1629        nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1630                          hbmLoad, CLR_DEFAULT);
     1631        DeleteObject (hbmLoad);
     1632        break;
     1633
     1634        case IDB_HIST_LARGE_COLOR:
     1635        hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1636                       MAKEINTRESOURCEA(IDB_HIST_LARGE));
     1637        nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1638                          hbmLoad, CLR_DEFAULT);
     1639        DeleteObject (hbmLoad);
     1640        break;
     1641
     1642        default:
     1643    nIndex = ImageList_GetImageCount (infoPtr->himlDef);
     1644        ERR ("invalid imagelist!\n");
     1645        break;
     1646    }
    16461647    }
    16471648    else
    16481649    {
    1649         hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
    1650         nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
    1651         DeleteObject (hbmLoad);
     1650    hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
     1651    nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
     1652    DeleteObject (hbmLoad);
    16521653    }
    16531654
     
    16591660       {
    16601661         WARN("Desired images do not match received images : Previous image number %i Previous images in list %i added %i expecting total %i, Images in list %i\n",
    1661               infoPtr->nNumBitmaps, nCount, imagecount - nCount,
    1662               infoPtr->nNumBitmaps+nButtons,imagecount);
    1663 
    1664         infoPtr->nNumBitmaps = imagecount;
     1662          infoPtr->nNumBitmaps, nCount, imagecount - nCount,
     1663          infoPtr->nNumBitmaps+nButtons,imagecount);
     1664
     1665    infoPtr->nNumBitmaps = imagecount;
    16651666       }
    16661667       else
     
    16881689
    16891690    if (infoPtr->nNumButtons == 0) {
    1690         infoPtr->buttons =
    1691             COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     1691    infoPtr->buttons =
     1692        COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    16921693    }
    16931694    else {
    1694         TBUTTON_INFO *oldButtons = infoPtr->buttons;
    1695         infoPtr->buttons =
    1696             COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    1697         memcpy (&infoPtr->buttons[0], &oldButtons[0],
    1698                 nOldButtons * sizeof(TBUTTON_INFO));
     1695    TBUTTON_INFO *oldButtons = infoPtr->buttons;
     1696    infoPtr->buttons =
     1697        COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     1698    memcpy (&infoPtr->buttons[0], &oldButtons[0],
     1699        nOldButtons * sizeof(TBUTTON_INFO));
    16991700        COMCTL32_Free (oldButtons);
    17001701    }
     
    17041705    /* insert new button data */
    17051706    for (nCount = 0; nCount < nAddButtons; nCount++) {
    1706         TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
    1707         btnPtr->iBitmap   = lpTbb[nCount].iBitmap;
    1708         btnPtr->idCommand = lpTbb[nCount].idCommand;
    1709         btnPtr->fsState   = lpTbb[nCount].fsState;
    1710         btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
    1711         btnPtr->dwData    = lpTbb[nCount].dwData;
    1712         btnPtr->iString   = lpTbb[nCount].iString;
    1713         btnPtr->bHot      = FALSE;
    1714 
    1715         if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
    1716             TTTOOLINFOA ti;
    1717 
    1718             ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    1719             ti.cbSize   = sizeof (TTTOOLINFOA);
    1720             ti.hwnd     = hwnd;
    1721             ti.uId      = btnPtr->idCommand;
    1722             ti.hinst    = 0;
    1723             ti.lpszText = LPSTR_TEXTCALLBACKA;
    1724 
    1725             SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
    1726                             0, (LPARAM)&ti);
    1727         }
     1707    TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
     1708    btnPtr->iBitmap   = lpTbb[nCount].iBitmap;
     1709    btnPtr->idCommand = lpTbb[nCount].idCommand;
     1710    btnPtr->fsState   = lpTbb[nCount].fsState;
     1711    btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
     1712    btnPtr->dwData    = lpTbb[nCount].dwData;
     1713    btnPtr->iString   = lpTbb[nCount].iString;
     1714    btnPtr->bHot      = FALSE;
     1715
     1716    if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
     1717        TTTOOLINFOA ti;
     1718
     1719        ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     1720        ti.cbSize   = sizeof (TTTOOLINFOA);
     1721        ti.hwnd     = hwnd;
     1722        ti.uId      = btnPtr->idCommand;
     1723        ti.hinst    = 0;
     1724        ti.lpszText = LPSTR_TEXTCALLBACKA;
     1725
     1726        SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
     1727                0, (LPARAM)&ti);
     1728    }
    17281729    }
    17291730
     
    17501751
    17511752    if (infoPtr->nNumButtons == 0) {
    1752         infoPtr->buttons =
    1753             COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     1753    infoPtr->buttons =
     1754        COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    17541755    }
    17551756    else {
    1756         TBUTTON_INFO *oldButtons = infoPtr->buttons;
    1757         infoPtr->buttons =
    1758             COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    1759         memcpy (&infoPtr->buttons[0], &oldButtons[0],
    1760                 nOldButtons * sizeof(TBUTTON_INFO));
     1757    TBUTTON_INFO *oldButtons = infoPtr->buttons;
     1758    infoPtr->buttons =
     1759        COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     1760    memcpy (&infoPtr->buttons[0], &oldButtons[0],
     1761        nOldButtons * sizeof(TBUTTON_INFO));
    17611762        COMCTL32_Free (oldButtons);
    17621763    }
     
    17661767    /* insert new button data */
    17671768    for (nCount = 0; nCount < nAddButtons; nCount++) {
    1768         TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
    1769         btnPtr->iBitmap   = lpTbb[nCount].iBitmap;
    1770         btnPtr->idCommand = lpTbb[nCount].idCommand;
    1771         btnPtr->fsState   = lpTbb[nCount].fsState;
    1772         btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
    1773         btnPtr->dwData    = lpTbb[nCount].dwData;
    1774         btnPtr->iString   = lpTbb[nCount].iString;
    1775         btnPtr->bHot      = FALSE;
    1776 
    1777         if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
    1778             TTTOOLINFOW ti;
    1779 
    1780             ZeroMemory (&ti, sizeof(TTTOOLINFOW));
    1781             ti.cbSize   = sizeof (TTTOOLINFOW);
    1782             ti.hwnd     = hwnd;
    1783             ti.uId      = btnPtr->idCommand;
    1784             ti.hinst    = 0;
    1785             ti.lpszText = LPSTR_TEXTCALLBACKW;
    1786 
    1787             SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
    1788                             0, (LPARAM)&ti);
    1789         }
     1769    TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
     1770    btnPtr->iBitmap   = lpTbb[nCount].iBitmap;
     1771    btnPtr->idCommand = lpTbb[nCount].idCommand;
     1772    btnPtr->fsState   = lpTbb[nCount].fsState;
     1773    btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
     1774    btnPtr->dwData    = lpTbb[nCount].dwData;
     1775    btnPtr->iString   = lpTbb[nCount].iString;
     1776    btnPtr->bHot      = FALSE;
     1777
     1778    if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
     1779        TTTOOLINFOW ti;
     1780
     1781        ZeroMemory (&ti, sizeof(TTTOOLINFOW));
     1782        ti.cbSize   = sizeof (TTTOOLINFOW);
     1783        ti.hwnd     = hwnd;
     1784        ti.uId      = btnPtr->idCommand;
     1785        ti.hinst    = 0;
     1786        ti.lpszText = LPSTR_TEXTCALLBACKW;
     1787
     1788        SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
     1789                0, (LPARAM)&ti);
     1790    }
    17901791    }
    17911792
     
    18051806
    18061807    if ((wParam) && (HIWORD(lParam) == 0)) {
    1807         char szString[256];
    1808         INT len, lenW;
    1809         TRACE("adding string from resource!\n");
    1810 
    1811         len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
    1812                              szString, 256);
    1813 
    1814         TRACE("len=%d \"%s\"\n", len, szString);
    1815         nIndex = infoPtr->nNumStrings;
    1816         if (infoPtr->nNumStrings == 0) {
    1817             infoPtr->strings =
    1818                 COMCTL32_Alloc (sizeof(LPWSTR));
    1819         }
    1820         else {
    1821             LPWSTR *oldStrings = infoPtr->strings;
    1822             infoPtr->strings =
    1823                 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    1824             memcpy (&infoPtr->strings[0], &oldStrings[0],
    1825                     sizeof(LPWSTR) * infoPtr->nNumStrings);
    1826             COMCTL32_Free (oldStrings);
    1827         }
     1808    char szString[256];
     1809    INT len, lenW;
     1810    TRACE("adding string from resource!\n");
     1811
     1812    len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
     1813                 szString, 256);
     1814
     1815    TRACE("len=%d \"%s\"\n", len, szString);
     1816    nIndex = infoPtr->nNumStrings;
     1817    if (infoPtr->nNumStrings == 0) {
     1818        infoPtr->strings =
     1819        COMCTL32_Alloc (sizeof(LPWSTR));
     1820    }
     1821    else {
     1822        LPWSTR *oldStrings = infoPtr->strings;
     1823        infoPtr->strings =
     1824        COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     1825        memcpy (&infoPtr->strings[0], &oldStrings[0],
     1826            sizeof(LPWSTR) * infoPtr->nNumStrings);
     1827        COMCTL32_Free (oldStrings);
     1828    }
    18281829
    18291830        lenW = MultiByteToWideChar( CP_ACP, 0, szString, -1, NULL, 0 );
     
    18311832        MultiByteToWideChar( CP_ACP, 0, szString, -1,
    18321833                             infoPtr->strings[infoPtr->nNumStrings], lenW );
    1833         infoPtr->nNumStrings++;
     1834    infoPtr->nNumStrings++;
    18341835    }
    18351836    else {
    1836         LPSTR p = (LPSTR)lParam;
    1837         INT len, lenW;
    1838 
    1839         if (p == NULL)
    1840             return -1;
    1841         TRACE("adding string(s) from array!\n");
    1842 
    1843         nIndex = infoPtr->nNumStrings;
    1844         while (*p) {
    1845             len = strlen (p);
    1846             TRACE("len=%d \"%s\"\n", len, p);
    1847 
    1848             if (infoPtr->nNumStrings == 0) {
    1849                 infoPtr->strings =
    1850                     COMCTL32_Alloc (sizeof(LPWSTR));
    1851             }
    1852             else {
    1853                 LPWSTR *oldStrings = infoPtr->strings;
    1854                 infoPtr->strings =
    1855                     COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    1856                 memcpy (&infoPtr->strings[0], &oldStrings[0],
    1857                         sizeof(LPWSTR) * infoPtr->nNumStrings);
    1858                 COMCTL32_Free (oldStrings);
    1859             }
     1837    LPSTR p = (LPSTR)lParam;
     1838    INT len, lenW;
     1839
     1840    if (p == NULL)
     1841        return -1;
     1842    TRACE("adding string(s) from array!\n");
     1843
     1844    nIndex = infoPtr->nNumStrings;
     1845    while (*p) {
     1846        len = strlen (p);
     1847        TRACE("len=%d \"%s\"\n", len, p);
     1848
     1849        if (infoPtr->nNumStrings == 0) {
     1850        infoPtr->strings =
     1851            COMCTL32_Alloc (sizeof(LPWSTR));
     1852        }
     1853        else {
     1854        LPWSTR *oldStrings = infoPtr->strings;
     1855        infoPtr->strings =
     1856            COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     1857        memcpy (&infoPtr->strings[0], &oldStrings[0],
     1858            sizeof(LPWSTR) * infoPtr->nNumStrings);
     1859        COMCTL32_Free (oldStrings);
     1860        }
    18601861
    18611862            lenW = MultiByteToWideChar( CP_ACP, 0, p, -1, NULL, 0 );
     
    18631864            MultiByteToWideChar( CP_ACP, 0, p, -1,
    18641865                                 infoPtr->strings[infoPtr->nNumStrings], lenW );
    1865             infoPtr->nNumStrings++;
    1866 
    1867             p += (len+1);
    1868         }
     1866        infoPtr->nNumStrings++;
     1867
     1868        p += (len+1);
     1869    }
    18691870    }
    18701871
     
    18811882
    18821883    if ((wParam) && (HIWORD(lParam) == 0)) {
    1883         WCHAR szString[MAX_RESOURCE_STRING_LENGTH];
    1884         INT len;
    1885         TRACE("adding string from resource!\n");
    1886 
    1887         len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
    1888                              szString, MAX_RESOURCE_STRING_LENGTH);
    1889 
    1890         TRACE("len=%d %s\n", len, debugstr_w(szString));
    1891         TRACE("First char: 0x%x\n", *szString);
    1892         if (szString[0] == L'|')
    1893         {
    1894             PWSTR p = szString + 1;
    1895                
    1896             nIndex = infoPtr->nNumStrings;
    1897             while (*p != L'|') {
    1898 
    1899             if (infoPtr->nNumStrings == 0) {
    1900                 infoPtr->strings =
    1901                     COMCTL32_Alloc (sizeof(LPWSTR));
    1902             }
    1903             else {
    1904                 LPWSTR *oldStrings = infoPtr->strings;
    1905                 infoPtr->strings =
    1906                     COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    1907                 memcpy (&infoPtr->strings[0], &oldStrings[0],
    1908                         sizeof(LPWSTR) * infoPtr->nNumStrings);
    1909                 COMCTL32_Free (oldStrings);
    1910             }
    1911 
    1912             len = COMCTL32_StrChrW (p, L'|') - p;
    1913             TRACE("len=%d %s\n", len, debugstr_w(p));
    1914             infoPtr->strings[infoPtr->nNumStrings] =
    1915                 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
    1916             lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len);
    1917             infoPtr->nNumStrings++;
    1918 
    1919                 p += (len+1);
    1920             }
    1921         }
    1922         else
    1923         {
     1884    WCHAR szString[MAX_RESOURCE_STRING_LENGTH];
     1885    INT len;
     1886    TRACE("adding string from resource!\n");
     1887
     1888    len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
     1889                 szString, MAX_RESOURCE_STRING_LENGTH);
     1890
     1891    TRACE("len=%d %s\n", len, debugstr_w(szString));
     1892    TRACE("First char: 0x%x\n", *szString);
     1893    if (szString[0] == L'|')
     1894    {
     1895        PWSTR p = szString + 1;
     1896
     1897        nIndex = infoPtr->nNumStrings;
     1898        while (*p != L'|') {
     1899
     1900        if (infoPtr->nNumStrings == 0) {
     1901        infoPtr->strings =
     1902            COMCTL32_Alloc (sizeof(LPWSTR));
     1903        }
     1904        else {
     1905        LPWSTR *oldStrings = infoPtr->strings;
     1906        infoPtr->strings =
     1907            COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     1908        memcpy (&infoPtr->strings[0], &oldStrings[0],
     1909            sizeof(LPWSTR) * infoPtr->nNumStrings);
     1910        COMCTL32_Free (oldStrings);
     1911        }
     1912
     1913        len = COMCTL32_StrChrW (p, L'|') - p;
     1914        TRACE("len=%d %s\n", len, debugstr_w(p));
     1915        infoPtr->strings[infoPtr->nNumStrings] =
     1916        COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
     1917        lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len);
     1918        infoPtr->nNumStrings++;
     1919
     1920        p += (len+1);
     1921        }
     1922    }
     1923    else
     1924    {
    19241925            nIndex = infoPtr->nNumStrings;
    19251926            if (infoPtr->nNumStrings == 0) {
     
    19431944    }
    19441945    else {
    1945         LPWSTR p = (LPWSTR)lParam;
    1946         INT len;
    1947 
    1948         if (p == NULL)
    1949             return -1;
    1950         TRACE("adding string(s) from array!\n");
    1951         nIndex = infoPtr->nNumStrings;
    1952         while (*p) {
    1953             len = strlenW (p);
    1954 
    1955             TRACE("len=%d %s\n", len, debugstr_w(p));
    1956             if (infoPtr->nNumStrings == 0) {
    1957                 infoPtr->strings =
    1958                     COMCTL32_Alloc (sizeof(LPWSTR));
    1959             }
    1960             else {
    1961                 LPWSTR *oldStrings = infoPtr->strings;
    1962                 infoPtr->strings =
    1963                     COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    1964                 memcpy (&infoPtr->strings[0], &oldStrings[0],
    1965                         sizeof(LPWSTR) * infoPtr->nNumStrings);
    1966                 COMCTL32_Free (oldStrings);
    1967             }
    1968 
    1969             infoPtr->strings[infoPtr->nNumStrings] =
    1970                 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
    1971             strcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
    1972             infoPtr->nNumStrings++;
    1973 
    1974             p += (len+1);
    1975         }
     1946    LPWSTR p = (LPWSTR)lParam;
     1947    INT len;
     1948
     1949    if (p == NULL)
     1950        return -1;
     1951    TRACE("adding string(s) from array!\n");
     1952    nIndex = infoPtr->nNumStrings;
     1953    while (*p) {
     1954        len = strlenW (p);
     1955
     1956        TRACE("len=%d %s\n", len, debugstr_w(p));
     1957        if (infoPtr->nNumStrings == 0) {
     1958        infoPtr->strings =
     1959            COMCTL32_Alloc (sizeof(LPWSTR));
     1960        }
     1961        else {
     1962        LPWSTR *oldStrings = infoPtr->strings;
     1963        infoPtr->strings =
     1964            COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     1965        memcpy (&infoPtr->strings[0], &oldStrings[0],
     1966            sizeof(LPWSTR) * infoPtr->nNumStrings);
     1967        COMCTL32_Free (oldStrings);
     1968        }
     1969
     1970        infoPtr->strings[infoPtr->nNumStrings] =
     1971        COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
     1972        strcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
     1973        infoPtr->nNumStrings++;
     1974
     1975        p += (len+1);
     1976    }
    19761977    }
    19771978
     
    20042005
    20052006    if (dwStyle & CCS_NORESIZE) {
    2006         uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
    2007         cx = 0;
    2008         cy = 0;
     2007    uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
     2008    cx = 0;
     2009    cy = 0;
    20092010    }
    20102011    else {
    2011         infoPtr->nWidth = parent_rect.right - parent_rect.left;
    2012         TOOLBAR_CalcToolbar (hwnd);
    2013         InvalidateRect( hwnd, NULL, TRUE );
    2014         cy = infoPtr->nHeight;
    2015         cx = infoPtr->nWidth;
    2016 
    2017         if (dwStyle & CCS_NOMOVEY) {
    2018                 GetWindowRect(hwnd, &window_rect);
    2019                 ScreenToClient(parent, (LPPOINT)&window_rect.left);
    2020                 y = window_rect.top;
    2021         }
     2012    infoPtr->nWidth = parent_rect.right - parent_rect.left;
     2013    TOOLBAR_CalcToolbar (hwnd);
     2014    InvalidateRect( hwnd, NULL, TRUE );
     2015    cy = infoPtr->nHeight;
     2016    cx = infoPtr->nWidth;
     2017
     2018    if (dwStyle & CCS_NOMOVEY) {
     2019        GetWindowRect(hwnd, &window_rect);
     2020        ScreenToClient(parent, (LPPOINT)&window_rect.left);
     2021        y = window_rect.top;
     2022    }
    20222023    }
    20232024
    20242025    if (dwStyle & CCS_NOPARENTALIGN)
    2025         uPosFlags |= SWP_NOMOVE;
     2026    uPosFlags |= SWP_NOMOVE;
    20262027
    20272028    if (!(dwStyle & CCS_NODIVIDER))
    2028         cy += GetSystemMetrics(SM_CYEDGE);
     2029    cy += GetSystemMetrics(SM_CYEDGE);
    20292030
    20302031    if (dwStyle & WS_BORDER)
     
    20612062
    20622063    if (infoPtr == NULL) {
    2063         ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
    2064         ERR("infoPtr == NULL!\n");
    2065         return 0;
     2064    ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
     2065    ERR("infoPtr == NULL!\n");
     2066    return 0;
    20662067    }
    20672068
     
    20812082    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    20822083    if (nIndex == -1)
    2083         return FALSE;
     2084    return FALSE;
    20842085
    20852086    btnPtr = &infoPtr->buttons[nIndex];
     
    21052106    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    21062107    if (nIndex == -1)
    2107         return FALSE;
     2108    return FALSE;
    21082109
    21092110    btnPtr = &infoPtr->buttons[nIndex];
    21102111
    21112112    if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
    2112         return FALSE;
     2113    return FALSE;
    21132114
    21142115    bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE;
    21152116
    21162117    if (LOWORD(lParam) == FALSE)
    2117         btnPtr->fsState &= ~TBSTATE_CHECKED;
     2118    btnPtr->fsState &= ~TBSTATE_CHECKED;
    21182119    else {
    2119         if (btnPtr->fsStyle & TBSTYLE_GROUP) {
    2120             nOldIndex =
    2121                 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
    2122             if (nOldIndex == nIndex)
    2123                 return 0;
    2124             if (nOldIndex != -1)
    2125                 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
    2126         }
    2127         btnPtr->fsState |= TBSTATE_CHECKED;
     2120    if (btnPtr->fsStyle & TBSTYLE_GROUP) {
     2121        nOldIndex =
     2122        TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
     2123        if (nOldIndex == nIndex)
     2124        return 0;
     2125        if (nOldIndex != -1)
     2126        infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
     2127    }
     2128    btnPtr->fsState |= TBSTATE_CHECKED;
    21282129    }
    21292130
    21302131    if( bChecked != LOWORD(lParam) )
    21312132    {
    2132         if (nOldIndex != -1)
     2133    if (nOldIndex != -1)
    21332134        {
    21342135            InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
     
    21712172
    21722173    SendMessageA (custInfo.tbInfo->hwndNotify, WM_NOTIFY,
    2173                   (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
     2174          (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
    21742175
    21752176    if (!(hRes = FindResourceA (COMCTL32_hModule,
    21762177                                MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
    21772178                                RT_DIALOGA)))
    2178         return FALSE;
     2179    return FALSE;
    21792180
    21802181    if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
    2181         return FALSE;
     2182    return FALSE;
    21822183
    21832184    ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
     
    21902191    nmhdr.code = TBN_ENDADJUST;
    21912192    SendMessageA (custInfo.tbInfo->hwndNotify, WM_NOTIFY,
    2192                   (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
     2193          (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
    21932194
    21942195    return ret;
     
    22032204
    22042205    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    2205         return FALSE;
    2206 
    2207     if ((infoPtr->hwndToolTip) && 
    2208         !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
    2209         TTTOOLINFOA ti;
    2210 
    2211         ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    2212         ti.cbSize   = sizeof (TTTOOLINFOA);
    2213         ti.hwnd     = hwnd;
    2214         ti.uId      = infoPtr->buttons[nIndex].idCommand;
    2215 
    2216         SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
     2206    return FALSE;
     2207
     2208    if ((infoPtr->hwndToolTip) &&
     2209    !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
     2210    TTTOOLINFOA ti;
     2211
     2212    ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     2213    ti.cbSize   = sizeof (TTTOOLINFOA);
     2214    ti.hwnd     = hwnd;
     2215    ti.uId      = infoPtr->buttons[nIndex].idCommand;
     2216
     2217    SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
    22172218    }
    22182219
    22192220    if (infoPtr->nNumButtons == 1) {
    2220         TRACE(" simple delete!\n");
    2221         COMCTL32_Free (infoPtr->buttons);
    2222         infoPtr->buttons = NULL;
    2223         infoPtr->nNumButtons = 0;
     2221    TRACE(" simple delete!\n");
     2222    COMCTL32_Free (infoPtr->buttons);
     2223    infoPtr->buttons = NULL;
     2224    infoPtr->nNumButtons = 0;
    22242225    }
    22252226    else {
    2226         TBUTTON_INFO *oldButtons = infoPtr->buttons;
     2227    TBUTTON_INFO *oldButtons = infoPtr->buttons;
    22272228        TRACE("complex delete! [nIndex=%d]\n", nIndex);
    22282229
    2229         infoPtr->nNumButtons--;
    2230         infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
     2230    infoPtr->nNumButtons--;
     2231    infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
    22312232        if (nIndex > 0) {
    22322233            memcpy (&infoPtr->buttons[0], &oldButtons[0],
     
    22392240        }
    22402241
    2241         COMCTL32_Free (oldButtons);
     2242    COMCTL32_Free (oldButtons);
    22422243    }
    22432244
     
    22602261    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    22612262    if (nIndex == -1)
    2262         return FALSE;
     2263    return FALSE;
    22632264
    22642265    btnPtr = &infoPtr->buttons[nIndex];
     
    22682269    /* update the toolbar button state */
    22692270    if(LOWORD(lParam) == FALSE) {
    2270         btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
     2271    btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
    22712272    } else {
    2272         btnPtr->fsState |= TBSTATE_ENABLED;
     2273    btnPtr->fsState |= TBSTATE_ENABLED;
    22732274    }
    22742275
     
    23012302    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    23022303    if (nIndex == -1)
    2303         return -1;
     2304    return -1;
    23042305
    23052306    return infoPtr->buttons[nIndex].iBitmap;
     
    23232324
    23242325    if (infoPtr == NULL)
    2325         return FALSE;
     2326    return FALSE;
    23262327
    23272328    if (lpTbb == NULL)
    2328         return FALSE;
     2329    return FALSE;
    23292330
    23302331    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    2331         return FALSE;
     2332    return FALSE;
    23322333
    23332334    btnPtr = &infoPtr->buttons[nIndex];
     
    23522353
    23532354    if (infoPtr == NULL)
    2354         return -1;
     2355    return -1;
    23552356    if (lpTbInfo == NULL)
    2356         return -1;
     2357    return -1;
    23572358    if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
    2358         return -1;
     2359    return -1;
    23592360
    23602361    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    23612362    if (nIndex == -1)
    2362         return -1;
     2363    return -1;
    23632364
    23642365    btnPtr = &infoPtr->buttons[nIndex];
    23652366
    23662367    if (lpTbInfo->dwMask & TBIF_COMMAND)
    2367         lpTbInfo->idCommand = btnPtr->idCommand;
     2368    lpTbInfo->idCommand = btnPtr->idCommand;
    23682369    if (lpTbInfo->dwMask & TBIF_IMAGE)
    2369         lpTbInfo->iImage = btnPtr->iBitmap;
     2370    lpTbInfo->iImage = btnPtr->iBitmap;
    23702371    if (lpTbInfo->dwMask & TBIF_LPARAM)
    2371         lpTbInfo->lParam = btnPtr->dwData;
     2372    lpTbInfo->lParam = btnPtr->dwData;
    23722373    if (lpTbInfo->dwMask & TBIF_SIZE)
    2373         lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
     2374    lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
    23742375    if (lpTbInfo->dwMask & TBIF_STATE)
    2375         lpTbInfo->fsState = btnPtr->fsState;
     2376    lpTbInfo->fsState = btnPtr->fsState;
    23762377    if (lpTbInfo->dwMask & TBIF_STYLE)
    2377         lpTbInfo->fsStyle = btnPtr->fsStyle;
     2378    lpTbInfo->fsStyle = btnPtr->fsStyle;
    23782379     if (lpTbInfo->dwMask & TBIF_TEXT) {
    23792380         if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
    2380          {     
     2381         {
    23812382             if (!WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[btnPtr->iString], -1,
    23822383                                       lpTbInfo->pszText, lpTbInfo->cchText, NULL, NULL ))
     
    23982399
    23992400    if (infoPtr == NULL)
    2400         return -1;
     2401    return -1;
    24012402    if (lpTbInfo == NULL)
    2402         return -1;
     2403    return -1;
    24032404    if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
    2404         return -1;
     2405    return -1;
    24052406
    24062407    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    24072408    if (nIndex == -1)
    2408         return -1;
     2409    return -1;
    24092410
    24102411    btnPtr = &infoPtr->buttons[nIndex];
    24112412
    24122413    if (lpTbInfo->dwMask & TBIF_COMMAND)
    2413         lpTbInfo->idCommand = btnPtr->idCommand;
     2414    lpTbInfo->idCommand = btnPtr->idCommand;
    24142415    if (lpTbInfo->dwMask & TBIF_IMAGE)
    2415         lpTbInfo->iImage = btnPtr->iBitmap;
     2416    lpTbInfo->iImage = btnPtr->iBitmap;
    24162417    if (lpTbInfo->dwMask & TBIF_LPARAM)
    2417         lpTbInfo->lParam = btnPtr->dwData;
     2418    lpTbInfo->lParam = btnPtr->dwData;
    24182419    if (lpTbInfo->dwMask & TBIF_SIZE)
    2419         lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
     2420    lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
    24202421    if (lpTbInfo->dwMask & TBIF_STATE)
    2421         lpTbInfo->fsState = btnPtr->fsState;
     2422    lpTbInfo->fsState = btnPtr->fsState;
    24222423    if (lpTbInfo->dwMask & TBIF_STYLE)
    2423         lpTbInfo->fsStyle = btnPtr->fsStyle;
     2424    lpTbInfo->fsStyle = btnPtr->fsStyle;
    24242425    if (lpTbInfo->dwMask & TBIF_TEXT) {
    2425         if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
    2426             lstrcpynW (lpTbInfo->pszText,
    2427                        (LPWSTR)infoPtr->strings[btnPtr->iString],
    2428                        lpTbInfo->cchText);
     2426    if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
     2427        lstrcpynW (lpTbInfo->pszText,
     2428               (LPWSTR)infoPtr->strings[btnPtr->iString],
     2429               lpTbInfo->cchText);
    24292430    }
    24302431
     
    24392440
    24402441    return MAKELONG((WORD)infoPtr->nButtonWidth,
    2441                     (WORD)infoPtr->nButtonHeight);
     2442            (WORD)infoPtr->nButtonHeight);
    24422443}
    24432444
     
    24512452    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    24522453    if (nIndex == -1)
    2453         return -1;
     2454    return -1;
    24542455
    24552456    nStringIndex = infoPtr->buttons[nIndex].iString;
     
    24582459
    24592460    if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
    2460         return -1;
     2461    return -1;
    24612462
    24622463    if (lParam == 0)
    2463         return -1;
     2464    return -1;
    24642465
    24652466    return WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[nStringIndex], -1,
     
    24762477    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    24772478    if (nIndex == -1)
    2478         return -1;
     2479    return -1;
    24792480
    24802481    nStringIndex = infoPtr->buttons[nIndex].iString;
     
    24832484
    24842485    if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
    2485         return -1;
     2486    return -1;
    24862487
    24872488    if (lParam == 0)
    2488         return -1;
     2489    return -1;
    24892490
    24902491    strcpyW ((LPWSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]);
     
    25302531
    25312532    if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
    2532         return -1;
     2533    return -1;
    25332534
    25342535    if (infoPtr->nHotItem < 0)
    2535         return -1;
     2536    return -1;
    25362537
    25372538    return (LRESULT)infoPtr->nHotItem;
     
    25612562
    25622563    if (infoPtr == NULL)
    2563         return FALSE;
     2564    return FALSE;
    25642565    nIndex = (INT)wParam;
    25652566    btnPtr = &infoPtr->buttons[nIndex];
    25662567    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    2567         return FALSE;
     2568    return FALSE;
    25682569    lpRect = (LPRECT)lParam;
    25692570    if (lpRect == NULL)
    2570         return FALSE;
     2571    return FALSE;
    25712572    if (btnPtr->fsState & TBSTATE_HIDDEN)
    2572         return FALSE;
    2573    
     2573    return FALSE;
     2574
    25742575    lpRect->left   = btnPtr->rect.left;
    25752576    lpRect->right  = btnPtr->rect.right;
     
    25882589
    25892590    if (lpSize == NULL)
    2590         return FALSE;
     2591    return FALSE;
    25912592
    25922593    lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
     
    25942595
    25952596    TRACE("maximum size %d x %d\n",
    2596            infoPtr->rcBound.right - infoPtr->rcBound.left,
    2597            infoPtr->rcBound.bottom - infoPtr->rcBound.top);
     2597       infoPtr->rcBound.right - infoPtr->rcBound.left,
     2598       infoPtr->rcBound.bottom - infoPtr->rcBound.top);
    25982599
    25992600    return TRUE;
     
    26142615
    26152616    if (infoPtr == NULL)
    2616         return FALSE;
     2617    return FALSE;
    26172618    nIndex = (INT)wParam;
    26182619    btnPtr = &infoPtr->buttons[nIndex];
    26192620    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    2620         return FALSE;
     2621    return FALSE;
    26212622    lpRect = (LPRECT)lParam;
    26222623    if (lpRect == NULL)
    2623         return FALSE;
    2624    
     2624    return FALSE;
     2625
    26252626    lpRect->left   = btnPtr->rect.left;
    26262627    lpRect->right  = btnPtr->rect.right;
     
    26382639
    26392640    if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
    2640         return infoPtr->nRows;
     2641    return infoPtr->nRows;
    26412642    else
    2642         return 1;
     2643    return 1;
    26432644}
    26442645
     
    26522653    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    26532654    if (nIndex == -1)
    2654         return -1;
     2655    return -1;
    26552656
    26562657    return infoPtr->buttons[nIndex].fsState;
     
    26662667    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    26672668    if (nIndex == -1)
    2668         return -1;
     2669    return -1;
    26692670
    26702671    return infoPtr->buttons[nIndex].fsStyle;
     
    26782679
    26792680    if (infoPtr == NULL)
    2680         return 0;
     2681    return 0;
    26812682
    26822683    return infoPtr->nMaxTextRows;
     
    26902691
    26912692    if (infoPtr == NULL)
    2692         return 0;
     2693    return 0;
    26932694    return infoPtr->hwndToolTip;
    26942695}
     
    27002701    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    27012702
    2702     TRACE("%s hwnd=0x%x stub!\n", 
    2703            infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
     2703    TRACE("%s hwnd=0x%x stub!\n",
     2704       infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
    27042705
    27052706    return infoPtr->bUnicode;
     
    27262727    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    27272728    if (nIndex == -1)
    2728         return FALSE;
     2729    return FALSE;
    27292730
    27302731    btnPtr = &infoPtr->buttons[nIndex];
    27312732    if (LOWORD(lParam) == FALSE)
    2732         btnPtr->fsState &= ~TBSTATE_HIDDEN;
     2733    btnPtr->fsState &= ~TBSTATE_HIDDEN;
    27332734    else
    2734         btnPtr->fsState |= TBSTATE_HIDDEN;
     2735    btnPtr->fsState |= TBSTATE_HIDDEN;
    27352736
    27362737    TOOLBAR_CalcToolbar (hwnd);
     
    27582759    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    27592760    if (nIndex == -1)
    2760         return FALSE;
     2761    return FALSE;
    27612762
    27622763    btnPtr = &infoPtr->buttons[nIndex];
    27632764    if (LOWORD(lParam) == FALSE)
    2764         btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
     2765    btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
    27652766    else
    2766         btnPtr->fsState |= TBSTATE_INDETERMINATE;
     2767    btnPtr->fsState |= TBSTATE_INDETERMINATE;
    27672768
    27682769    InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
     
    27812782
    27822783    if (lpTbb == NULL)
    2783         return FALSE;
     2784    return FALSE;
    27842785
    27852786    if (nIndex == -1) {
    27862787       /* EPP: this seems to be an undocumented call (from my IE4)
    2787         * I assume in that case that:
    2788         * - lpTbb->iString is a string pointer (not a string index in strings[] table
    2789         * - index of insertion is at the end of existing buttons
    2790         * I only see this happen with nIndex == -1, but it could have a special
    2791         * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
    2792         */
    2793        int      len;
    2794        LPSTR    ptr;
     2788    * I assume in that case that:
     2789    * - lpTbb->iString is a string pointer (not a string index in strings[] table
     2790    * - index of insertion is at the end of existing buttons
     2791    * I only see this happen with nIndex == -1, but it could have a special
     2792    * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
     2793    */
     2794       int  len;
     2795       LPSTR    ptr;
    27952796
    27962797       /* FIXME: iString == -1 is undocumented */
     
    28142815    TRACE("inserting button index=%d\n", nIndex);
    28152816    if (nIndex > infoPtr->nNumButtons) {
    2816         nIndex = infoPtr->nNumButtons;
    2817         TRACE("adjust index=%d\n", nIndex);
     2817    nIndex = infoPtr->nNumButtons;
     2818    TRACE("adjust index=%d\n", nIndex);
    28182819    }
    28192820
     
    28232824    /* pre insert copy */
    28242825    if (nIndex > 0) {
    2825         memcpy (&infoPtr->buttons[0], &oldButtons[0],
    2826                 nIndex * sizeof(TBUTTON_INFO));
     2826    memcpy (&infoPtr->buttons[0], &oldButtons[0],
     2827        nIndex * sizeof(TBUTTON_INFO));
    28272828    }
    28282829
     
    28362837
    28372838    if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
    2838         TTTOOLINFOA ti;
    2839 
    2840         ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    2841         ti.cbSize   = sizeof (TTTOOLINFOA);
    2842         ti.hwnd     = hwnd;
    2843         ti.uId      = lpTbb->idCommand;
    2844         ti.hinst    = 0;
    2845         ti.lpszText = LPSTR_TEXTCALLBACKA;
    2846 
    2847         SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
    2848                         0, (LPARAM)&ti);
     2839    TTTOOLINFOA ti;
     2840
     2841    ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     2842    ti.cbSize   = sizeof (TTTOOLINFOA);
     2843    ti.hwnd     = hwnd;
     2844    ti.uId      = lpTbb->idCommand;
     2845    ti.hinst    = 0;
     2846    ti.lpszText = LPSTR_TEXTCALLBACKA;
     2847
     2848    SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
     2849            0, (LPARAM)&ti);
    28492850    }
    28502851
    28512852    /* post insert copy */
    28522853    if (nIndex < infoPtr->nNumButtons - 1) {
    2853         memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
    2854                 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
     2854    memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
     2855        (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
    28552856    }
    28562857
     
    28742875
    28752876    if (lpTbb == NULL)
    2876         return FALSE;
     2877    return FALSE;
    28772878    if (nIndex < 0)
    2878         return FALSE;
     2879    return FALSE;
    28792880
    28802881    TRACE("inserting button index=%d\n", nIndex);
    28812882    if (nIndex > infoPtr->nNumButtons) {
    2882         nIndex = infoPtr->nNumButtons;
    2883         TRACE("adjust index=%d\n", nIndex);
     2883    nIndex = infoPtr->nNumButtons;
     2884    TRACE("adjust index=%d\n", nIndex);
    28842885    }
    28852886
     
    28892890    /* pre insert copy */
    28902891    if (nIndex > 0) {
    2891         memcpy (&infoPtr->buttons[0], &oldButtons[0],
    2892                 nIndex * sizeof(TBUTTON_INFO));
     2892    memcpy (&infoPtr->buttons[0], &oldButtons[0],
     2893        nIndex * sizeof(TBUTTON_INFO));
    28932894    }
    28942895
     
    29022903
    29032904    if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
    2904         TTTOOLINFOW ti;
    2905 
    2906         ZeroMemory (&ti, sizeof(TTTOOLINFOW));
    2907         ti.cbSize   = sizeof (TTTOOLINFOW);
    2908         ti.hwnd     = hwnd;
    2909         ti.uId      = lpTbb->idCommand;
    2910         ti.hinst    = 0;
    2911         ti.lpszText = LPSTR_TEXTCALLBACKW;
    2912 
    2913         SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
    2914                         0, (LPARAM)&ti);
     2905    TTTOOLINFOW ti;
     2906
     2907    ZeroMemory (&ti, sizeof(TTTOOLINFOW));
     2908    ti.cbSize   = sizeof (TTTOOLINFOW);
     2909    ti.hwnd     = hwnd;
     2910    ti.uId      = lpTbb->idCommand;
     2911    ti.hinst    = 0;
     2912    ti.lpszText = LPSTR_TEXTCALLBACKW;
     2913
     2914    SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
     2915            0, (LPARAM)&ti);
    29152916    }
    29162917
    29172918    /* post insert copy */
    29182919    if (nIndex < infoPtr->nNumButtons - 1) {
    2919         memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
    2920                 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
     2920    memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
     2921        (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
    29212922    }
    29222923
     
    29402941    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    29412942    if (nIndex == -1)
    2942         return FALSE;
     2943    return FALSE;
    29432944
    29442945    return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
     
    29542955    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    29552956    if (nIndex == -1)
    2956         return FALSE;
     2957    return FALSE;
    29572958
    29582959    return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
     
    29682969    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    29692970    if (nIndex == -1)
    2970         return TRUE;
     2971    return TRUE;
    29712972
    29722973    return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
     
    29822983    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    29832984    if (nIndex == -1)
    2984         return FALSE;
     2985    return FALSE;
    29852986
    29862987    return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
     
    29962997    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    29972998    if (nIndex == -1)
    2998         return FALSE;
     2999    return FALSE;
    29993000
    30003001    return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
     
    30103011    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    30113012    if (nIndex == -1)
    3012         return FALSE;
     3013    return FALSE;
    30133014
    30143015    return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
     
    30313032    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    30323033    if (nIndex == -1)
    3033         return FALSE;
     3034    return FALSE;
    30343035
    30353036    btnPtr = &infoPtr->buttons[nIndex];
    30363037    if (LOWORD(lParam) == FALSE)
    3037         btnPtr->fsState &= ~TBSTATE_PRESSED;
     3038    btnPtr->fsState &= ~TBSTATE_PRESSED;
    30383039    else
    3039         btnPtr->fsState |= TBSTATE_PRESSED;
     3040    btnPtr->fsState |= TBSTATE_PRESSED;
    30403041
    30413042    InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
     
    30583059
    30593060    if ((BOOL)wParam) {
    3060         /* save toolbar information */
    3061         FIXME("save to \"%s\" \"%s\"\n",
    3062                lpSave->pszSubKey, lpSave->pszValueName);
     3061    /* save toolbar information */
     3062    FIXME("save to \"%s\" \"%s\"\n",
     3063           lpSave->pszSubKey, lpSave->pszValueName);
    30633064
    30643065
    30653066    }
    30663067    else {
    3067         /* restore toolbar information */
    3068 
    3069         FIXME("restore from \"%s\" \"%s\"\n",
    3070                lpSave->pszSubKey, lpSave->pszValueName);
     3068    /* restore toolbar information */
     3069
     3070    FIXME("restore from \"%s\" \"%s\"\n",
     3071           lpSave->pszSubKey, lpSave->pszValueName);
    30713072
    30723073
     
    30863087
    30873088    if (lpSave == NULL)
    3088         return 0;
     3089    return 0;
    30893090
    30903091    if ((BOOL)wParam) {
    3091         /* save toolbar information */
    3092         FIXME("save to \"%s\" \"%s\"\n",
    3093                lpSave->pszSubKey, lpSave->pszValueName);
     3092    /* save toolbar information */
     3093    FIXME("save to \"%s\" \"%s\"\n",
     3094           lpSave->pszSubKey, lpSave->pszValueName);
    30943095
    30953096
    30963097    }
    30973098    else {
    3098         /* restore toolbar information */
    3099 
    3100         FIXME("restore from \"%s\" \"%s\"\n",
    3101                lpSave->pszSubKey, lpSave->pszValueName);
     3099    /* restore toolbar information */
     3100
     3101    FIXME("restore from \"%s\" \"%s\"\n",
     3102           lpSave->pszSubKey, lpSave->pszValueName);
    31023103
    31033104
     
    31273128
    31283129    if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
    3129         return FALSE;
     3130    return FALSE;
    31303131
    31313132    if (infoPtr->nNumButtons > 0)
     
    31573158
    31583159    if (lptbbi == NULL)
    3159         return FALSE;
     3160    return FALSE;
    31603161    if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
    3161         return FALSE;
    3162    
     3162    return FALSE;
     3163
    31633164    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    31643165    if (nIndex == -1)
    3165         return FALSE;
     3166    return FALSE;
    31663167
    31673168    btnPtr = &infoPtr->buttons[nIndex];
    31683169    if (lptbbi->dwMask & TBIF_COMMAND)
    3169         btnPtr->idCommand = lptbbi->idCommand;
     3170    btnPtr->idCommand = lptbbi->idCommand;
    31703171    if (lptbbi->dwMask & TBIF_IMAGE)
    3171         btnPtr->iBitmap = lptbbi->iImage;
     3172    btnPtr->iBitmap = lptbbi->iImage;
    31723173    if (lptbbi->dwMask & TBIF_LPARAM)
    3173         btnPtr->dwData = lptbbi->lParam;
     3174    btnPtr->dwData = lptbbi->lParam;
    31743175/*    if (lptbbi->dwMask & TBIF_SIZE) */
    3175 /*      btnPtr->cx = lptbbi->cx; */
     3176/*  btnPtr->cx = lptbbi->cx; */
    31763177    if (lptbbi->dwMask & TBIF_STATE)
    3177         btnPtr->fsState = lptbbi->fsState;
     3178    btnPtr->fsState = lptbbi->fsState;
    31783179    if (lptbbi->dwMask & TBIF_STYLE)
    3179         btnPtr->fsStyle = lptbbi->fsStyle;
     3180    btnPtr->fsStyle = lptbbi->fsStyle;
    31803181
    31813182    if (lptbbi->dwMask & TBIF_TEXT) {
    3182         if ((btnPtr->iString >= 0) ||
    3183             (btnPtr->iString < infoPtr->nNumStrings)) {
    3184            TRACE("Ooooooch\n");
     3183    if ((btnPtr->iString >= 0) ||
     3184        (btnPtr->iString < infoPtr->nNumStrings)) {
     3185       TRACE("Ooooooch\n");
    31853186#if 0
    3186             WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
    3187             INT len = lstrlenA (lptbbi->pszText);
    3188             *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
     3187        WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
     3188        INT len = lstrlenA (lptbbi->pszText);
     3189        *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
    31893190#endif
    31903191
    3191             /* this is the ultimate sollution */
    3192 /*          Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
    3193         }
     3192        /* this is the ultimate sollution */
     3193/*      Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
     3194    }
    31943195    }
    31953196
     
    32073208
    32083209    if (lptbbi == NULL)
    3209         return FALSE;
     3210    return FALSE;
    32103211    if (lptbbi->cbSize < sizeof(TBBUTTONINFOW))
    3211         return FALSE;
     3212    return FALSE;
    32123213
    32133214    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    32143215    if (nIndex == -1)
    3215         return FALSE;
     3216    return FALSE;
    32163217
    32173218    btnPtr = &infoPtr->buttons[nIndex];
    32183219    if (lptbbi->dwMask & TBIF_COMMAND)
    3219         btnPtr->idCommand = lptbbi->idCommand;
     3220    btnPtr->idCommand = lptbbi->idCommand;
    32203221    if (lptbbi->dwMask & TBIF_IMAGE)
    3221         btnPtr->iBitmap = lptbbi->iImage;
     3222    btnPtr->iBitmap = lptbbi->iImage;
    32223223    if (lptbbi->dwMask & TBIF_LPARAM)
    3223         btnPtr->dwData = lptbbi->lParam;
     3224    btnPtr->dwData = lptbbi->lParam;
    32243225/*    if (lptbbi->dwMask & TBIF_SIZE) */
    3225 /*      btnPtr->cx = lptbbi->cx; */
     3226/*  btnPtr->cx = lptbbi->cx; */
    32263227    if (lptbbi->dwMask & TBIF_STATE)
    3227         btnPtr->fsState = lptbbi->fsState;
     3228    btnPtr->fsState = lptbbi->fsState;
    32283229    if (lptbbi->dwMask & TBIF_STYLE)
    3229         btnPtr->fsStyle = lptbbi->fsStyle;
     3230    btnPtr->fsStyle = lptbbi->fsStyle;
    32303231
    32313232    if (lptbbi->dwMask & TBIF_TEXT) {
    3232         if ((btnPtr->iString >= 0) ||
    3233             (btnPtr->iString < infoPtr->nNumStrings)) {
     3233    if ((btnPtr->iString >= 0) ||
     3234        (btnPtr->iString < infoPtr->nNumStrings)) {
    32343235#if 0
    3235             WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
    3236             INT len = lstrlenW (lptbbi->pszText);
    3237             *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
     3236        WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
     3237        INT len = lstrlenW (lptbbi->pszText);
     3238        *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
    32383239#endif
    32393240
    3240             /* this is the ultimate solution */
    3241 /*          Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
    3242         }
     3241        /* this is the ultimate solution */
     3242/*      Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
     3243    }
    32433244    }
    32443245
     
    32553256    {
    32563257        ERR("invalid parameter\n");
    3257         return FALSE;
     3258    return FALSE;
    32583259    }
    32593260
    32603261    /* The documentation claims you can only change the button size before
    3261      * any button has been added. But this is wrong. 
    3262      * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding 
     3262     * any button has been added. But this is wrong.
     3263     * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
    32633264     * it to the toolbar, and it checks that the return value is nonzero - mjm
    32643265     * Further testing shows that we must actually perform the change too.
     
    32763277
    32773278    if (infoPtr == NULL) {
    3278         TRACE("Toolbar not initialized yet?????\n");
    3279         return FALSE;
     3279    TRACE("Toolbar not initialized yet?????\n");
     3280    return FALSE;
    32803281    }
    32813282
    32823283    /* if setting to current values, ignore */
    32833284    if ((infoPtr->cxMin == (INT)LOWORD(lParam)) &&
    3284         (infoPtr->cxMax == (INT)HIWORD(lParam))) {
    3285         TRACE("matches current width, min=%d, max=%d, no recalc\n",
    3286               infoPtr->cxMin, infoPtr->cxMax);
    3287         return TRUE;
     3285    (infoPtr->cxMax == (INT)HIWORD(lParam))) {
     3286    TRACE("matches current width, min=%d, max=%d, no recalc\n",
     3287          infoPtr->cxMin, infoPtr->cxMax);
     3288    return TRUE;
    32883289    }
    32893290
     
    32943295    /* if both values are 0 then we are done */
    32953296    if (lParam == 0) {
    3296         TRACE("setting both min and max to 0, norecalc\n");
    3297         return TRUE;
     3297    TRACE("setting both min and max to 0, norecalc\n");
     3298    return TRUE;
    32983299    }
    32993300
     
    33013302       recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
    33023303       which doesn't actually draw - GA). */
    3303     TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n", 
    3304         infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax);
     3304    TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
     3305    infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax);
    33053306
    33063307    TOOLBAR_CalcToolbar (hwnd);
     
    33193320
    33203321    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    3321         return FALSE;
     3322    return FALSE;
    33223323
    33233324    infoPtr->buttons[nIndex].idCommand = (INT)lParam;
     
    33253326    if (infoPtr->hwndToolTip) {
    33263327
    3327         FIXME("change tool tip!\n");
     3328    FIXME("change tool tip!\n");
    33283329
    33293330    }
     
    33483349    /* FIXME: redraw ? */
    33493350
    3350     return (LRESULT)himlTemp; 
     3351    return (LRESULT)himlTemp;
    33513352}
    33523353
     
    33603361    dwTemp = infoPtr->dwDTFlags;
    33613362    infoPtr->dwDTFlags =
    3362         (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
     3363    (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
    33633364
    33643365    return (LRESULT)dwTemp;
     
    33753376    infoPtr->dwExStyle = (DWORD)lParam;
    33763377
    3377     return (LRESULT)dwTemp; 
     3378    return (LRESULT)dwTemp;
    33783379}
    33793380
     
    33903391    /* FIXME: redraw ? */
    33913392
    3392     return (LRESULT)himlTemp; 
     3393    return (LRESULT)himlTemp;
    33933394}
    33943395
     
    34073408    {
    34083409
    3409         infoPtr->nHotItem = (INT)wParam;
     3410        infoPtr->nHotItem = (INT)wParam;
    34103411        if ((INT)wParam >=0)
    34113412        {
    34123413            btnPtr = &infoPtr->buttons[(INT)wParam];
    34133414            btnPtr->bHot = TRUE;
    3414                 InvalidateRect (hwnd, &btnPtr->rect,
     3415            InvalidateRect (hwnd, &btnPtr->rect,
    34153416                    TOOLBAR_HasText(infoPtr, btnPtr));
    34163417        }
     
    34193420            btnPtr = &infoPtr->buttons[nOldHotItem];
    34203421            btnPtr->bHot = FALSE;
    3421                 InvalidateRect (hwnd, &btnPtr->rect,
     3422            InvalidateRect (hwnd, &btnPtr->rect,
    34223423                    TOOLBAR_HasText(infoPtr, btnPtr));
    34233424        }
     
    34253426
    34263427    if (nOldHotItem < 0)
    3427         return -1;
     3428    return -1;
    34283429
    34293430    return (LRESULT)nOldHotItem;
     
    34433444    /* FIXME: redraw ? */
    34443445
    3445     return (LRESULT)himlTemp; 
     3446    return (LRESULT)himlTemp;
    34463447}
    34473448
     
    34903491
    34913492    if (infoPtr == NULL)
    3492         return FALSE;
     3493    return FALSE;
    34933494
    34943495    infoPtr->nMaxTextRows = (INT)wParam;
     
    35103511
    35113512    if (infoPtr == NULL)
    3512         return 0;
     3513    return 0;
    35133514    hwndOldNotify = infoPtr->hwndNotify;
    35143515    infoPtr->hwndNotify = (HWND)wParam;
     
    35273528
    35283529    if (LOWORD(wParam) > 1) {
    3529         FIXME("multiple rows not supported!\n");
     3530    FIXME("multiple rows not supported!\n");
    35303531    }
    35313532
     
    35433544    /* return bounding rectangle */
    35443545    if (lprc) {
    3545         lprc->left   = infoPtr->rcBound.left;
    3546         lprc->right  = infoPtr->rcBound.right;
    3547         lprc->top    = infoPtr->rcBound.top;
    3548         lprc->bottom = infoPtr->rcBound.bottom;
     3546    lprc->left   = infoPtr->rcBound.left;
     3547    lprc->right  = infoPtr->rcBound.right;
     3548    lprc->top    = infoPtr->rcBound.top;
     3549    lprc->bottom = infoPtr->rcBound.bottom;
    35493550    }
    35503551
     
    35623563    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    35633564    if (nIndex == -1)
    3564         return FALSE;
     3565    return FALSE;
    35653566
    35663567    btnPtr = &infoPtr->buttons[nIndex];
     
    35873588    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    35883589    if (nIndex == -1)
    3589         return FALSE;
     3590    return FALSE;
    35903591
    35913592    btnPtr = &infoPtr->buttons[nIndex];
     
    35993600
    36003601        if (infoPtr->hwndToolTip) {
    3601             FIXME("change tool tip!\n");
     3602        FIXME("change tool tip!\n");
    36023603        }
    36033604    }
     
    36133614
    36143615    if (infoPtr == NULL)
    3615         return 0;
     3616    return 0;
    36163617    infoPtr->hwndToolTip = (HWND)wParam;
    36173618    return 0;
     
    36253626    BOOL bTemp;
    36263627
    3627     TRACE("%s hwnd=0x%04x stub!\n", 
    3628            ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
     3628    TRACE("%s hwnd=0x%04x stub!\n",
     3629       ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
    36293630
    36303631    bTemp = infoPtr->bUnicode;
     
    36833684
    36843685    if (dwStyle & TBSTYLE_TOOLTIPS) {
    3685         /* Create tooltip control */
    3686         infoPtr->hwndToolTip =
    3687             CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    3688                                CW_USEDEFAULT, CW_USEDEFAULT,
    3689                                CW_USEDEFAULT, CW_USEDEFAULT,
    3690                                hwnd, 0, 0, 0);
    3691 
    3692         /* Send NM_TOOLTIPSCREATED notification */
    3693         if (infoPtr->hwndToolTip) {
    3694             NMTOOLTIPSCREATED nmttc;
    3695 
    3696             nmttc.hdr.hwndFrom = hwnd;
    3697             nmttc.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    3698             nmttc.hdr.code = NM_TOOLTIPSCREATED;
    3699             nmttc.hwndToolTips = infoPtr->hwndToolTip;
    3700 
    3701             SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
    3702                           (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
    3703         }
     3686    /* Create tooltip control */
     3687    infoPtr->hwndToolTip =
     3688        CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
     3689                   CW_USEDEFAULT, CW_USEDEFAULT,
     3690                   CW_USEDEFAULT, CW_USEDEFAULT,
     3691                   hwnd, 0, 0, 0);
     3692
     3693    /* Send NM_TOOLTIPSCREATED notification */
     3694    if (infoPtr->hwndToolTip) {
     3695        NMTOOLTIPSCREATED nmttc;
     3696
     3697        nmttc.hdr.hwndFrom = hwnd;
     3698        nmttc.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     3699        nmttc.hdr.code = NM_TOOLTIPSCREATED;
     3700        nmttc.hwndToolTips = infoPtr->hwndToolTip;
     3701
     3702        SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
     3703              (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
     3704    }
    37043705    }
    37053706
     
    37173718    /* delete tooltip control */
    37183719    if (infoPtr->hwndToolTip)
    3719         DestroyWindow (infoPtr->hwndToolTip);
     3720    DestroyWindow (infoPtr->hwndToolTip);
    37203721
    37213722    /* delete button data */
    37223723    if (infoPtr->buttons)
    3723         COMCTL32_Free (infoPtr->buttons);
     3724    COMCTL32_Free (infoPtr->buttons);
    37243725
    37253726    /* delete strings */
    37263727    if (infoPtr->strings) {
    3727         INT i;
    3728         for (i = 0; i < infoPtr->nNumStrings; i++)
    3729             if (infoPtr->strings[i])
    3730                 COMCTL32_Free (infoPtr->strings[i]);
    3731 
    3732         COMCTL32_Free (infoPtr->strings);
     3728    INT i;
     3729    for (i = 0; i < infoPtr->nNumStrings; i++)
     3730        if (infoPtr->strings[i])
     3731        COMCTL32_Free (infoPtr->strings[i]);
     3732
     3733    COMCTL32_Free (infoPtr->strings);
    37333734    }
    37343735
    37353736    /* destroy internal image list */
    37363737    if (infoPtr->himlInt)
    3737         ImageList_Destroy (infoPtr->himlInt);
     3738    ImageList_Destroy (infoPtr->himlInt);
    37383739
    37393740    /* delete default font */
    37403741    if (infoPtr->hFont)
    3741         DeleteObject (infoPtr->hFont);
     3742    DeleteObject (infoPtr->hFont);
    37423743
    37433744    /* free toolbar info data */
     
    37553756
    37563757    if (infoPtr->bTransparent)
    3757         return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
     3758    return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
    37583759
    37593760    return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
     
    37833784
    37843785    if (nHit >= 0) {
    3785         btnPtr = &infoPtr->buttons[nHit];
    3786         if (!(btnPtr->fsState & TBSTATE_ENABLED))
    3787             return 0;
    3788         SetCapture (hwnd);
    3789         infoPtr->bCaptured = TRUE;
    3790         infoPtr->nButtonDown = nHit;
    3791 
    3792         btnPtr->fsState |= TBSTATE_PRESSED;
     3786    btnPtr = &infoPtr->buttons[nHit];
     3787    if (!(btnPtr->fsState & TBSTATE_ENABLED))
     3788        return 0;
     3789    SetCapture (hwnd);
     3790    infoPtr->bCaptured = TRUE;
     3791    infoPtr->nButtonDown = nHit;
     3792
     3793    btnPtr->fsState |= TBSTATE_PRESSED;
    37933794
    37943795        InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
     
    37963797    }
    37973798    else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
    3798         TOOLBAR_Customize (hwnd);
     3799    TOOLBAR_Customize (hwnd);
    37993800
    38003801    return 0;
     
    38113812
    38123813    if (infoPtr->hwndToolTip)
    3813         TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
    3814                             WM_LBUTTONDOWN, wParam, lParam);
     3814    TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
     3815                WM_LBUTTONDOWN, wParam, lParam);
    38153816
    38163817    pt.x = (INT)LOWORD(lParam);
     
    38193820
    38203821    if (nHit >= 0) {
    3821         RECT arrowRect;
    3822         btnPtr = &infoPtr->buttons[nHit];
    3823         if (!(btnPtr->fsState & TBSTATE_ENABLED))
    3824             return 0;
    3825 
    3826         infoPtr->nOldHit = nHit;
    3827 
    3828         CopyRect(&arrowRect, &btnPtr->rect);
    3829         arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH);
    3830 
    3831         /* for EX_DRAWDDARROWS style,  click must be in the drop-down arrow rect */
    3832         if ((btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
    3833              ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
    3834               (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
    3835         {
    3836             NMTOOLBARA nmtb;
    3837             /*
    3838              * this time we must force a Redraw, so the btn is
    3839              * painted down before CaptureChanged repaints it up
    3840              */
    3841             RedrawWindow(hwnd,&btnPtr->rect,0,
    3842                         RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
    3843 
    3844             nmtb.hdr.hwndFrom = hwnd;
    3845             nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
    3846             nmtb.hdr.code = TBN_DROPDOWN;
    3847             nmtb.iItem = btnPtr->idCommand;
    3848 
    3849             SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
    3850                           (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
    3851         }
    3852         else
    3853         {
    3854             SetCapture (hwnd);
    3855             infoPtr->bCaptured = TRUE;
    3856             infoPtr->nButtonDown = nHit;
    3857 
    3858             btnPtr->fsState |= TBSTATE_PRESSED;
    3859             btnPtr->bHot = FALSE;
    3860 
    3861             InvalidateRect(hwnd, &btnPtr->rect,
    3862                            TOOLBAR_HasText(infoPtr, btnPtr));
    3863         }
     3822    RECT arrowRect;
     3823    btnPtr = &infoPtr->buttons[nHit];
     3824    if (!(btnPtr->fsState & TBSTATE_ENABLED))
     3825        return 0;
     3826
     3827    infoPtr->nOldHit = nHit;
     3828
     3829    CopyRect(&arrowRect, &btnPtr->rect);
     3830    arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH);
     3831
     3832    /* for EX_DRAWDDARROWS style,  click must be in the drop-down arrow rect */
     3833    if ((btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
     3834         ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
     3835          (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
     3836    {
     3837        NMTOOLBARA nmtb;
     3838        /*
     3839         * this time we must force a Redraw, so the btn is
     3840         * painted down before CaptureChanged repaints it up
     3841         */
     3842        RedrawWindow(hwnd,&btnPtr->rect,0,
     3843            RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
     3844
     3845        nmtb.hdr.hwndFrom = hwnd;
     3846        nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
     3847        nmtb.hdr.code = TBN_DROPDOWN;
     3848        nmtb.iItem = btnPtr->idCommand;
     3849
     3850        SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
     3851              (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
     3852    }
     3853    else
     3854    {
     3855        SetCapture (hwnd);
     3856        infoPtr->bCaptured = TRUE;
     3857        infoPtr->nButtonDown = nHit;
     3858
     3859        btnPtr->fsState |= TBSTATE_PRESSED;
     3860        btnPtr->bHot = FALSE;
     3861
     3862        InvalidateRect(hwnd, &btnPtr->rect,
     3863               TOOLBAR_HasText(infoPtr, btnPtr));
     3864    }
    38643865    }
    38653866
     
    38783879
    38793880    if (infoPtr->hwndToolTip)
    3880         TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
    3881                             WM_LBUTTONUP, wParam, lParam);
     3881    TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
     3882                WM_LBUTTONUP, wParam, lParam);
    38823883
    38833884    pt.x = (INT)LOWORD(lParam);
     
    38913892
    38923893    if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
    3893         btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
    3894         btnPtr->fsState &= ~TBSTATE_PRESSED;
    3895 
    3896         if (nHit == infoPtr->nButtonDown) {
    3897             if (btnPtr->fsStyle & TBSTYLE_CHECK) {
    3898                 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
    3899                     nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
    3900                         infoPtr->nButtonDown);
    3901                     if (nOldIndex == infoPtr->nButtonDown)
    3902                         bSendMessage = FALSE;
    3903                     if ((nOldIndex != infoPtr->nButtonDown) &&
    3904                         (nOldIndex != -1))
    3905                         infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
    3906                     btnPtr->fsState |= TBSTATE_CHECKED;
    3907                 }
    3908                 else {
    3909                     if (btnPtr->fsState & TBSTATE_CHECKED)
    3910                         btnPtr->fsState &= ~TBSTATE_CHECKED;
    3911                     else
    3912                         btnPtr->fsState |= TBSTATE_CHECKED;
    3913                 }
    3914             }
    3915         }
    3916         else
    3917             bSendMessage = FALSE;
    3918 
    3919         if (nOldIndex != -1)
     3894    btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
     3895    btnPtr->fsState &= ~TBSTATE_PRESSED;
     3896
     3897    if (nHit == infoPtr->nButtonDown) {
     3898        if (btnPtr->fsStyle & TBSTYLE_CHECK) {
     3899        if (btnPtr->fsStyle & TBSTYLE_GROUP) {
     3900            nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
     3901            infoPtr->nButtonDown);
     3902            if (nOldIndex == infoPtr->nButtonDown)
     3903            bSendMessage = FALSE;
     3904            if ((nOldIndex != infoPtr->nButtonDown) &&
     3905            (nOldIndex != -1))
     3906            infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
     3907            btnPtr->fsState |= TBSTATE_CHECKED;
     3908        }
     3909        else {
     3910            if (btnPtr->fsState & TBSTATE_CHECKED)
     3911            btnPtr->fsState &= ~TBSTATE_CHECKED;
     3912            else
     3913            btnPtr->fsState |= TBSTATE_CHECKED;
     3914        }
     3915        }
     3916    }
     3917    else
     3918        bSendMessage = FALSE;
     3919
     3920    if (nOldIndex != -1)
    39203921        {
    39213922            InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
     
    39233924        }
    39243925
    3925         /*
    3926         * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
    3927         * that resets bCaptured and btn TBSTATE_PRESSED flags,
    3928          * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
    3929         */
    3930         ReleaseCapture ();
    3931 
    3932         if (bSendMessage)
    3933             SendMessageA (GetParent(hwnd), WM_COMMAND,
    3934                           MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
     3926    /*
     3927    * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
     3928    * that resets bCaptured and btn TBSTATE_PRESSED flags,
     3929     * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
     3930    */
     3931    ReleaseCapture ();
     3932
     3933    if (bSendMessage)
     3934        SendMessageA (GetParent(hwnd), WM_COMMAND,
     3935              MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
    39353936    }
    39363937
     
    39493950    {
    39503951        btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
    3951         btnPtr->fsState &= ~TBSTATE_PRESSED;
     3952        btnPtr->fsState &= ~TBSTATE_PRESSED;
    39523953
    39533954        infoPtr->nButtonDown = -1;
     
    39753976    if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED))
    39763977    {
    3977         hotBtnPtr->bHot = FALSE;
     3978    hotBtnPtr->bHot = FALSE;
    39783979
    39793980        InvalidateRect (hwnd, &hotBtnPtr->rect, TOOLBAR_HasText(infoPtr,
     
    40194020    if(!(trackinfo.dwFlags & TME_LEAVE)) {
    40204021        trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
    4021  
     4022
    40224023        /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
    40234024        /* and can properly deactivate the hot toolbar button */
     
    40264027
    40274028    if (infoPtr->hwndToolTip)
    4028         TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
    4029                             WM_MOUSEMOVE, wParam, lParam);
     4029    TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
     4030                WM_MOUSEMOVE, wParam, lParam);
    40304031
    40314032    pt.x = (INT)LOWORD(lParam);
     
    40364037    if (infoPtr->nOldHit != nHit)
    40374038    {
    4038         /* Remove the effect of an old hot button if the button was enabled and was
    4039            drawn with the hot button effect */
    4040         if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
    4041                 (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
    4042         {
    4043             oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
    4044             oldBtnPtr->bHot = FALSE;
    4045                    
    4046             InvalidateRect (hwnd, &oldBtnPtr->rect,
     4039    /* Remove the effect of an old hot button if the button was enabled and was
     4040       drawn with the hot button effect */
     4041    if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
     4042        (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
     4043    {
     4044        oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
     4045        oldBtnPtr->bHot = FALSE;
     4046
     4047        InvalidateRect (hwnd, &oldBtnPtr->rect,
    40474048                TOOLBAR_HasText(infoPtr, oldBtnPtr));
    4048         }
    4049 
    4050         /* It's not a separator or in nowhere. It's a hot button. */
    4051         if (nHit >= 0)
    4052         {
    4053             btnPtr = &infoPtr->buttons[nHit];
    4054             btnPtr->bHot = TRUE;
    4055 
    4056             infoPtr->nHotItem = nHit;
    4057 
    4058             /* only enabled buttons show hot effect */           
     4049    }
     4050
     4051    /* It's not a separator or in nowhere. It's a hot button. */
     4052    if (nHit >= 0)
     4053    {
     4054        btnPtr = &infoPtr->buttons[nHit];
     4055        btnPtr->bHot = TRUE;
     4056
     4057        infoPtr->nHotItem = nHit;
     4058
     4059            /* only enabled buttons show hot effect */
    40594060            if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED)
    40604061            {
     
    40634064            }
    40644065
    4065         }
     4066    }
    40664067
    40674068    if (infoPtr->bCaptured) {
    4068             btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
    4069             if (infoPtr->nOldHit == infoPtr->nButtonDown) {
    4070                 btnPtr->fsState &= ~TBSTATE_PRESSED;
     4069        btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
     4070        if (infoPtr->nOldHit == infoPtr->nButtonDown) {
     4071        btnPtr->fsState &= ~TBSTATE_PRESSED;
    40714072                InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    4072             }
    4073             else if (nHit == infoPtr->nButtonDown) {
    4074                 btnPtr->fsState |= TBSTATE_PRESSED;
     4073        }
     4074        else if (nHit == infoPtr->nButtonDown) {
     4075        btnPtr->fsState |= TBSTATE_PRESSED;
    40754076                InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    4076             }
    4077         }
    4078         infoPtr->nOldHit = nHit;
     4077        }
     4078    }
     4079    infoPtr->nOldHit = nHit;
    40794080    }
    40804081    return 0;
     
    40864087{
    40874088/*    if (wndPtr->dwStyle & CCS_NODIVIDER) */
    4088         return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
     4089    return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
    40894090/*    else */
    4090 /*      return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
     4091/*  return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
    40914092}
    40924093
     
    40964097{
    40974098    if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
    4098         ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
     4099    ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
    40994100
    41004101    return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
     
    41174118    if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
    41184119        HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
    4119         SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
     4120    SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
    41204121    }
    41214122
     
    41324133
    41334134    if (dwStyle & WS_MINIMIZE)
    4134         return 0; /* Nothing to do */
     4135    return 0; /* Nothing to do */
    41354136
    41364137    DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
    41374138
    41384139    if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
    4139         return 0;
     4140    return 0;
    41404141
    41414142    if (!(dwStyle & CCS_NODIVIDER))
    41424143    {
    4143         GetWindowRect (hwnd, &rcWindow);
    4144         OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
    4145         if( dwStyle & WS_BORDER )
    4146             OffsetRect (&rcWindow, 1, 1);
    4147         DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
     4144    GetWindowRect (hwnd, &rcWindow);
     4145    OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
     4146    if( dwStyle & WS_BORDER )
     4147        OffsetRect (&rcWindow, 1, 1);
     4148    DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
    41484149    }
    41494150
     
    41634164
    41644165    if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
    4165         SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,   wParam, lParam);
     4166    SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,   wParam, lParam);
    41664167
    41674168#if 0
    4168         if (lpnmh->code == TTN_GETDISPINFOA) {
    4169             LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
    4170 
    4171             FIXME("retrieving ASCII string\n");
    4172 
    4173         }
    4174         else if (lpnmh->code == TTN_GETDISPINFOW) {
    4175             LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
    4176 
    4177             FIXME("retrieving UNICODE string\n");
    4178 
    4179         }
     4169    if (lpnmh->code == TTN_GETDISPINFOA) {
     4170        LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
     4171
     4172        FIXME("retrieving ASCII string\n");
     4173
     4174    }
     4175    else if (lpnmh->code == TTN_GETDISPINFOW) {
     4176        LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
     4177
     4178        FIXME("retrieving UNICODE string\n");
     4179
     4180    }
    41804181#endif
    41814182    }
     
    41934194
    41944195    /* fill ps.rcPaint with a default rect */
    4195     memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound)); 
     4196    memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound));
    41964197
    41974198    hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam;
    41984199
    41994200    TRACE("psrect=(%d,%d)-(%d,%d)\n",
    4200           ps.rcPaint.left, ps.rcPaint.top,
    4201           ps.rcPaint.right, ps.rcPaint.bottom);
     4201      ps.rcPaint.left, ps.rcPaint.top,
     4202      ps.rcPaint.right, ps.rcPaint.bottom);
    42024203
    42034204    TOOLBAR_Refresh (hwnd, hdc, &ps);
     
    42234224    /* Resize deadlock check */
    42244225    if (infoPtr->bAutoSize) {
    4225         infoPtr->bAutoSize = FALSE;
    4226         return 0;
     4226    infoPtr->bAutoSize = FALSE;
     4227    return 0;
    42274228    }
    42284229
     
    42394240
    42404241    if (flags == SIZE_RESTORED) {
    4241         /* width and height don't apply */
    4242         parent = GetParent (hwnd);
    4243         GetClientRect(parent, &parent_rect);
    4244         x = parent_rect.left;
    4245         y = parent_rect.top;
    4246 
    4247         if (dwStyle & CCS_NORESIZE) {
    4248             uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
    4249 
    4250             /*
     4242    /* width and height don't apply */
     4243    parent = GetParent (hwnd);
     4244    GetClientRect(parent, &parent_rect);
     4245    x = parent_rect.left;
     4246    y = parent_rect.top;
     4247
     4248    if (dwStyle & CCS_NORESIZE) {
     4249        uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
     4250
     4251        /*
    42514252             * this sets the working width of the toolbar, and
    42524253             * Calc Toolbar will not adjust it, only the height
    42534254             */
    4254             infoPtr->nWidth = parent_rect.right - parent_rect.left;
    4255             cy = infoPtr->nHeight;
    4256             cx = infoPtr->nWidth;
    4257             TOOLBAR_CalcToolbar (hwnd);
    4258             infoPtr->nWidth = cx;
    4259             infoPtr->nHeight = cy;
    4260         }
    4261         else {
    4262             infoPtr->nWidth = parent_rect.right - parent_rect.left;
    4263             TOOLBAR_CalcToolbar (hwnd);
    4264             cy = infoPtr->nHeight;
    4265             cx = infoPtr->nWidth;
    4266 
    4267             if (dwStyle & CCS_NOMOVEY) {
    4268                 GetWindowRect(hwnd, &window_rect);
    4269                 ScreenToClient(parent, (LPPOINT)&window_rect.left);
    4270                 y = window_rect.top;
    4271             }
    4272         }
    4273 
    4274         if (dwStyle & CCS_NOPARENTALIGN) {
    4275             uPosFlags |= SWP_NOMOVE;
    4276             cy = infoPtr->nHeight;
    4277             cx = infoPtr->nWidth;
    4278         }
    4279 
    4280         if (!(dwStyle & CCS_NODIVIDER))
    4281             cy += GetSystemMetrics(SM_CYEDGE);
    4282 
    4283         if (dwStyle & WS_BORDER)
    4284         {
    4285             x = y = 1;
    4286             cy += GetSystemMetrics(SM_CYEDGE);
    4287             cx += GetSystemMetrics(SM_CYEDGE);
    4288         }
    4289 
    4290         SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
    4291                         cx, cy, uPosFlags | SWP_NOZORDER);
     4255        infoPtr->nWidth = parent_rect.right - parent_rect.left;
     4256        cy = infoPtr->nHeight;
     4257        cx = infoPtr->nWidth;
     4258        TOOLBAR_CalcToolbar (hwnd);
     4259        infoPtr->nWidth = cx;
     4260        infoPtr->nHeight = cy;
     4261    }
     4262    else {
     4263        infoPtr->nWidth = parent_rect.right - parent_rect.left;
     4264        TOOLBAR_CalcToolbar (hwnd);
     4265        cy = infoPtr->nHeight;
     4266        cx = infoPtr->nWidth;
     4267
     4268        if (dwStyle & CCS_NOMOVEY) {
     4269        GetWindowRect(hwnd, &window_rect);
     4270        ScreenToClient(parent, (LPPOINT)&window_rect.left);
     4271        y = window_rect.top;
     4272        }
     4273    }
     4274
     4275    if (dwStyle & CCS_NOPARENTALIGN) {
     4276        uPosFlags |= SWP_NOMOVE;
     4277        cy = infoPtr->nHeight;
     4278        cx = infoPtr->nWidth;
     4279    }
     4280
     4281    if (!(dwStyle & CCS_NODIVIDER))
     4282        cy += GetSystemMetrics(SM_CYEDGE);
     4283
     4284    if (dwStyle & WS_BORDER)
     4285    {
     4286        x = y = 1;
     4287        cy += GetSystemMetrics(SM_CYEDGE);
     4288        cx += GetSystemMetrics(SM_CYEDGE);
     4289    }
     4290
     4291    SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
     4292            cx, cy, uPosFlags | SWP_NOZORDER);
    42924293    }
    42934294    return 0;
     
    43014302
    43024303    if (nType == GWL_STYLE) {
    4303         if (lpStyle->styleNew & TBSTYLE_LIST) {
    4304             infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
    4305         }
    4306         else {
    4307             infoPtr->dwDTFlags = DT_CENTER;
    4308         }
     4304    if (lpStyle->styleNew & TBSTYLE_LIST) {
     4305        infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
     4306    }
     4307    else {
     4308        infoPtr->dwDTFlags = DT_CENTER;
     4309    }
    43094310    }
    43104311
     
    43224323{
    43234324    if (!TOOLBAR_GetInfoPtr(hwnd) && (uMsg != WM_NCCREATE))
    4324         return DefWindowProcA( hwnd, uMsg, wParam, lParam );
     4325    return DefWindowProcA( hwnd, uMsg, wParam, lParam );
    43254326
    43264327    switch (uMsg)
    43274328    {
    4328         case TB_ADDBITMAP:
    4329             return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
    4330 
    4331         case TB_ADDBUTTONSA:
    4332             return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
    4333 
    4334         case TB_ADDBUTTONSW:
    4335             return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
    4336 
    4337         case TB_ADDSTRINGA:
    4338             return TOOLBAR_AddStringA (hwnd, wParam, lParam);
    4339 
    4340         case TB_ADDSTRINGW:
    4341             return TOOLBAR_AddStringW (hwnd, wParam, lParam);
    4342 
    4343         case TB_AUTOSIZE:
    4344             return TOOLBAR_AutoSize (hwnd);
    4345 
    4346         case TB_BUTTONCOUNT:
    4347             return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
    4348 
    4349         case TB_BUTTONSTRUCTSIZE:
    4350             return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
    4351 
    4352         case TB_CHANGEBITMAP:
    4353             return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
    4354 
    4355         case TB_CHECKBUTTON:
    4356             return TOOLBAR_CheckButton (hwnd, wParam, lParam);
    4357 
    4358         case TB_COMMANDTOINDEX:
    4359             return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
    4360 
    4361         case TB_CUSTOMIZE:
    4362             return TOOLBAR_Customize (hwnd);
    4363 
    4364         case TB_DELETEBUTTON:
    4365             return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
    4366 
    4367         case TB_ENABLEBUTTON:
    4368             return TOOLBAR_EnableButton (hwnd, wParam, lParam);
    4369 
    4370         case TB_GETANCHORHIGHLIGHT:
    4371             return TOOLBAR_GetAnchorHighlight (hwnd);
    4372 
    4373         case TB_GETBITMAP:
    4374             return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
    4375 
    4376         case TB_GETBITMAPFLAGS:
    4377             return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
    4378 
    4379         case TB_GETBUTTON:
    4380             return TOOLBAR_GetButton (hwnd, wParam, lParam);
    4381 
    4382         case TB_GETBUTTONINFOA:
    4383             return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
    4384 
    4385         case TB_GETBUTTONINFOW:
    4386             return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
    4387 
    4388         case TB_GETBUTTONSIZE:
    4389             return TOOLBAR_GetButtonSize (hwnd);
    4390 
    4391         case TB_GETBUTTONTEXTA:
    4392             return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
    4393 
    4394         case TB_GETBUTTONTEXTW:
    4395             return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
    4396 
    4397 /*      case TB_GETCOLORSCHEME:                 */ /* 4.71 */
    4398 
    4399         case TB_GETDISABLEDIMAGELIST:
    4400             return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
    4401 
    4402         case TB_GETEXTENDEDSTYLE:
    4403             return TOOLBAR_GetExtendedStyle (hwnd);
    4404 
    4405         case TB_GETHOTIMAGELIST:
    4406             return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
    4407 
    4408         case TB_GETHOTITEM:
    4409             return TOOLBAR_GetHotItem (hwnd);
    4410 
    4411         case TB_GETIMAGELIST:
    4412             return TOOLBAR_GetImageList (hwnd, wParam, lParam);
    4413 
    4414 /*      case TB_GETINSERTMARK:                  */ /* 4.71 */
    4415 /*      case TB_GETINSERTMARKCOLOR:             */ /* 4.71 */
    4416 
    4417         case TB_GETITEMRECT:
    4418             return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
    4419 
    4420         case TB_GETMAXSIZE:
    4421             return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
    4422 
    4423 /*      case TB_GETOBJECT:                      */ /* 4.71 */
    4424 /*      case TB_GETPADDING:                     */ /* 4.71 */
    4425 
    4426         case TB_GETRECT:
    4427             return TOOLBAR_GetRect (hwnd, wParam, lParam);
    4428 
    4429         case TB_GETROWS:
    4430             return TOOLBAR_GetRows (hwnd, wParam, lParam);
    4431 
    4432         case TB_GETSTATE:
    4433             return TOOLBAR_GetState (hwnd, wParam, lParam);
    4434 
    4435         case TB_GETSTYLE:
    4436             return TOOLBAR_GetStyle (hwnd, wParam, lParam);
    4437 
    4438         case TB_GETTEXTROWS:
    4439             return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
    4440 
    4441         case TB_GETTOOLTIPS:
    4442             return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
    4443 
    4444         case TB_GETUNICODEFORMAT:
    4445             return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
    4446 
    4447         case CCM_GETVERSION:
    4448             return TOOLBAR_GetVersion (hwnd);
    4449 
    4450         case TB_HIDEBUTTON:
    4451             return TOOLBAR_HideButton (hwnd, wParam, lParam);
    4452 
    4453         case TB_HITTEST:
    4454             return TOOLBAR_HitTest (hwnd, wParam, lParam);
    4455 
    4456         case TB_INDETERMINATE:
    4457             return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
    4458 
    4459         case TB_INSERTBUTTONA:
    4460             return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
    4461 
    4462         case TB_INSERTBUTTONW:
    4463             return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
    4464 
    4465 /*      case TB_INSERTMARKHITTEST:              */ /* 4.71 */
    4466 
    4467         case TB_ISBUTTONCHECKED:
    4468             return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
    4469 
    4470         case TB_ISBUTTONENABLED:
    4471             return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
    4472 
    4473         case TB_ISBUTTONHIDDEN:
    4474             return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
    4475 
    4476         case TB_ISBUTTONHIGHLIGHTED:
    4477             return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
    4478 
    4479         case TB_ISBUTTONINDETERMINATE:
    4480             return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
    4481 
    4482         case TB_ISBUTTONPRESSED:
    4483             return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
    4484 
    4485         case TB_LOADIMAGES:                        /* 4.70 */
    4486             FIXME("missing standard imagelists\n");
    4487             return 0;
    4488 
    4489 /*      case TB_MAPACCELERATORA:                */ /* 4.71 */
    4490 /*      case TB_MAPACCELERATORW:                */ /* 4.71 */
    4491 /*      case TB_MARKBUTTON:                     */ /* 4.71 */
    4492 /*      case TB_MOVEBUTTON:                     */ /* 4.71 */
    4493 
    4494         case TB_PRESSBUTTON:
    4495             return TOOLBAR_PressButton (hwnd, wParam, lParam);
    4496 
    4497 /*      case TB_REPLACEBITMAP: */
    4498 
    4499         case TB_SAVERESTOREA:
    4500             return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
    4501 
    4502         case TB_SAVERESTOREW:
    4503             return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
    4504 
    4505         case TB_SETANCHORHIGHLIGHT:
    4506             return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
    4507 
    4508         case TB_SETBITMAPSIZE:
    4509             return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
    4510 
    4511         case TB_SETBUTTONINFOA:
    4512             return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
    4513 
    4514         case TB_SETBUTTONINFOW:
    4515             return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
    4516 
    4517         case TB_SETBUTTONSIZE:
    4518             return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
    4519 
    4520         case TB_SETBUTTONWIDTH:
    4521             return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
    4522 
    4523         case TB_SETCMDID:
    4524             return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
    4525 
    4526 /*      case TB_SETCOLORSCHEME:                 */ /* 4.71 */
    4527 
    4528         case TB_SETDISABLEDIMAGELIST:
    4529             return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
    4530 
    4531         case TB_SETDRAWTEXTFLAGS:
    4532             return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
    4533 
    4534         case TB_SETEXTENDEDSTYLE:
    4535             return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
    4536 
    4537         case TB_SETHOTIMAGELIST:
    4538             return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
    4539 
    4540         case TB_SETHOTITEM:
    4541             return TOOLBAR_SetHotItem (hwnd, wParam);
    4542 
    4543         case TB_SETIMAGELIST:
    4544             return TOOLBAR_SetImageList (hwnd, wParam, lParam);
    4545 
    4546         case TB_SETINDENT:
    4547             return TOOLBAR_SetIndent (hwnd, wParam, lParam);
    4548 
    4549 /*      case TB_SETINSERTMARK:                  */ /* 4.71 */
    4550 
    4551         case TB_SETINSERTMARKCOLOR:
    4552             return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
    4553 
    4554         case TB_SETMAXTEXTROWS:
    4555             return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
    4556 
    4557 /*      case TB_SETPADDING:                     */ /* 4.71 */
    4558 
    4559         case TB_SETPARENT:
    4560             return TOOLBAR_SetParent (hwnd, wParam, lParam);
    4561 
    4562         case TB_SETROWS:
    4563             return TOOLBAR_SetRows (hwnd, wParam, lParam);
    4564 
    4565         case TB_SETSTATE:
    4566             return TOOLBAR_SetState (hwnd, wParam, lParam);
    4567 
    4568         case TB_SETSTYLE:
    4569             return TOOLBAR_SetStyle (hwnd, wParam, lParam);
    4570 
    4571         case TB_SETTOOLTIPS:
    4572             return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
    4573 
    4574         case TB_SETUNICODEFORMAT:
    4575             return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
    4576 
    4577         case CCM_SETVERSION:
    4578             return TOOLBAR_SetVersion (hwnd, (INT)wParam);
    4579 
    4580 
    4581 /*      case WM_CHAR: */
    4582 
    4583         case WM_CREATE:
    4584             return TOOLBAR_Create (hwnd, wParam, lParam);
    4585 
    4586         case WM_DESTROY:
    4587           return TOOLBAR_Destroy (hwnd, wParam, lParam);
    4588 
    4589         case WM_ERASEBKGND:
    4590             return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
    4591 
    4592         case WM_GETFONT:
    4593                 return TOOLBAR_GetFont (hwnd, wParam, lParam);
    4594 
    4595 /*      case WM_KEYDOWN: */
    4596 /*      case WM_KILLFOCUS: */
    4597 
    4598         case WM_LBUTTONDBLCLK:
    4599             return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
    4600 
    4601         case WM_LBUTTONDOWN:
    4602             return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
    4603 
    4604         case WM_LBUTTONUP:
    4605             return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
    4606 
    4607         case WM_MOUSEMOVE:
    4608             return TOOLBAR_MouseMove (hwnd, wParam, lParam);
    4609 
    4610         case WM_MOUSELEAVE:
    4611             return TOOLBAR_MouseLeave (hwnd, wParam, lParam);   
    4612 
    4613         case WM_CAPTURECHANGED:
    4614             return TOOLBAR_CaptureChanged(hwnd);       
    4615 
    4616         case WM_NCACTIVATE:
    4617             return TOOLBAR_NCActivate (hwnd, wParam, lParam);
    4618 
    4619         case WM_NCCALCSIZE:
    4620             return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
    4621 
    4622         case WM_NCCREATE:
    4623             return TOOLBAR_NCCreate (hwnd, wParam, lParam);
    4624 
    4625         case WM_NCPAINT:
    4626             return TOOLBAR_NCPaint (hwnd, wParam, lParam);
    4627 
    4628         case WM_NOTIFY:
    4629             return TOOLBAR_Notify (hwnd, wParam, lParam);
    4630 
    4631 /*      case WM_NOTIFYFORMAT: */
    4632 
    4633         case WM_PAINT:
    4634             return TOOLBAR_Paint (hwnd, wParam);
    4635 
    4636         case WM_SIZE:
    4637             return TOOLBAR_Size (hwnd, wParam, lParam);
    4638 
    4639         case WM_STYLECHANGED:
    4640             return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
    4641 
    4642 /*      case WM_SYSCOLORCHANGE: */
    4643 
    4644 /*      case WM_WININICHANGE: */
    4645 
    4646         case WM_CHARTOITEM:
    4647         case WM_COMMAND:
    4648         case WM_DRAWITEM:
    4649         case WM_MEASUREITEM:
    4650         case WM_VKEYTOITEM:
    4651             return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
    4652 
    4653         default:
    4654             if (uMsg >= WM_USER)
    4655                 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    4656                      uMsg, wParam, lParam);
    4657             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     4329    case TB_ADDBITMAP:
     4330        return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
     4331
     4332    case TB_ADDBUTTONSA:
     4333        return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
     4334
     4335    case TB_ADDBUTTONSW:
     4336        return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
     4337
     4338    case TB_ADDSTRINGA:
     4339        return TOOLBAR_AddStringA (hwnd, wParam, lParam);
     4340
     4341    case TB_ADDSTRINGW:
     4342        return TOOLBAR_AddStringW (hwnd, wParam, lParam);
     4343
     4344    case TB_AUTOSIZE:
     4345        return TOOLBAR_AutoSize (hwnd);
     4346
     4347    case TB_BUTTONCOUNT:
     4348        return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
     4349
     4350    case TB_BUTTONSTRUCTSIZE:
     4351        return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
     4352
     4353    case TB_CHANGEBITMAP:
     4354        return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
     4355
     4356    case TB_CHECKBUTTON:
     4357        return TOOLBAR_CheckButton (hwnd, wParam, lParam);
     4358
     4359    case TB_COMMANDTOINDEX:
     4360        return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
     4361
     4362    case TB_CUSTOMIZE:
     4363        return TOOLBAR_Customize (hwnd);
     4364
     4365    case TB_DELETEBUTTON:
     4366        return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
     4367
     4368    case TB_ENABLEBUTTON:
     4369        return TOOLBAR_EnableButton (hwnd, wParam, lParam);
     4370
     4371    case TB_GETANCHORHIGHLIGHT:
     4372        return TOOLBAR_GetAnchorHighlight (hwnd);
     4373
     4374    case TB_GETBITMAP:
     4375        return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
     4376
     4377    case TB_GETBITMAPFLAGS:
     4378        return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
     4379
     4380    case TB_GETBUTTON:
     4381        return TOOLBAR_GetButton (hwnd, wParam, lParam);
     4382
     4383    case TB_GETBUTTONINFOA:
     4384        return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
     4385
     4386    case TB_GETBUTTONINFOW:
     4387        return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
     4388
     4389    case TB_GETBUTTONSIZE:
     4390        return TOOLBAR_GetButtonSize (hwnd);
     4391
     4392    case TB_GETBUTTONTEXTA:
     4393        return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
     4394
     4395    case TB_GETBUTTONTEXTW:
     4396        return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
     4397
     4398/*  case TB_GETCOLORSCHEME:         */ /* 4.71 */
     4399
     4400    case TB_GETDISABLEDIMAGELIST:
     4401        return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
     4402
     4403    case TB_GETEXTENDEDSTYLE:
     4404        return TOOLBAR_GetExtendedStyle (hwnd);
     4405
     4406    case TB_GETHOTIMAGELIST:
     4407        return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
     4408
     4409    case TB_GETHOTITEM:
     4410        return TOOLBAR_GetHotItem (hwnd);
     4411
     4412    case TB_GETIMAGELIST:
     4413        return TOOLBAR_GetImageList (hwnd, wParam, lParam);
     4414
     4415/*  case TB_GETINSERTMARK:          */ /* 4.71 */
     4416/*  case TB_GETINSERTMARKCOLOR:     */ /* 4.71 */
     4417
     4418    case TB_GETITEMRECT:
     4419        return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
     4420
     4421    case TB_GETMAXSIZE:
     4422        return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
     4423
     4424/*  case TB_GETOBJECT:          */ /* 4.71 */
     4425/*  case TB_GETPADDING:         */ /* 4.71 */
     4426
     4427    case TB_GETRECT:
     4428        return TOOLBAR_GetRect (hwnd, wParam, lParam);
     4429
     4430    case TB_GETROWS:
     4431        return TOOLBAR_GetRows (hwnd, wParam, lParam);
     4432
     4433    case TB_GETSTATE:
     4434        return TOOLBAR_GetState (hwnd, wParam, lParam);
     4435
     4436    case TB_GETSTYLE:
     4437        return TOOLBAR_GetStyle (hwnd, wParam, lParam);
     4438
     4439    case TB_GETTEXTROWS:
     4440        return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
     4441
     4442    case TB_GETTOOLTIPS:
     4443        return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
     4444
     4445    case TB_GETUNICODEFORMAT:
     4446        return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
     4447
     4448    case CCM_GETVERSION:
     4449        return TOOLBAR_GetVersion (hwnd);
     4450
     4451    case TB_HIDEBUTTON:
     4452        return TOOLBAR_HideButton (hwnd, wParam, lParam);
     4453
     4454    case TB_HITTEST:
     4455        return TOOLBAR_HitTest (hwnd, wParam, lParam);
     4456
     4457    case TB_INDETERMINATE:
     4458        return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
     4459
     4460    case TB_INSERTBUTTONA:
     4461        return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
     4462
     4463    case TB_INSERTBUTTONW:
     4464        return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
     4465
     4466/*  case TB_INSERTMARKHITTEST:      */ /* 4.71 */
     4467
     4468    case TB_ISBUTTONCHECKED:
     4469        return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
     4470
     4471    case TB_ISBUTTONENABLED:
     4472        return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
     4473
     4474    case TB_ISBUTTONHIDDEN:
     4475        return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
     4476
     4477    case TB_ISBUTTONHIGHLIGHTED:
     4478        return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
     4479
     4480    case TB_ISBUTTONINDETERMINATE:
     4481        return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
     4482
     4483    case TB_ISBUTTONPRESSED:
     4484        return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
     4485
     4486    case TB_LOADIMAGES:            /* 4.70 */
     4487        FIXME("missing standard imagelists\n");
     4488        return 0;
     4489
     4490/*  case TB_MAPACCELERATORA:        */ /* 4.71 */
     4491/*  case TB_MAPACCELERATORW:        */ /* 4.71 */
     4492/*  case TB_MARKBUTTON:         */ /* 4.71 */
     4493/*  case TB_MOVEBUTTON:         */ /* 4.71 */
     4494
     4495    case TB_PRESSBUTTON:
     4496        return TOOLBAR_PressButton (hwnd, wParam, lParam);
     4497
     4498/*  case TB_REPLACEBITMAP: */
     4499
     4500    case TB_SAVERESTOREA:
     4501        return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
     4502
     4503    case TB_SAVERESTOREW:
     4504        return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
     4505
     4506    case TB_SETANCHORHIGHLIGHT:
     4507        return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
     4508
     4509    case TB_SETBITMAPSIZE:
     4510        return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
     4511
     4512    case TB_SETBUTTONINFOA:
     4513        return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
     4514
     4515    case TB_SETBUTTONINFOW:
     4516        return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
     4517
     4518    case TB_SETBUTTONSIZE:
     4519        return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
     4520
     4521    case TB_SETBUTTONWIDTH:
     4522        return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
     4523
     4524    case TB_SETCMDID:
     4525        return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
     4526
     4527/*  case TB_SETCOLORSCHEME:         */ /* 4.71 */
     4528
     4529    case TB_SETDISABLEDIMAGELIST:
     4530        return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
     4531
     4532    case TB_SETDRAWTEXTFLAGS:
     4533        return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
     4534
     4535    case TB_SETEXTENDEDSTYLE:
     4536        return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
     4537
     4538    case TB_SETHOTIMAGELIST:
     4539        return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
     4540
     4541    case TB_SETHOTITEM:
     4542        return TOOLBAR_SetHotItem (hwnd, wParam);
     4543
     4544    case TB_SETIMAGELIST:
     4545        return TOOLBAR_SetImageList (hwnd, wParam, lParam);
     4546
     4547    case TB_SETINDENT:
     4548        return TOOLBAR_SetIndent (hwnd, wParam, lParam);
     4549
     4550/*  case TB_SETINSERTMARK:          */ /* 4.71 */
     4551
     4552    case TB_SETINSERTMARKCOLOR:
     4553        return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
     4554
     4555    case TB_SETMAXTEXTROWS:
     4556        return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
     4557
     4558/*  case TB_SETPADDING:         */ /* 4.71 */
     4559
     4560    case TB_SETPARENT:
     4561        return TOOLBAR_SetParent (hwnd, wParam, lParam);
     4562
     4563    case TB_SETROWS:
     4564        return TOOLBAR_SetRows (hwnd, wParam, lParam);
     4565
     4566    case TB_SETSTATE:
     4567        return TOOLBAR_SetState (hwnd, wParam, lParam);
     4568
     4569    case TB_SETSTYLE:
     4570        return TOOLBAR_SetStyle (hwnd, wParam, lParam);
     4571
     4572    case TB_SETTOOLTIPS:
     4573        return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
     4574
     4575    case TB_SETUNICODEFORMAT:
     4576        return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
     4577
     4578    case CCM_SETVERSION:
     4579        return TOOLBAR_SetVersion (hwnd, (INT)wParam);
     4580
     4581
     4582/*  case WM_CHAR: */
     4583
     4584    case WM_CREATE:
     4585        return TOOLBAR_Create (hwnd, wParam, lParam);
     4586
     4587    case WM_DESTROY:
     4588      return TOOLBAR_Destroy (hwnd, wParam, lParam);
     4589
     4590    case WM_ERASEBKGND:
     4591        return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
     4592
     4593    case WM_GETFONT:
     4594        return TOOLBAR_GetFont (hwnd, wParam, lParam);
     4595
     4596/*  case WM_KEYDOWN: */
     4597/*  case WM_KILLFOCUS: */
     4598
     4599    case WM_LBUTTONDBLCLK:
     4600        return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
     4601
     4602    case WM_LBUTTONDOWN:
     4603        return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
     4604
     4605    case WM_LBUTTONUP:
     4606        return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
     4607
     4608    case WM_MOUSEMOVE:
     4609        return TOOLBAR_MouseMove (hwnd, wParam, lParam);
     4610
     4611    case WM_MOUSELEAVE:
     4612        return TOOLBAR_MouseLeave (hwnd, wParam, lParam);
     4613
     4614    case WM_CAPTURECHANGED:
     4615        return TOOLBAR_CaptureChanged(hwnd);
     4616
     4617    case WM_NCACTIVATE:
     4618        return TOOLBAR_NCActivate (hwnd, wParam, lParam);
     4619
     4620    case WM_NCCALCSIZE:
     4621        return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
     4622
     4623    case WM_NCCREATE:
     4624        return TOOLBAR_NCCreate (hwnd, wParam, lParam);
     4625
     4626    case WM_NCPAINT:
     4627        return TOOLBAR_NCPaint (hwnd, wParam, lParam);
     4628
     4629    case WM_NOTIFY:
     4630        return TOOLBAR_Notify (hwnd, wParam, lParam);
     4631
     4632/*  case WM_NOTIFYFORMAT: */
     4633
     4634    case WM_PAINT:
     4635        return TOOLBAR_Paint (hwnd, wParam);
     4636
     4637    case WM_SIZE:
     4638        return TOOLBAR_Size (hwnd, wParam, lParam);
     4639
     4640    case WM_STYLECHANGED:
     4641        return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
     4642
     4643/*  case WM_SYSCOLORCHANGE: */
     4644
     4645/*  case WM_WININICHANGE: */
     4646
     4647    case WM_CHARTOITEM:
     4648    case WM_COMMAND:
     4649    case WM_DRAWITEM:
     4650    case WM_MEASUREITEM:
     4651    case WM_VKEYTOITEM:
     4652        return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
     4653
     4654    default:
     4655        if (uMsg >= WM_USER)
     4656        ERR("unknown msg %04x wp=%08x lp=%08lx\n",
     4657             uMsg, wParam, lParam);
     4658        return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    46584659    }
    46594660    return 0;
     
    46744675    wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
    46754676    wndClass.lpszClassName = TOOLBARCLASSNAMEA;
    4676  
     4677
    46774678    RegisterClassA (&wndClass);
    46784679}
Note: See TracChangeset for help on using the changeset viewer.