Changeset 10538 for trunk/src


Ignore:
Timestamp:
Mar 17, 2004, 5:59:41 PM (21 years ago)
Author:
sandervl
Message:

put back old version

File:
1 edited

Legend:

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

    r10535 r10538  
    1919 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2020 *
    21  * NOTES
    22  *
    2321 *  Differences between MSDN and actual native control operation:
    2422 *   1. MSDN says: "TBSTYLE_LIST: Creates a flat toolbar with button text
     
    3028 *      *not* imply TBSTYLE_FLAT as documented.  (GA 8/2001)
    3129 *
    32  * This code was audited for completeness against the documented features
    33  * of Comctl32.dll version 6.0 on Mar. 14, 2004, by Robert Shearman.
    34  *
    35  * Unless otherwise noted, we believe this code to be complete, as per
    36  * the specification mentioned above.
    37  * If you discover missing features or bugs please note them below.
    38  *
     30 *
    3931 * TODO:
    4032 *   - Button wrapping (under construction).
    41  *   - Messages:
    42  *     - TB_GETINSERTMARK
    43  *     - TB_GETINSERTMARKCOLOR
    44  *     - TB_GETMETRICS
    45  *     - TB_GETOBJECT
    46  *     - TB_INSERTMARKHITTEST
    47  *     - TB_MOVEBUTTON
    48  *     - TB_SETINSERTMARK
    49  *     - TB_SETMETRICS
    50  *   - Notifications:
    51  *     - NM_CHAR
    52  *     - NM_KEYDOWN
    53  *     - NM_LDOWN
    54  *     - NM_RCLICK
    55  *     - NM_RDBLCLICK
    56  *     - TBN_DELETINGBUTTON
    57  *     - TBN_DRAGOUT
    58  *     - TBN_GETOBJECT
    59  *     - TBN_RESTORE
    60  *     - TBN_SAVE
    61  *     - TBN_TOOLBARCHANGE
     33 *   - Messages.
     34 *   - Notifications (under construction).
    6235 *   - Fix TB_SETROWS.
     36 *   - Tooltip support (almost complete).
     37 *   - Unicode suppport (under construction).
    6338 *   - Fix TOOLBAR_SetButtonInfo32A/W.
    64  *   - iListGap custom draw support.
     39 *   - TBSTYLE_AUTOSIZE for toolbar and buttons.
     40 *   - I_IMAGECALLBACK support.
     41 *   - iString of -1 is undocumented
    6542 *   - Customization dialog:
     43 *      - Add flat look.
    6644 *      - Minor buglet in 'available buttons' list:
    67  *        Buttons are not listed in MS-like order. MS seems to use a single
     45 *        Buttons are not listed in M$-like order. M$ seems to use a single
    6846 *        internal list to store the button information of both listboxes.
    6947 *      - Drag list support.
     48 *      - Help and Reset button support.
    7049 *
    7150 * Testing:
     
    8059 */
    8160
    82 #include <stdarg.h>
    8361#include <string.h>
    8462
     63#include "winbase.h"
    8564#include "windef.h"
    86 #include "winbase.h"
    8765#include "wingdi.h"
    8866#include "winuser.h"
    8967#include "wine/unicode.h"
    90 #include "winnls.h"
    9168#include "commctrl.h"
    9269#include "imagelist.h"
     
    128105    INT      nHeight;        /* height of the toolbar */
    129106    INT      nWidth;         /* width of the toolbar */
    130     RECT     client_rect;
    131107    INT      nButtonHeight;
    132108    INT      nButtonWidth;
     
    151127    DWORD    dwItemCDFlag;    /* TBCDRF_ flags from last ITEMPREPAINT    */
    152128    SIZE     szPadding;       /* padding values around button */
    153     INT      iListGap;        /* default gap between text and image for toolbar with list style */
    154129    HFONT    hDefaultFont;
    155130    HFONT    hFont;           /* text font */
     
    178153    RECT     rcBound;         /* bounding rectangle */
    179154    INT      iVersion;
    180     LPWSTR   pszTooltipText;    /* temporary store for a string > 80 characters
    181                                  * for TTN_GETDISPINFOW notification */
     155
    182156    TBUTTON_INFO *buttons;      /* pointer to button array */
    183157    LPWSTR       *strings;      /* pointer to string array */
     
    201175} CUSTOMBUTTON, *PCUSTOMBUTTON;
    202176
    203 typedef enum
    204 {
    205     IMAGE_LIST_DEFAULT,
    206     IMAGE_LIST_HOT,
    207     IMAGE_LIST_DISABLED
    208 } IMAGE_LIST_TYPE;
    209177
    210178#define SEPARATOR_WIDTH    8
     
    212180#define BOTTOM_BORDER      2
    213181#define DDARROW_WIDTH      11
    214 #define ARROW_HEIGHT       3
    215 
    216 /* gap between border of button and text/image */
    217 #define OFFSET_X 1
    218 #define OFFSET_Y 1
    219 /* how wide to treat the bitmap if it isn't present */
    220 #define LIST_IMAGE_ABSENT_WIDTH 2
    221182
    222183#define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
    223184#define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
    224185#define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
    225 
    226 #ifdef __WIN32OS2__
    227 static inline const char *wine_dbgstr_rect( const RECT *rect )
    228 {
    229     return "rect (null)";
    230 }
    231 #endif
    232 
    233 static inline int TOOLBAR_GetListTextOffset(TOOLBAR_INFO *infoPtr, INT iListGap)
    234 {
    235     return GetSystemMetrics(SM_CXEDGE) + iListGap - infoPtr->szPadding.cx/2;
    236 }
    237186
    238187/* Used to find undocumented extended styles */
     
    406355
    407356/***********************************************************************
    408 *               TOOLBAR_GetImageListForDrawing
     357*               TOOLBAR_DrawImageList
    409358*
    410359* This function validates the bitmap index (including I_IMAGECALLBACK
    411 * functionality) and returns the corresponding image list.
    412 */
    413 static HIMAGELIST
    414 TOOLBAR_GetImageListForDrawing (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, IMAGE_LIST_TYPE imagelist, INT * index)
    415 {
    416     HIMAGELIST himl;
    417 
    418     if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
    419         if (btnPtr->iBitmap == I_IMAGENONE) return NULL;
    420         ERR("index %d,%d is not valid, max %d\n",
    421             HIWORD(btnPtr->iBitmap), LOWORD(btnPtr->iBitmap), infoPtr->nNumBitmaps);
    422         return NULL;
    423     }
    424 
    425     if ((*index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
    426         if ((*index == I_IMAGECALLBACK) ||
    427             (*index == I_IMAGENONE)) return NULL;
    428         ERR("TBN_GETDISPINFO returned invalid index %d\n",
    429             *index);
    430         return NULL;
    431     }
    432 
    433     switch(imagelist)
    434     {
    435     case IMAGE_LIST_DEFAULT:
    436         himl = GETDEFIMAGELIST(infoPtr, GETHIMLID(infoPtr, btnPtr->iBitmap));
    437         break;
    438     case IMAGE_LIST_HOT:
    439         himl = GETHOTIMAGELIST(infoPtr, GETHIMLID(infoPtr, btnPtr->iBitmap));
    440         break;
    441     case IMAGE_LIST_DISABLED:
    442         himl = GETDISIMAGELIST(infoPtr, GETHIMLID(infoPtr, btnPtr->iBitmap));
    443         break;
    444     default:
    445         himl = NULL;
    446         FIXME("Shouldn't reach here\n");
    447     }
    448 
    449     if (!himl)
    450        TRACE("no image list\n");
    451 
    452     return himl;
    453 }
    454 
    455 
    456 /***********************************************************************
    457 *               TOOLBAR_TestImageExist
    458 *
    459 * This function is similar to TOOLBAR_GetImageListForDrawing, except it does not
    460 * return the image list. The I_IMAGECALLBACK functionality is implemented.
     360* functionality). It then draws the image via the ImageList_Draw
     361* function. It returns TRUE if the image was drawn, FALSE otherwise.
    461362*/
    462363static BOOL
    463 TOOLBAR_TestImageExist (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl)
     364TOOLBAR_DrawImageList (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl,
     365                        HDC hdc, UINT left, UINT top, UINT draw_flags)
    464366{
    465367    INT index;
     
    481383        return FALSE;
    482384    }
     385    TRACE("drawing index=%d, himl=%p, left=%d, top=%d, flags=%08x\n",
     386          index, himl, left, top, draw_flags);
     387
     388    ImageList_Draw (himl, index, hdc, left, top, draw_flags);
     389    return TRUE;
     390}
     391
     392
     393/***********************************************************************
     394*               TOOLBAR_TestImageExist
     395*
     396* This function is similar to TOOLBAR_DrawImageList, except it does not
     397* draw the image. The I_IMAGECALLBACK functionality is implemented.
     398*/
     399static BOOL
     400TOOLBAR_TestImageExist (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl)
     401{
     402    INT index;
     403
     404    if (!himl) return FALSE;
     405
     406    if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
     407        if (btnPtr->iBitmap == I_IMAGENONE) return FALSE;
     408        ERR("index %d is not valid, max %d\n",
     409            btnPtr->iBitmap, infoPtr->nNumBitmaps);
     410        return FALSE;
     411    }
     412
     413    if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
     414        if ((index == I_IMAGECALLBACK) ||
     415            (index == I_IMAGENONE)) return FALSE;
     416        ERR("TBN_GETDISPINFO returned invalid index %d\n",
     417            index);
     418        return FALSE;
     419    }
    483420    return TRUE;
    484421}
     
    516453*               TOOLBAR_DrawDDFlatSeparator
    517454*
    518 * This function draws the separator that was flagged as BTNS_DROPDOWN.
     455* This function draws the separator that was flaged as TBSTYLE_DROPDOWN.
    519456* In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
    520457* followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
     
    558495
    559496static void
    560 TOOLBAR_DrawArrow (HDC hdc, INT left, INT top, COLORREF clr)
     497TOOLBAR_DrawArrow (HDC hdc, INT left, INT top, INT colorRef)
    561498{
    562499    INT x, y;
    563500    HPEN hPen, hOldPen;
    564501
    565     if (!(hPen = CreatePen( PS_SOLID, 1, clr))) return;
     502    if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
    566503    hOldPen = SelectObject ( hdc, hPen );
    567504    x = left + 2;
    568     y = top;
     505    y = top + 8;
    569506    MoveToEx (hdc, x, y, NULL);
    570507    LineTo (hdc, x+5, y++); x++;
     
    584521 */
    585522static void
    586 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, RECT *rcText, LPWSTR lpText,
    587                     NMTBCUSTOMDRAW *tbcd)
    588 {
    589     HDC hdc = tbcd->nmcd.hdc;
     523TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
     524                    HDC hdc, INT nState, DWORD dwStyle,
     525                    RECT *rcText, LPWSTR lpText, NMTBCUSTOMDRAW *tbcd)
     526{
    590527    HFONT  hOldFont = 0;
    591528    COLORREF clrOld = 0;
    592     COLORREF clrOldBk = 0;
    593     int oldBkMode = 0;
    594     UINT state = tbcd->nmcd.uItemState;
    595529
    596530    /* draw text */
    597531    if (lpText) {
    598         TRACE("string=%s rect=(%ld,%ld)-(%ld,%ld)\n", debugstr_w(lpText),
     532        TRACE("string rect=(%ld,%ld)-(%ld,%ld)\n",
    599533              rcText->left, rcText->top, rcText->right, rcText->bottom);
    600534
    601535        hOldFont = SelectObject (hdc, infoPtr->hFont);
    602         if ((state & CDIS_HOT) && (infoPtr->dwItemCDFlag & TBCDRF_HILITEHOTTRACK )) {
    603             clrOld = SetTextColor (hdc, tbcd->clrTextHighlight);
    604         }
    605         else if (state & CDIS_DISABLED) {
     536        if (!(nState & TBSTATE_ENABLED)) {
    606537            clrOld = SetTextColor (hdc, tbcd->clrBtnHighlight);
    607538            OffsetRect (rcText, 1, 1);
     
    610541            OffsetRect (rcText, -1, -1);
    611542        }
    612         else if (state & CDIS_INDETERMINATE) {
     543        else if (nState & TBSTATE_INDETERMINATE) {
    613544            clrOld = SetTextColor (hdc, comctl32_color.clr3dShadow);
    614545        }
    615         else if ((state & CDIS_MARKED) && !(infoPtr->dwItemCDFlag & TBCDRF_NOMARK)) {
     546        else if (btnPtr->bHot && (infoPtr->dwItemCDFlag & TBCDRF_HILITEHOTTRACK )) {
    616547            clrOld = SetTextColor (hdc, tbcd->clrTextHighlight);
    617             clrOldBk = SetBkColor (hdc, tbcd->clrMark);
    618             oldBkMode = SetBkMode (hdc, OPAQUE); /* FIXME: should this be in the NMTBCUSTOMDRAW structure? */
    619548        }
    620549        else {
     
    624553        DrawTextW (hdc, lpText, -1, rcText, infoPtr->dwDTFlags);
    625554        SetTextColor (hdc, clrOld);
    626         if ((state & CDIS_MARKED) && !(infoPtr->dwItemCDFlag & TBCDRF_NOMARK))
    627         {
    628             SetBkColor (hdc, clrOldBk);
    629             SetBkMode (hdc, oldBkMode);
    630         }
    631555        SelectObject (hdc, hOldFont);
    632556    }
     
    635559
    636560static void
    637 TOOLBAR_DrawPattern (LPRECT lpRect, NMTBCUSTOMDRAW *tbcd)
    638 {
    639     HDC hdc = tbcd->nmcd.hdc;
    640     HBRUSH hbr = SelectObject (hdc, tbcd->hbrMonoDither);
    641     COLORREF clrTextOld;
    642     COLORREF clrBkOld;
     561TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
     562{
     563    HBRUSH hbr = SelectObject (hdc, COMCTL32_hPattern55AABrush);
    643564    INT cx = lpRect->right - lpRect->left;
    644565    INT cy = lpRect->bottom - lpRect->top;
    645     clrTextOld = SetTextColor(hdc, tbcd->clrBtnHighlight);
    646     clrBkOld = SetBkColor(hdc, tbcd->clrBtnFace);
    647     PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, PATCOPY);
    648     SetBkColor(hdc, clrBkOld);
    649     SetTextColor(hdc, clrTextOld);
     566    PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
    650567    SelectObject (hdc, hbr);
    651568}
    652569
    653570
    654 static void TOOLBAR_DrawMasked(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
    655                                HDC hdc, INT x, INT y)
     571static void
     572TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
     573                    HDC hdc, INT x, INT y)
    656574{
    657575    HIMAGELIST himl = GETDEFIMAGELIST(infoPtr, 0);
    658 
    659     if (himl)
    660     {
    661         INT cx, cy;
    662         HBITMAP hbmMask, hbmImage;
    663         HDC hdcMask, hdcImage;
    664 
    665         ImageList_GetIconSize(himl, &cx, &cy);
    666 
    667         /* Create src image */
    668         hdcImage = CreateCompatibleDC(hdc);
    669         hbmImage = CreateBitmap(cx, cy, GetDeviceCaps(hdc,PLANES),
    670                                 GetDeviceCaps(hdc,BITSPIXEL), NULL);
    671         SelectObject(hdcImage, hbmImage);
    672         ImageList_DrawEx(himl, btnPtr->iBitmap, hdcImage, 0, 0, cx, cy,
    673                          RGB(0xff, 0xff, 0xff), RGB(0,0,0), ILD_NORMAL);
    674 
    675         /* Create Mask */
    676         hdcMask = CreateCompatibleDC(0);
    677         hbmMask = CreateBitmap(cx, cy, 1, 1, NULL);
    678         SelectObject(hdcMask, hbmMask);
    679 
    680         /* Remove the background and all white pixels */
    681         SetBkColor(hdcImage, ImageList_GetBkColor(himl));
    682         BitBlt(hdcMask, 0, 0, cx, cy, hdcImage, 0, 0, SRCCOPY);
    683         SetBkColor(hdcImage, RGB(0xff, 0xff, 0xff));
    684         BitBlt(hdcMask, 0, 0, cx, cy, hdcImage, 0, 0, NOTSRCERASE);
    685 
    686         /* draw the new mask 'etched' to hdc */
    687         SetBkColor(hdc, RGB(255, 255, 255));
    688         SelectObject(hdc, GetSysColorBrush(COLOR_3DHILIGHT));
    689         BitBlt(hdc, x + 1, y + 1, cx, cy, hdcMask, 0, 0, 0xE20746);
    690         SelectObject(hdc, GetSysColorBrush(COLOR_3DSHADOW));
    691         BitBlt(hdc, x, y, cx, cy, hdcMask, 0, 0, 0xE20746);
    692 
    693         /* Cleanup */
    694         DeleteObject(hbmImage);
    695         DeleteDC(hdcImage);
    696         DeleteObject (hbmMask);
    697         DeleteDC(hdcMask);
    698     }
     576    INT cx, cy;
     577    HBITMAP hbmMask;
     578    HDC hdcMask;
     579
     580    if (!himl)
     581        return;
     582
     583    ImageList_GetIconSize(himl, &cx, &cy);
     584
     585    /* create new dc's */
     586    hdcMask = CreateCompatibleDC (0);
     587
     588    /* create new bitmap */
     589    hbmMask = CreateBitmap (cx, cy, 1, 1, NULL);
     590    SelectObject (hdcMask, hbmMask);
     591
     592    /* copy the mask bitmap */
     593    ImageList_DrawEx(himl, btnPtr->iBitmap, hdcMask, 0, 0, 0, 0, RGB(255, 255, 255), RGB(0, 0, 0), ILD_MASK);
     594
     595    /* draw the new mask */
     596    SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
     597    BitBlt (hdc, x+1, y+1, cx, cy, hdcMask, 0, 0, 0xB8074A);
     598
     599    SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
     600    BitBlt (hdc, x, y, cx, cy, hdcMask, 0, 0, 0xB8074A);
     601
     602    DeleteObject (hbmMask);
     603    DeleteDC (hdcMask);
    699604}
    700605
     
    716621}
    717622
    718 /* draws the image on a toolbar button */
    719 static void
    720 TOOLBAR_DrawImage(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, INT left, INT top, const NMTBCUSTOMDRAW *tbcd)
    721 {
    722     HIMAGELIST himl = NULL;
    723     BOOL draw_masked = FALSE;
    724     INT index;
    725     INT offset = 0;
    726     UINT draw_flags = ILD_NORMAL;
    727 
    728     if (tbcd->nmcd.uItemState & (CDIS_DISABLED | CDIS_INDETERMINATE))
    729     {
    730         himl = TOOLBAR_GetImageListForDrawing(infoPtr, btnPtr, IMAGE_LIST_DISABLED, &index);
    731         if (!himl)
    732            draw_masked = TRUE;
    733     }
    734     else if ((tbcd->nmcd.uItemState & CDIS_HOT) && (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & TBSTYLE_FLAT))
    735     {
    736         /* if hot, attempt to draw with hot image list, if fails,
    737            use default image list */
    738         himl = TOOLBAR_GetImageListForDrawing(infoPtr, btnPtr, IMAGE_LIST_HOT, &index);
    739         if (!himl)
    740             himl = TOOLBAR_GetImageListForDrawing(infoPtr, btnPtr, IMAGE_LIST_DEFAULT, &index);
    741         }
    742     else
    743         himl = TOOLBAR_GetImageListForDrawing(infoPtr, btnPtr, IMAGE_LIST_DEFAULT, &index);
    744 
    745     if (!(infoPtr->dwItemCDFlag & TBCDRF_NOOFFSET) &&
    746         (tbcd->nmcd.uItemState & (CDIS_SELECTED | CDIS_CHECKED)))
    747         offset = 1;
    748 
    749     if (!(infoPtr->dwItemCDFlag & TBCDRF_NOMARK) &&
    750         (tbcd->nmcd.uItemState & CDIS_MARKED))
    751         draw_flags |= ILD_BLEND50;
    752 
    753     TRACE("drawing index=%d, himl=%p, left=%d, top=%d, offset=%d\n",
    754       index, himl, left, top, offset);
    755 
    756     if (draw_masked)
    757         TOOLBAR_DrawMasked (infoPtr, btnPtr, tbcd->nmcd.hdc, left + offset, top + offset);
    758     else if (himl)
    759         ImageList_Draw (himl, index, tbcd->nmcd.hdc, left + offset, top + offset, draw_flags);
    760 }
    761 
    762 /* draws a blank frame for a toolbar button */
    763 static void
    764 TOOLBAR_DrawFrame(const TOOLBAR_INFO *infoPtr, BOOL flat, const NMTBCUSTOMDRAW *tbcd)
    765 {
    766     HDC hdc = tbcd->nmcd.hdc;
    767     RECT rc = tbcd->nmcd.rc;
    768     /* if the state is disabled or indeterminate then the button
    769      * cannot have an interactive look like pressed or hot */
    770     BOOL non_interactive_state = (tbcd->nmcd.uItemState & CDIS_DISABLED) ||
    771                                  (tbcd->nmcd.uItemState & CDIS_INDETERMINATE);
    772     BOOL pressed_look = !non_interactive_state &&
    773                         ((tbcd->nmcd.uItemState & CDIS_SELECTED) ||
    774                          (tbcd->nmcd.uItemState & CDIS_CHECKED));
    775 
    776     /* app don't want us to draw any edges */
    777     if (infoPtr->dwItemCDFlag & TBCDRF_NOEDGES)
    778         return;
    779 
    780     if (flat)
    781     {
    782         if (pressed_look)
    783             DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
    784         else if ((tbcd->nmcd.uItemState & CDIS_HOT) && !non_interactive_state)
    785             DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT);
    786     }
    787     else
    788     {
    789         if (pressed_look)
    790             DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE);
    791         else
    792             DrawEdge (hdc, &rc, EDGE_RAISED,
    793               BF_SOFT | BF_RECT | BF_MIDDLE);
    794     }
    795 }
    796 
    797 static void
    798 TOOLBAR_DrawSepDDArrow(const TOOLBAR_INFO *infoPtr, BOOL flat, const NMTBCUSTOMDRAW *tbcd, RECT *rcArrow)
    799 {
    800     HDC hdc = tbcd->nmcd.hdc;
    801     int offset = 0;
    802 
    803     if (flat)
    804     {
    805         if ((tbcd->nmcd.uItemState & CDIS_SELECTED) || (tbcd->nmcd.uItemState & CDIS_CHECKED))
    806             DrawEdge (hdc, rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
    807         else if ( (tbcd->nmcd.uItemState & CDIS_HOT) &&
    808                  !(tbcd->nmcd.uItemState & CDIS_DISABLED) &&
    809                  !(tbcd->nmcd.uItemState & CDIS_INDETERMINATE))
    810             DrawEdge (hdc, rcArrow, BDR_RAISEDINNER, BF_RECT);
    811     }
    812     else
    813     {
    814         if ((tbcd->nmcd.uItemState & CDIS_SELECTED) || (tbcd->nmcd.uItemState & CDIS_CHECKED))
    815             DrawEdge (hdc, rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
    816         else
    817             DrawEdge (hdc, rcArrow, EDGE_RAISED,
    818               BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    819     }
    820 
    821     if (tbcd->nmcd.uItemState & (CDIS_SELECTED | CDIS_CHECKED))
    822         offset = (infoPtr->dwItemCDFlag & TBCDRF_NOOFFSET) ? 0 : 1;
    823 
    824     if (tbcd->nmcd.uItemState & (CDIS_DISABLED | CDIS_INDETERMINATE))
    825     {
    826         TOOLBAR_DrawArrow(hdc, rcArrow->left+1, rcArrow->top+1 + (rcArrow->bottom - rcArrow->top - ARROW_HEIGHT) / 2, comctl32_color.clrBtnHighlight);
    827         TOOLBAR_DrawArrow(hdc, rcArrow->left, rcArrow->top + (rcArrow->bottom - rcArrow->top - ARROW_HEIGHT) / 2, comctl32_color.clr3dShadow);
    828     }
    829     else
    830         TOOLBAR_DrawArrow(hdc, rcArrow->left + offset, rcArrow->top + offset + (rcArrow->bottom - rcArrow->top - ARROW_HEIGHT) / 2, comctl32_color.clrBtnText);
    831 }
    832 
    833 /* draws a complete toolbar button */
     623
    834624static void
    835625TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
     
    837627    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    838628    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    839     BOOL hasDropDownArrow = (TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) &&
    840                             (btnPtr->fsStyle & BTNS_DROPDOWN)) ||
    841                             (btnPtr->fsStyle & BTNS_WHOLEDROPDOWN);
    842     BOOL drawSepDropDownArrow = hasDropDownArrow &&
    843                                 (~btnPtr->fsStyle & BTNS_WHOLEDROPDOWN);
    844     RECT rc, rcArrow, rcBitmap, rcText;
     629    BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) &&
     630                            (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
     631    RECT rc, rcArrow, rcBitmap, rcText, rcFill;
    845632    LPWSTR lpText = NULL;
    846633    NMTBCUSTOMDRAW tbcd;
    847634    DWORD ntfret;
    848635    INT offset;
     636    HIMAGELIST himlDef;
     637
     638    if (btnPtr->fsState & TBSTATE_HIDDEN)
     639        return;
    849640
    850641    rc = btnPtr->rect;
     642    CopyRect (&rcFill, &rc);
    851643    CopyRect (&rcArrow, &rc);
    852644    CopyRect(&rcBitmap, &rc);
     645    CopyRect(&rcText, &rc);
    853646
    854647    /* get a pointer to the text */
     
    857650    if (hasDropDownArrow)
    858651    {
    859         int right;
    860 
    861         if (dwStyle & TBSTYLE_FLAT)
    862             right = max(rc.left, rc.right - DDARROW_WIDTH);
    863         else
    864             right = max(rc.left, rc.right - DDARROW_WIDTH - 2);
    865 
    866         if (drawSepDropDownArrow)
    867            rc.right = right;
    868 
    869         rcArrow.left = right;
    870     }
    871 
    872     /* copy text rect after adjusting for drop-down arrow
    873      * so that text is centred in the rectangle not containing
    874      * the arrow */
    875     CopyRect(&rcText, &rc);
     652        if (dwStyle & TBSTYLE_FLAT)
     653            rc.right = max(rc.left, rc.right - DDARROW_WIDTH);
     654        else
     655            rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2);
     656        rcArrow.left = rc.right;
     657    }
    876658
    877659    /* Center the bitmap horizontally and vertically */
    878660    if (dwStyle & TBSTYLE_LIST)
    879         rcBitmap.left += GetSystemMetrics(SM_CXEDGE) + OFFSET_X;
     661        rcBitmap.left += 3;
    880662    else
    881         rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2;
     663        rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2;
    882664
    883665    if(lpText)
    884         rcBitmap.top+= GetSystemMetrics(SM_CYEDGE) + OFFSET_Y;
     666        rcBitmap.top+=2; /* this looks to be the correct value from vmware comparison - cmm */
    885667    else
    886668        rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2;
    887669
    888670    TRACE("iBitmap: %d, start=(%ld,%ld) w=%d, h=%d\n",
    889       btnPtr->iBitmap, rcBitmap.left, rcBitmap.top,
    890       infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
     671          btnPtr->iBitmap, rcBitmap.left, rcBitmap.top,
     672          infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
    891673    TRACE ("iString: %x\n", btnPtr->iString);
    892674    TRACE ("Stringtext: %s\n", debugstr_w(lpText));
     
    894676    /* draw text */
    895677    if (lpText) {
    896         rcText.left += GetSystemMetrics(SM_CXEDGE) + OFFSET_X;
    897         rcText.right -= GetSystemMetrics(SM_CXEDGE) + OFFSET_X;
    898         if (GETDEFIMAGELIST(infoPtr, GETHIMLID(infoPtr,btnPtr->iBitmap)) &&
    899                 TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    900         {
    901             if (dwStyle & TBSTYLE_LIST)
    902                 rcText.left += infoPtr->nBitmapWidth + TOOLBAR_GetListTextOffset(infoPtr, infoPtr->iListGap);
    903             else
    904                 rcText.top += GetSystemMetrics(SM_CYEDGE) + OFFSET_Y + infoPtr->nBitmapHeight + infoPtr->szPadding.cy/2;
    905         }
    906         else
    907             if (dwStyle & TBSTYLE_LIST)
    908                 rcText.left += LIST_IMAGE_ABSENT_WIDTH + TOOLBAR_GetListTextOffset(infoPtr, infoPtr->iListGap);
    909 
    910         if (btnPtr->fsState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
    911             OffsetRect (&rcText, 1, 1);
    912     }
    913 
    914     /* Initialize fields in all cases, because we use these later
    915      * NOTE: applications can and do alter these to customize their
    916      * toolbars */
     678
     679        InflateRect (&rcText, -3, -3);
     680
     681        if (GETDEFIMAGELIST(infoPtr, 0) &&
     682            TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
     683                /* The following test looked like this before
     684                 * I changed it. IE4 "Links" toolbar would not
     685                 * draw correctly with the original code.  - GA 8/01
     686                 *   ((dwStyle & TBSTYLE_LIST) &&
     687                 *    ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
     688                 *       (btnPtr->iBitmap != I_IMAGENONE))
     689                 */
     690                if (dwStyle & TBSTYLE_LIST) {
     691                    /* LIST style w/ ICON offset is by matching native. */
     692                    /* Matches IE4 "Links" bar.   - GA 8/01             */
     693                    rcText.left += (infoPtr->nBitmapWidth + 2);
     694                }
     695                else {
     696                    rcText.top += infoPtr->nBitmapHeight + 1;
     697                }
     698        }
     699        else {
     700                if (dwStyle & TBSTYLE_LIST) {
     701                    /* LIST style w/o ICON offset is by matching native. */
     702                    /* Matches IE4 "menu" bar.   - GA  8/01              */
     703                    rcText.left += 4;
     704                }
     705        }
     706
     707        if (btnPtr->fsState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
     708            OffsetRect (&rcText, 1, 1);
     709    }
     710
     711    /* Initialize fields in all cases, because we use these later */
    917712    ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
    918713    tbcd.clrText = comctl32_color.clrBtnText;
     
    924719    tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
    925720    tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
    926     /* MSDN says that this is the text rectangle.
    927      * But (why always a but) tracing of v5.7 of native shows
    928      * that this is really a *relative* rectangle based on the
    929      * the nmcd.rc. Also the left and top are always 0 ignoring
    930      * any bitmap that might be present. */
     721    /* MSDN says that this is the text rectangle.              */
     722    /* But (why always a but) tracing of v5.7 of native shows  */
     723    /* that this is really a *relative* rectangle based on the */
     724    /* the nmcd.rc. Also the left and top are always 0 ignoring*/
     725    /* any bitmap that might be present.                      */
    931726    tbcd.rcText.left = 0;
    932727    tbcd.rcText.top = 0;
    933728    tbcd.rcText.right = rcText.right - rc.left;
    934729    tbcd.rcText.bottom = rcText.bottom - rc.top;
    935     tbcd.nmcd.uItemState = TOOLBAR_TranslateState(btnPtr);
    936     tbcd.nmcd.hdc = hdc;
    937     tbcd.nmcd.rc = rc;
    938     tbcd.hbrMonoDither = COMCTL32_hPattern55AABrush;
    939 
    940     /* FIXME: what are these used for? */
     730
     731    /* FIXME: what should these be set to ????? */
     732    tbcd.hbrMonoDither = 0;
    941733    tbcd.hbrLines = 0;
    942734    tbcd.hpenLines = 0;
     
    948740    {
    949741        tbcd.nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
     742        tbcd.nmcd.hdc = hdc;
     743        tbcd.nmcd.rc = rc;
    950744        tbcd.nmcd.dwItemSpec = btnPtr->idCommand;
     745        tbcd.nmcd.uItemState = TOOLBAR_TranslateState(btnPtr);
    951746        tbcd.nmcd.lItemlParam = btnPtr->dwData;
    952747        ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
    953         /* reset these fields so the user can't alter the behaviour like native */
    954         tbcd.nmcd.hdc = hdc;
    955         tbcd.nmcd.rc = rc;
    956 
    957748        infoPtr->dwItemCustDraw = ntfret & 0xffff;
    958749        infoPtr->dwItemCDFlag = ntfret & 0xffff0000;
     
    964755    }
    965756
     757    if (!infoPtr->bBtnTranspnt)
     758        FillRect( hdc, &rcFill, GetSysColorBrush(COLOR_BTNFACE));
     759
    966760    /* separator */
    967     if (btnPtr->fsStyle & BTNS_SEP) {
     761    if (btnPtr->fsStyle & TBSTYLE_SEP) {
    968762        /* with the FLAT style, iBitmap is the width and has already */
    969763        /* been taken into consideration in calculating the width    */
     
    972766        /* when drawing the vertical bar...      */
    973767        if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) {
    974             if (btnPtr->fsStyle & BTNS_DROPDOWN)
     768            if (btnPtr->fsStyle & TBSTYLE_DROPDOWN)
    975769                TOOLBAR_DrawDDFlatSeparator (&rc, hdc, btnPtr, infoPtr);
    976770            else
    977771                TOOLBAR_DrawFlatSeparator (&rc, hdc, infoPtr);
    978772        }
    979         else if (btnPtr->fsStyle != BTNS_SEP) {
     773        else if (btnPtr->fsStyle != TBSTYLE_SEP) {
    980774            FIXME("Draw some kind of separator: fsStyle=%x\n",
    981775                  btnPtr->fsStyle);
     
    984778    }
    985779
    986     if (!(tbcd.nmcd.uItemState & CDIS_HOT) &&
    987         ((tbcd.nmcd.uItemState & CDIS_CHECKED) || (tbcd.nmcd.uItemState & CDIS_INDETERMINATE)))
    988         TOOLBAR_DrawPattern (&rc, &tbcd);
    989 
    990     if ((dwStyle & TBSTYLE_FLAT) && (tbcd.nmcd.uItemState & CDIS_HOT))
     780    /* Determine index of image list */
     781    himlDef = GETDEFIMAGELIST(infoPtr, GETHIMLID(infoPtr, btnPtr->iBitmap));
     782
     783    /* disabled */
     784    if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
     785        HIMAGELIST himlDis = GETDISIMAGELIST(infoPtr, GETHIMLID(infoPtr, btnPtr->iBitmap));
     786        if (!(dwStyle & TBSTYLE_FLAT) && !(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
     787        {
     788            DrawEdge (hdc, &rc, EDGE_RAISED,
     789                      BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     790            if (hasDropDownArrow)
     791            DrawEdge (hdc, &rcArrow, EDGE_RAISED,
     792                      BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     793        }
     794
     795        if (hasDropDownArrow)
     796        {
     797            TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT);
     798            TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW);
     799        }
     800
     801        if (!TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDis,
     802                                   hdc, rcBitmap.left, rcBitmap.top,
     803                                   ILD_NORMAL))
     804            TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
     805
     806        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
     807        goto FINALNOTIFY;
     808    }
     809
     810    /* pressed TBSTYLE_BUTTON */
     811    if (btnPtr->fsState & TBSTATE_PRESSED) {
     812        offset = (infoPtr->dwItemCDFlag & TBCDRF_NOOFFSET) ? 0 : 1;
     813        if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
     814        {
     815            if (dwStyle & TBSTYLE_FLAT)
     816            {
     817                DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
     818                if (hasDropDownArrow)
     819                    DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
     820            }
     821            else
     822            {
     823                DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
     824                if (hasDropDownArrow)
     825                    DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
     826            }
     827        }
     828
     829        if (hasDropDownArrow)
     830            TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
     831
     832        TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDef,
     833                               hdc, rcBitmap.left+offset, rcBitmap.top+offset,
     834                               ILD_NORMAL);
     835
     836        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
     837        goto FINALNOTIFY;
     838    }
     839
     840    /* checked TBSTYLE_CHECK */
     841    if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
     842        (btnPtr->fsState & TBSTATE_CHECKED)) {
     843        if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
     844        {
     845            if (dwStyle & TBSTYLE_FLAT)
     846                DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
     847                          BF_RECT | BF_ADJUST);
     848            else
     849                DrawEdge (hdc, &rc, EDGE_SUNKEN,
     850                          BF_RECT | BF_MIDDLE | BF_ADJUST);
     851        }
     852
     853        TOOLBAR_DrawPattern (hdc, &rc);
     854
     855        TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDef,
     856                               hdc, rcBitmap.left+1, rcBitmap.top+1,
     857                               ILD_NORMAL);
     858
     859        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
     860        goto FINALNOTIFY;
     861    }
     862
     863    /* indeterminate */
     864    if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
     865        if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
     866            DrawEdge (hdc, &rc, EDGE_RAISED,
     867                      BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     868
     869        TOOLBAR_DrawPattern (hdc, &rc);
     870        TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
     871        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
     872        goto FINALNOTIFY;
     873    }
     874
     875    /* normal state */
     876    if (dwStyle & TBSTYLE_FLAT)
    991877    {
    992         if ( infoPtr->dwItemCDFlag & TBCDRF_HILITEHOTTRACK )
    993         {
    994             COLORREF oldclr;
    995 
    996             oldclr = SetBkColor(hdc, tbcd.clrHighlightHotTrack);
    997             ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, 0);
     878        if (btnPtr->bHot)
     879        {
     880            if ( infoPtr->dwItemCDFlag & TBCDRF_HILITEHOTTRACK )
     881            {
     882                COLORREF oldclr;
     883
     884                oldclr = SetBkColor(hdc, tbcd.clrHighlightHotTrack);
     885                ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, 0);
     886                if (hasDropDownArrow)
     887                    ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rcArrow, NULL, 0, 0);
     888                SetBkColor(hdc, oldclr);
     889            }
     890            else
     891            {
     892                if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
     893                {
     894                    DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT);
     895                    if (hasDropDownArrow)
     896                        DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT);
     897                }
     898            }
     899        }
     900#if 1
     901        else /* The following code needs to be removed after
     902              * "hot item" support has been implemented for the
     903              * case where it is being de-selected.
     904              */
     905        {
     906            FrameRect(hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
    998907            if (hasDropDownArrow)
    999                 ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rcArrow, NULL, 0, 0);
    1000             SetBkColor(hdc, oldclr);
    1001         }
    1002     }
    1003 
    1004     TOOLBAR_DrawFrame(infoPtr, dwStyle & TBSTYLE_FLAT, &tbcd);
    1005 
    1006     if (drawSepDropDownArrow)
    1007         TOOLBAR_DrawSepDDArrow(infoPtr, dwStyle & TBSTYLE_FLAT, &tbcd, &rcArrow);
    1008 
    1009     if (!(infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) || (btnPtr->fsStyle & BTNS_SHOWTEXT))
    1010         TOOLBAR_DrawString (infoPtr, &rcText, lpText, &tbcd);
    1011 
    1012     TOOLBAR_DrawImage(infoPtr, btnPtr, rcBitmap.left, rcBitmap.top, &tbcd);
    1013 
    1014     if (hasDropDownArrow && !drawSepDropDownArrow)
     908            FrameRect(hdc, &rcArrow, GetSysColorBrush(COLOR_BTNFACE));
     909        }
     910#endif
     911
     912        if (hasDropDownArrow)
     913            TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME);
     914
     915        if (btnPtr->bHot) {
     916            HIMAGELIST himlHot = GETHOTIMAGELIST(infoPtr,
     917                GETHIMLID(infoPtr, btnPtr->iBitmap));
     918            /* if hot, attempt to draw with himlHot, if fails, use himlDef */
     919            if (!TOOLBAR_DrawImageList (infoPtr, btnPtr,
     920                                        himlHot,
     921                                        hdc, rcBitmap.left,
     922                                        rcBitmap.top, ILD_NORMAL))
     923                TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDef,
     924                                       hdc, rcBitmap.left, rcBitmap.top,
     925                                       ILD_NORMAL);
     926        }
     927        else
     928            TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDef,
     929                                   hdc, rcBitmap.left, rcBitmap.top,
     930                                   ILD_NORMAL);
     931    }
     932    else
    1015933    {
    1016         if (tbcd.nmcd.uItemState & (CDIS_DISABLED | CDIS_INDETERMINATE))
    1017         {
    1018             TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1 + (rcArrow.bottom - rcArrow.top - ARROW_HEIGHT) / 2, comctl32_color.clrBtnHighlight);
    1019             TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top + (rcArrow.bottom - rcArrow.top - ARROW_HEIGHT) / 2, comctl32_color.clr3dShadow);
    1020         }
    1021         else if (tbcd.nmcd.uItemState & (CDIS_SELECTED | CDIS_CHECKED))
    1022         {
    1023             offset = (infoPtr->dwItemCDFlag & TBCDRF_NOOFFSET) ? 0 : 1;
    1024             TOOLBAR_DrawArrow(hdc, rcArrow.left + offset, rcArrow.top + offset + (rcArrow.bottom - rcArrow.top - ARROW_HEIGHT) / 2, comctl32_color.clrBtnText);
    1025         }
    1026         else
    1027             TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top + (rcArrow.bottom - rcArrow.top - ARROW_HEIGHT) / 2, comctl32_color.clrBtnText);
    1028     }
    1029 
    1030 FINALNOTIFY:
     934        if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
     935            DrawEdge (hdc, &rc, EDGE_RAISED,
     936                      BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     937
     938        if (hasDropDownArrow)
     939        {
     940            if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
     941                DrawEdge (hdc, &rcArrow, EDGE_RAISED,
     942                          BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     943            TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
     944        }
     945
     946        TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDef,
     947                               hdc, rcBitmap.left, rcBitmap.top,
     948                               ILD_NORMAL);}
     949
     950
     951    TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
     952
     953 FINALNOTIFY:
    1031954    if (infoPtr->dwItemCustDraw & CDRF_NOTIFYPOSTPAINT)
    1032955    {
     
    1052975    TBUTTON_INFO *btnPtr;
    1053976    INT i, oldBKmode = 0;
    1054     RECT rcTemp, rcClient;
     977    RECT rcTemp;
    1055978    NMTBCUSTOMDRAW tbcd;
    1056979    DWORD ntfret;
    1057 
    1058     /* the app has told us not to redraw the toolbar */
    1059     if (!infoPtr->bDoRedraw)
    1060         return;
    1061980
    1062981    /* if imagelist belongs to the app, it can be changed
     
    10821001        oldBKmode = SetBkMode (hdc, TRANSPARENT);
    10831002
    1084     GetClientRect(hwnd, &rcClient);
    1085 
    10861003    /* redraw necessary buttons */
    10871004    btnPtr = infoPtr->buttons;
    10881005    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
    10891006    {
    1090         BOOL bDraw;
    1091         if (infoPtr->dwExStyle & TBSTYLE_EX_HIDECLIPPEDBUTTONS)
    1092         {
    1093             IntersectRect(&rcTemp, &rcClient, &btnPtr->rect);
    1094             bDraw = EqualRect(&rcTemp, &btnPtr->rect);
    1095         }
    1096         else
    1097             bDraw = TRUE;
    1098         bDraw &= IntersectRect(&rcTemp, &(ps->rcPaint), &(btnPtr->rect));
    1099         bDraw = (btnPtr->fsState & TBSTATE_HIDDEN) ? FALSE : bDraw;
    1100         if (bDraw)
     1007        if(IntersectRect(&rcTemp, &(ps->rcPaint), &(btnPtr->rect)))
    11011008            TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
    11021009    }
     
    11251032* indicates where the underline goes, except for the string "&&" which
    11261033* is reduced to a single "&". GetTextExtentPoint does not process these
    1127 * only DrawText does. Note that the BTNS_NOPREFIX is handled here.
     1034* only DrawText does. Note that the TBSTYLE_NOPREFIX is handled here.
    11281035*/
    11291036static void
     
    11361043    lpSize->cy = 0;
    11371044
    1138     if (infoPtr->nMaxTextRows > 0 &&
    1139         !(btnPtr->fsState & TBSTATE_HIDDEN) &&
    1140         (!(infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) ||
    1141         (btnPtr->fsStyle & BTNS_SHOWTEXT)) )
     1045    if (!(btnPtr->fsState & TBSTATE_HIDDEN) )
    11421046    {
    11431047        LPWSTR lpText = TOOLBAR_GetText(infoPtr, btnPtr);
     
    11541058            /* Use DrawText to get true size as drawn (less pesky "&") */
    11551059            DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE |
    1156                    DT_CALCRECT | ((btnPtr->fsStyle & BTNS_NOPREFIX) ?
     1060                   DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ?
    11571061                                  DT_NOPREFIX : 0));
    11581062
     
    11841088    lpSize->cx = 0;
    11851089    lpSize->cy = 0;
    1186 
    1187     if(infoPtr->nMaxTextRows == 0)
    1188         return;
    11891090
    11901091    hdc = GetDC (hwnd);
     
    12121113*               TOOLBAR_WrapToolbar
    12131114*
    1214 * This function walks through the buttons and separators in the
     1115* This function walks through the buttons and seperators in the
    12151116* toolbar, and sets the TBSTATE_WRAP flag only on those items where
    12161117* wrapping should occur based on the width of the toolbar window.
     
    12661167        /* custom controls in toolbars.                              */
    12671168        /*                                                           */
    1268         /* BTNS_DROPDOWN separators are treated as buttons for    */
     1169        /* TBSTYLE_DROPDOWN separators are treated as buttons for    */
    12691170        /* width.  - GA 8/01                                         */
    1270         if ((btnPtr[i].fsStyle & BTNS_SEP) &&
    1271             !(btnPtr[i].fsStyle & BTNS_DROPDOWN))
     1171        if ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
     1172            !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN))
    12721173            cx = (btnPtr[i].iBitmap > 0) ?
    12731174                        btnPtr[i].iBitmap : SEPARATOR_WIDTH;
     
    12791180        /* next row if the previous wrapping is on a button.         */
    12801181        if( bButtonWrap &&
    1281                 (btnPtr[i].fsStyle & BTNS_SEP) &&
     1182                (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
    12821183                (i + 1 < infoPtr->nNumButtons ) &&
    1283                 (btnPtr[i + 1].fsStyle & BTNS_SEP) )
     1184                (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
    12841185        {
    12851186            TRACE("wrap point 1 btn %d style %02x\n", i, btnPtr[i].fsStyle);
     
    13031204            /*  go to the next until it reaches a non separator.      */
    13041205            /*  Wrap the last separator if it is before a button.     */
    1305             while( ( ((btnPtr[i].fsStyle & BTNS_SEP) &&
    1306                       !(btnPtr[i].fsStyle & BTNS_DROPDOWN)) ||
     1206            while( ( ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
     1207                      !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN)) ||
    13071208                     (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
    13081209                        i < infoPtr->nNumButtons )
     
    13291230            for ( j = i - 1; j >= 0  &&  !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
    13301231            {
    1331                 if ((btnPtr[j].fsStyle & BTNS_SEP) &&
     1232                if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
    13321233                        !(btnPtr[j].fsState & TBSTATE_HIDDEN))
    13331234                {
     
    13721273                bFound = TRUE;
    13731274                x = infoPtr->nIndent;
    1374                 if (btnPtr[i].fsStyle & BTNS_SEP )
     1275                if (btnPtr[i].fsStyle & TBSTYLE_SEP )
    13751276                    bButtonWrap = FALSE;
    13761277                else
     
    14131314    TOOLBAR_CalcStrings (hwnd, &sizeString);
    14141315
    1415     TOOLBAR_DumpToolbar (infoPtr, __LINE__);
    1416 
    14171316    for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
    14181317    {
     
    14251324                                     0, sizeString.cy) + infoPtr->szPadding.cy;
    14261325        infoPtr->nButtonWidth = ((usesBitmaps) ? infoPtr->nBitmapWidth :
    1427                                  LIST_IMAGE_ABSENT_WIDTH) + sizeString.cx + infoPtr->szPadding.cx;
    1428         if (sizeString.cx > 0)
    1429             infoPtr->nButtonWidth += TOOLBAR_GetListTextOffset(infoPtr, infoPtr->iListGap) + infoPtr->szPadding.cx/2;
     1326                                 0) + sizeString.cx + 6;
    14301327        TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n",
    14311328              infoPtr->nButtonWidth, infoPtr->nButtonHeight, usesBitmaps,
    14321329              infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
     1330        TOOLBAR_DumpToolbar (infoPtr, __LINE__);
    14331331    }
    14341332    else {
     
    14371335            if (usesBitmaps)
    14381336                infoPtr->nButtonHeight = sizeString.cy +
    1439                     infoPtr->szPadding.cy/2 + /* this is the space to separate text from bitmap */
    1440                   infoPtr->nBitmapHeight + infoPtr->szPadding.cy;
     1337                    2 + /* this is the space to separate text from bitmap */
     1338                  infoPtr->nBitmapHeight + 6;
    14411339            else
    1442                 infoPtr->nButtonHeight = sizeString.cy + infoPtr->szPadding.cy;
     1340                infoPtr->nButtonHeight = sizeString.cy + 6;
    14431341        }
    1444         else
    1445             infoPtr->nButtonHeight = infoPtr->nBitmapHeight + infoPtr->szPadding.cy;
     1342        else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
     1343            infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
    14461344
    14471345        if (sizeString.cx > infoPtr->nBitmapWidth)
    1448             infoPtr->nButtonWidth = sizeString.cx + infoPtr->szPadding.cx;
    1449         else
    1450             infoPtr->nButtonWidth = infoPtr->nBitmapWidth + infoPtr->szPadding.cx;
     1346            infoPtr->nButtonWidth = sizeString.cx + 6;
     1347        else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
     1348            infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
    14511349    }
    14521350
     
    14611359    y  = 0;
    14621360
     1361   /*
     1362    * We will set the height below, and we set the width on entry
     1363    * so we do not reset them here..
     1364    */
     1365#if 0
     1366    GetClientRect( hwnd, &rc );
     1367    /* get initial values for toolbar */
     1368    infoPtr->nWidth  = rc.right - rc.left;
     1369    infoPtr->nHeight = rc.bottom - rc.top;
     1370#endif
     1371
    14631372    /* from above, minimum is a button, and possible text */
    14641373    cx = infoPtr->nButtonWidth;
     
    14781387
    14791388    btnPtr = infoPtr->buttons;
     1389
     1390    /* do not base height/width on parent, if the parent is a */
     1391    /* rebar control it could have multiple rows of toolbars  */
     1392/*    GetClientRect( GetParent(hwnd), &rc ); */
     1393/*    cx = rc.right - rc.left; */
     1394/*    cy = rc.bottom - rc.top; */
    14801395
    14811396    TRACE("cy=%d\n", cy);
     
    14951410        /* it is the actual width of the separator. This is used for */
    14961411        /* custom controls in toolbars.                              */
    1497         if (btnPtr->fsStyle & BTNS_SEP) {
    1498             if (btnPtr->fsStyle & BTNS_DROPDOWN) {
     1412        if (btnPtr->fsStyle & TBSTYLE_SEP) {
     1413            if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) {
    14991414                cy = (btnPtr->iBitmap > 0) ?
    15001415                     btnPtr->iBitmap : SEPARATOR_WIDTH;
     
    15071422        else
    15081423        {
    1509             if ((infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) ||
    1510                 (btnPtr->fsStyle & BTNS_AUTOSIZE))
     1424            if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE)
    15111425            {
    15121426              SIZE sz;
     
    15221436              ReleaseDC (hwnd, hdc);
    15231437
    1524               /* add space on for button frame, etc */
    1525               cx = sz.cx + infoPtr->szPadding.cx;
    1526              
    1527               /* add list padding */
    1528               if ((dwStyle & TBSTYLE_LIST) && sz.cx > 0)
    1529                   cx += TOOLBAR_GetListTextOffset(infoPtr, infoPtr->iListGap) + infoPtr->szPadding.cx/2;
    1530 
    1531               if (TOOLBAR_TestImageExist (infoPtr, btnPtr, GETDEFIMAGELIST(infoPtr,0)))
    1532               {
    1533                 if (dwStyle & TBSTYLE_LIST)
    1534                   cx += infoPtr->nBitmapWidth;
    1535                 else if (cx < (infoPtr->nBitmapWidth+infoPtr->szPadding.cx))
    1536                   cx = infoPtr->nBitmapWidth+infoPtr->szPadding.cx;
    1537               }
    1538               else if (dwStyle & TBSTYLE_LIST)
    1539                   cx += LIST_IMAGE_ABSENT_WIDTH;
     1438              /* Fudge amount measured against IE4 "menu" and "Links" */
     1439              /* toolbars with native control (v4.71).  -  GA 8/01    */
     1440              cx = sz.cx + 6 + 5 + 5;
     1441              if ((dwStyle & TBSTYLE_LIST) &&
     1442                  (TOOLBAR_TestImageExist (infoPtr, btnPtr, GETDEFIMAGELIST(infoPtr,0))))
     1443                  cx += infoPtr->nBitmapWidth;
    15401444            }
    15411445            else
    15421446              cx = infoPtr->nButtonWidth;
    15431447
    1544             if ((hasDropDownArrows && (btnPtr->fsStyle & BTNS_DROPDOWN)) || (btnPtr->fsStyle & BTNS_WHOLEDROPDOWN))
     1448            if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN))
    15451449              cx += DDARROW_WIDTH;
    15461450        }
     
    15581462
    15591463        /* Set the toolTip only for non-hidden, non-separator button */
    1560         if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & BTNS_SEP ))
     1464        if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
    15611465        {
    15621466            TTTOOLINFOA ti;
     
    15811485        if( bWrap )
    15821486        {
    1583             if ( !(btnPtr->fsStyle & BTNS_SEP) )
     1487            if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
    15841488                y += cy;
    15851489            else
     
    15881492                /* it is the actual width of the separator. This is used for */
    15891493                /* custom controls in toolbars.                              */
    1590                 if ( !(btnPtr->fsStyle & BTNS_DROPDOWN))
     1494                if ( !(btnPtr->fsStyle & TBSTYLE_DROPDOWN))
    15911495                    y += cy + ( (btnPtr->iBitmap > 0 ) ?
    15921496                                btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
     
    16481552            continue;
    16491553
    1650         if (btnPtr->fsStyle & BTNS_SEP) {
     1554        if (btnPtr->fsStyle & TBSTYLE_SEP) {
    16511555            if (PtInRect (&btnPtr->rect, *lpPt)) {
    16521556                TRACE(" ON SEPARATOR %d!\n", i);
     
    17011605    /* check index button */
    17021606    btnPtr = &infoPtr->buttons[nIndex];
    1703     if ((btnPtr->fsStyle & BTNS_CHECKGROUP) == BTNS_CHECKGROUP) {
     1607    if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
    17041608        if (btnPtr->fsState & TBSTATE_CHECKED)
    17051609            return nIndex;
     
    17101614    while (nRunIndex >= 0) {
    17111615        btnPtr = &infoPtr->buttons[nRunIndex];
    1712         if ((btnPtr->fsStyle & BTNS_CHECKGROUP) == BTNS_CHECKGROUP) {
     1616        if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
    17131617            if (btnPtr->fsState & TBSTATE_CHECKED)
    17141618                return nRunIndex;
     
    17231627    while (nRunIndex < infoPtr->nNumButtons) {
    17241628        btnPtr = &infoPtr->buttons[nRunIndex];
    1725         if ((btnPtr->fsStyle & BTNS_CHECKGROUP) == BTNS_CHECKGROUP) {
     1629        if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
    17261630            if (btnPtr->fsState & TBSTATE_CHECKED)
    17271631                return nRunIndex;
     
    17861690                    return FALSE;
    17871691
    1788                 /* UNDOCUMENTED: dialog hwnd immediately follows NMHDR */
    1789                 nmtb.iItem = (int)hwnd;
    17901692                /* Send TBN_INITCUSTOMIZE notification */
    17911693                if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_INITCUSTOMIZE) ==
    1792                     TBNRF_HIDEHELP)
     1694                    TBNRF_HIDEHELP)
    17931695                {
    1794                     TRACE("TBNRF_HIDEHELP requested\n");
    1795                     ShowWindow(GetDlgItem(hwnd, IDC_HELP_BTN), SW_HIDE);
     1696                    FIXME("TBNRF_HIDEHELP not supported\n");
    17961697                }
    17971698
     
    17991700                for (i = 0; i < custInfo->tbInfo->nNumButtons; i++)
    18001701                {
    1801                     btnInfo = (PCUSTOMBUTTON)Alloc(sizeof(CUSTOMBUTTON));
     1702                    btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
    18021703                    memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
    1803                     btnInfo->btn.fsStyle = BTNS_SEP;
     1704                    btnInfo->btn.fsStyle = TBSTYLE_SEP;
    18041705                    btnInfo->bVirtual = FALSE;
    18051706                    LoadStringW (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
     
    18131714
    18141715                /* insert separator button into 'available buttons' list */
    1815                 btnInfo = (PCUSTOMBUTTON)Alloc(sizeof(CUSTOMBUTTON));
     1716                btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
    18161717                memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
    1817                 btnInfo->btn.fsStyle = BTNS_SEP;
     1718                btnInfo->btn.fsStyle = TBSTYLE_SEP;
    18181719                btnInfo->bVirtual = FALSE;
    18191720                btnInfo->bRemovable = TRUE;
     
    18481749                    if (index == -1)
    18491750                    {
    1850                         btnInfo = (PCUSTOMBUTTON)Alloc(sizeof(CUSTOMBUTTON));
     1751                        btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
    18511752                        btnInfo->bVirtual = FALSE;
    18521753                        btnInfo->bRemovable = TRUE;
     
    18631764
    18641765                    memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
    1865                     if (!(nmtb.tbButton.fsStyle & BTNS_SEP))
     1766                    if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
    18661767                    {
    18671768                        if (lstrlenW(nmtb.pszText))
     
    18801781
    18811782                /* append 'virtual' separator button to the 'toolbar buttons' list */
    1882                 btnInfo = (PCUSTOMBUTTON)Alloc(sizeof(CUSTOMBUTTON));
     1783                btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
    18831784                memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
    1884                 btnInfo->btn.fsStyle = BTNS_SEP;
     1785                btnInfo->btn.fsStyle = TBSTYLE_SEP;
    18851786                btnInfo->bVirtual = TRUE;
    18861787                btnInfo->bRemovable = FALSE;
     
    20521953
    20531954                            /* insert into 'available button' list */
    2054                             if (!(btnInfo->btn.fsStyle & BTNS_SEP))
     1955                            if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP))
    20551956                            {
    20561957                                index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
     
    20581959                            }
    20591960                            else
    2060                                 Free (btnInfo);
     1961                                COMCTL32_Free (btnInfo);
    20611962                        }
    20621963                    }
    20631964                    break;
    2064                 case IDC_HELP_BTN:
    2065                         TOOLBAR_SendNotify(&nmtb.hdr, infoPtr, TBN_CUSTHELP);
    2066                         break;
    2067                 case IDC_RESET_BTN:
    2068                         TOOLBAR_SendNotify(&nmtb.hdr, infoPtr, TBN_RESET);
    2069                         break;
    20701965
    20711966                case IDOK: /* Add button */
     
    20991994
    21001995                                /* duplicate 'separator' button */
    2101                                 btnNew = (PCUSTOMBUTTON)Alloc (sizeof(CUSTOMBUTTON));
     1996                                btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON));
    21021997                                memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON));
    21031998                                btnInfo = btnNew;
     
    21302025                {
    21312026                    btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0);
    2132                     Free(btnInfo);
     2027                    COMCTL32_Free(btnInfo);
    21332028                    SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0);
    21342029                }
     
    21412036                {
    21422037                    btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0);
    2143                     Free(btnInfo);
     2038                    COMCTL32_Free(btnInfo);
    21442039                    SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0);
    21452040                }
     
    21992094
    22002095                /* draw image and text */
    2201                 if ((btnInfo->btn.fsStyle & BTNS_SEP) == 0) {
     2096                if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0) {
    22022097                        HIMAGELIST himl = GETDEFIMAGELIST(infoPtr, GETHIMLID(infoPtr,
    22032098                                btnInfo->btn.iBitmap));
     
    23042199        TRACE ("creating default image list!\n");
    23052200
    2306         himlDef = ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
    2307                                     ILC_COLORDDB | ILC_MASK, nButtons, 2);
     2201    himlDef = ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
     2202                ILC_COLOR | ILC_MASK, nButtons, 2);
    23082203        TOOLBAR_InsertImageList(&infoPtr->himlDef, &infoPtr->cimlDef, himlDef, 0);
    2309         infoPtr->himlInt = himlDef;
     2204    infoPtr->himlInt = himlDef;
    23102205    }
    23112206    else {
     
    23492244       DeleteDC (hdcBitmap);
    23502245
    2351        nIndex = ImageList_AddMasked (himlDef, hbmLoad, comctl32_color.clrBtnFace);
     2246       nIndex = ImageList_AddMasked (himlDef, hbmLoad, CLR_DEFAULT);
    23522247       DeleteObject (hbmLoad);
    23532248    }
     
    23612256                                       MAKEINTRESOURCEA(IDB_STD_SMALL));
    23622257                nIndex = ImageList_AddMasked (himlDef,
    2363                                               hbmLoad, comctl32_color.clrBtnFace);
     2258                                              hbmLoad, CLR_DEFAULT);
    23642259                DeleteObject (hbmLoad);
    23652260                break;
     
    23692264                                       MAKEINTRESOURCEA(IDB_STD_LARGE));
    23702265                nIndex = ImageList_AddMasked (himlDef,
    2371                                               hbmLoad, comctl32_color.clrBtnFace);
     2266                                              hbmLoad, CLR_DEFAULT);
    23722267                DeleteObject (hbmLoad);
    23732268                break;
     
    23772272                                       MAKEINTRESOURCEA(IDB_VIEW_SMALL));
    23782273                nIndex = ImageList_AddMasked (himlDef,
    2379                                               hbmLoad, comctl32_color.clrBtnFace);
     2274                                              hbmLoad, CLR_DEFAULT);
    23802275                DeleteObject (hbmLoad);
    23812276                break;
     
    23852280                                       MAKEINTRESOURCEA(IDB_VIEW_LARGE));
    23862281                nIndex = ImageList_AddMasked (himlDef,
    2387                                               hbmLoad, comctl32_color.clrBtnFace);
     2282                                              hbmLoad, CLR_DEFAULT);
    23882283                DeleteObject (hbmLoad);
    23892284                break;
     
    23932288                                       MAKEINTRESOURCEA(IDB_HIST_SMALL));
    23942289                nIndex = ImageList_AddMasked (himlDef,
    2395                                               hbmLoad, comctl32_color.clrBtnFace);
     2290                                              hbmLoad, CLR_DEFAULT);
    23962291                DeleteObject (hbmLoad);
    23972292                break;
     
    24012296                                       MAKEINTRESOURCEA(IDB_HIST_LARGE));
    24022297                nIndex = ImageList_AddMasked (himlDef,
    2403                                               hbmLoad, comctl32_color.clrBtnFace);
     2298                                              hbmLoad, CLR_DEFAULT);
    24042299                DeleteObject (hbmLoad);
    24052300                break;
     
    24142309    {
    24152310        hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
    2416         nIndex = ImageList_AddMasked (himlDef, hbmLoad, comctl32_color.clrBtnFace);
     2311        nIndex = ImageList_AddMasked (himlDef, hbmLoad, CLR_DEFAULT);
    24172312        DeleteObject (hbmLoad);
    24182313    }
     
    24222317    if (infoPtr->nNumBitmapInfos == 0)
    24232318    {
    2424         infoPtr->bitmaps = Alloc(sizeof(TBITMAP_INFO));
     2319        infoPtr->bitmaps = COMCTL32_Alloc(sizeof(TBITMAP_INFO));
    24252320    }
    24262321    else
    24272322    {
    24282323        TBITMAP_INFO *oldBitmaps = infoPtr->bitmaps;
    2429         infoPtr->bitmaps = Alloc((infoPtr->nNumBitmapInfos + 1) * sizeof(TBITMAP_INFO));
     2324        infoPtr->bitmaps = COMCTL32_Alloc((infoPtr->nNumBitmapInfos + 1) * sizeof(TBITMAP_INFO));
    24302325        memcpy(&infoPtr->bitmaps[0], &oldBitmaps[0], infoPtr->nNumBitmapInfos);
    24312326    }
     
    24542349    }
    24552350
    2456     InvalidateRect(hwnd, NULL, TRUE);
     2351    InvalidateRect(hwnd, NULL, FALSE);
    24572352
    24582353    return nIndex;
     
    24752370    if (infoPtr->nNumButtons == 0) {
    24762371        infoPtr->buttons =
    2477             Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     2372            COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    24782373    }
    24792374    else {
    24802375        TBUTTON_INFO *oldButtons = infoPtr->buttons;
    24812376        infoPtr->buttons =
    2482             Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     2377            COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    24832378        memcpy (&infoPtr->buttons[0], &oldButtons[0],
    24842379                nOldButtons * sizeof(TBUTTON_INFO));
    2485         Free (oldButtons);
     2380        COMCTL32_Free (oldButtons);
    24862381    }
    24872382
     
    24962391        btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
    24972392        btnPtr->dwData    = lpTbb[nCount].dwData;
    2498         if(HIWORD(lpTbb[nCount].iString) && lpTbb[nCount].iString != -1)
    2499             Str_SetPtrAtoW ((LPWSTR*)&btnPtr->iString, (LPSTR)lpTbb[nCount].iString );
    2500         else
    2501             btnPtr->iString   = lpTbb[nCount].iString;
     2393        btnPtr->iString   = lpTbb[nCount].iString;
    25022394        btnPtr->bHot      = FALSE;
    25032395
    2504         if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & BTNS_SEP)) {
     2396        if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
    25052397            TTTOOLINFOA ti;
    25062398
     
    25212413    TOOLBAR_DumpToolbar (infoPtr, __LINE__);
    25222414
    2523     InvalidateRect(hwnd, NULL, TRUE);
     2415    InvalidateRect(hwnd, NULL, FALSE);
    25242416
    25252417    return TRUE;
     
    25422434    if (infoPtr->nNumButtons == 0) {
    25432435        infoPtr->buttons =
    2544             Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     2436            COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    25452437    }
    25462438    else {
    25472439        TBUTTON_INFO *oldButtons = infoPtr->buttons;
    25482440        infoPtr->buttons =
    2549             Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     2441            COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    25502442        memcpy (&infoPtr->buttons[0], &oldButtons[0],
    25512443                nOldButtons * sizeof(TBUTTON_INFO));
    2552         Free (oldButtons);
     2444        COMCTL32_Free (oldButtons);
    25532445    }
    25542446
     
    25632455        btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
    25642456        btnPtr->dwData    = lpTbb[nCount].dwData;
    2565         if(HIWORD(lpTbb[nCount].iString) && lpTbb[nCount].iString != -1)
    2566             Str_SetPtrW ((LPWSTR*)&btnPtr->iString, (LPWSTR)lpTbb[nCount].iString );
    2567         else
    2568             btnPtr->iString   = lpTbb[nCount].iString;
     2457        btnPtr->iString   = lpTbb[nCount].iString;
    25692458        btnPtr->bHot      = FALSE;
    25702459
    2571         if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & BTNS_SEP)) {
     2460        if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
    25722461            TTTOOLINFOW ti;
    25732462
     
    25892478    TOOLBAR_DumpToolbar (infoPtr, __LINE__);
    25902479
    2591     InvalidateRect(hwnd, NULL, TRUE);
     2480    InvalidateRect(hwnd, NULL, FALSE);
    25922481
    25932482    return TRUE;
     
    26132502        if (infoPtr->nNumStrings == 0) {
    26142503            infoPtr->strings =
    2615                 Alloc (sizeof(LPWSTR));
     2504                COMCTL32_Alloc (sizeof(LPWSTR));
    26162505        }
    26172506        else {
    26182507            LPWSTR *oldStrings = infoPtr->strings;
    26192508            infoPtr->strings =
    2620                 Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     2509                COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    26212510            memcpy (&infoPtr->strings[0], &oldStrings[0],
    26222511                    sizeof(LPWSTR) * infoPtr->nNumStrings);
    2623             Free (oldStrings);
    2624         }
    2625 
    2626         /*Alloc zeros out the allocated memory*/
     2512            COMCTL32_Free (oldStrings);
     2513        }
     2514
     2515        /*COMCTL32_Alloc zeros out the allocated memory*/
    26272516        Str_SetPtrAtoW (&infoPtr->strings[infoPtr->nNumStrings], szString );
    26282517        infoPtr->nNumStrings++;
     
    26432532            if (infoPtr->nNumStrings == 0) {
    26442533                infoPtr->strings =
    2645                     Alloc (sizeof(LPWSTR));
     2534                    COMCTL32_Alloc (sizeof(LPWSTR));
    26462535            }
    26472536            else {
    26482537                LPWSTR *oldStrings = infoPtr->strings;
    26492538                infoPtr->strings =
    2650                     Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     2539                    COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    26512540                memcpy (&infoPtr->strings[0], &oldStrings[0],
    26522541                        sizeof(LPWSTR) * infoPtr->nNumStrings);
    2653                 Free (oldStrings);
     2542                COMCTL32_Free (oldStrings);
    26542543            }
    26552544
     
    26912580
    26922581                if (infoPtr->nNumStrings == 0) {
    2693                     infoPtr->strings = Alloc (sizeof(LPWSTR));
     2582                    infoPtr->strings = COMCTL32_Alloc (sizeof(LPWSTR));
    26942583                }
    26952584                else
    26962585                {
    26972586                    LPWSTR *oldStrings = infoPtr->strings;
    2698                     infoPtr->strings = Alloc(sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     2587                    infoPtr->strings = COMCTL32_Alloc(sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    26992588                    memcpy(&infoPtr->strings[0], &oldStrings[0],
    27002589                           sizeof(LPWSTR) * infoPtr->nNumStrings);
    2701                     Free(oldStrings);
     2590                    COMCTL32_Free(oldStrings);
    27022591                }
    27032592
    2704                 np=strchrW (p, '|');
     2593                np=COMCTL32_StrChrW (p, L'|');
    27052594                if (np!=NULL) {
    27062595                    len = np - p;
     
    27122601                TRACE("len=%d %s\n", len, debugstr_w(p));
    27132602                infoPtr->strings[infoPtr->nNumStrings] =
    2714                     Alloc (sizeof(WCHAR)*(len+1));
     2603                    COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
    27152604                lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len+1);
    27162605                infoPtr->nNumStrings++;
     
    27242613            if (infoPtr->nNumStrings == 0) {
    27252614                infoPtr->strings =
    2726                     Alloc (sizeof(LPWSTR));
     2615                    COMCTL32_Alloc (sizeof(LPWSTR));
    27272616            }
    27282617            else {
    27292618                LPWSTR *oldStrings = infoPtr->strings;
    27302619                infoPtr->strings =
    2731                     Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     2620                    COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    27322621                memcpy (&infoPtr->strings[0], &oldStrings[0],
    27332622                        sizeof(LPWSTR) * infoPtr->nNumStrings);
    2734                 Free (oldStrings);
     2623                COMCTL32_Free (oldStrings);
    27352624            }
    27362625
     
    27532642            if (infoPtr->nNumStrings == 0) {
    27542643                infoPtr->strings =
    2755                     Alloc (sizeof(LPWSTR));
     2644                    COMCTL32_Alloc (sizeof(LPWSTR));
    27562645            }
    27572646            else {
    27582647                LPWSTR *oldStrings = infoPtr->strings;
    27592648                infoPtr->strings =
    2760                     Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     2649                    COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    27612650                memcpy (&infoPtr->strings[0], &oldStrings[0],
    27622651                        sizeof(LPWSTR) * infoPtr->nNumStrings);
    2763                 Free (oldStrings);
     2652                COMCTL32_Free (oldStrings);
    27642653            }
    27652654
     
    28112700        cx = infoPtr->nWidth;
    28122701
    2813         if ((dwStyle & CCS_BOTTOM) == CCS_NOMOVEY) {
     2702        if (dwStyle & CCS_NOMOVEY) {
    28142703                GetWindowRect(hwnd, &window_rect);
    28152704                ScreenToClient(parent, (LPPOINT)&window_rect.left);
    28162705                y = window_rect.top;
    28172706        }
    2818         if ((dwStyle & CCS_BOTTOM) == CCS_BOTTOM) {
    2819             GetWindowRect(hwnd, &window_rect);
    2820             y = parent_rect.bottom - ( window_rect.bottom - window_rect.top);
    2821         }
    28222707    }
    28232708
     
    28362721
    28372722    infoPtr->bAutoSize = TRUE;
    2838     SetWindowPos (hwnd, HWND_TOP,  x, y, cx, cy, uPosFlags);
    2839     /* The following line makes sure that the infoPtr->bAutoSize is turned off
    2840      * after the setwindowpos calls */
     2723    SetWindowPos (hwnd, HWND_TOP, parent_rect.left - x, parent_rect.top - y,
     2724                        cx, cy, uPosFlags);
     2725    /* The following line makes sure that the infoPtr->bAutoSize is turned off after
     2726     * the setwindowpos calls */
    28412727    infoPtr->bAutoSize = FALSE;
    28422728
     
    28782764    INT nIndex;
    28792765
    2880     TRACE("button %d, iBitmap now %d\n", wParam, LOWORD(lParam));
    2881 
    28822766    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    28832767    if (nIndex == -1)
     
    29052789
    29062790    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    2907 
    2908     TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd, nIndex, lParam);
    2909 
    29102791    if (nIndex == -1)
    29112792        return FALSE;
    29122793
    29132794    btnPtr = &infoPtr->buttons[nIndex];
     2795
     2796    if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
     2797        return FALSE;
    29142798
    29152799    bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE;
     
    29182802        btnPtr->fsState &= ~TBSTATE_CHECKED;
    29192803    else {
    2920         if (btnPtr->fsStyle & BTNS_GROUP) {
     2804        if (btnPtr->fsStyle & TBSTYLE_GROUP) {
    29212805            nOldIndex =
    29222806                TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
     
    29312815    if( bChecked != LOWORD(lParam) )
    29322816    {
    2933         if (nOldIndex != -1)
    2934             InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect, TRUE);
     2817        if (nOldIndex != -1)
     2818        {
     2819            InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
     2820                TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
     2821        }
    29352822        InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    29362823    }
     
    29702857    if (!(hRes = FindResourceA (COMCTL32_hModule,
    29712858                                MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
    2972                                 (LPSTR)RT_DIALOGA)))
     2859                                RT_DIALOGA)))
    29732860        return FALSE;
    29742861
     
    30002887
    30012888    if ((infoPtr->hwndToolTip) &&
    3002         !(infoPtr->buttons[nIndex].fsStyle & BTNS_SEP)) {
     2889        !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
    30032890        TTTOOLINFOA ti;
    30042891
     
    30132900    if (infoPtr->nNumButtons == 1) {
    30142901        TRACE(" simple delete!\n");
    3015         Free (infoPtr->buttons);
     2902        COMCTL32_Free (infoPtr->buttons);
    30162903        infoPtr->buttons = NULL;
    30172904        infoPtr->nNumButtons = 0;
     
    30222909
    30232910        infoPtr->nNumButtons--;
    3024         infoPtr->buttons = Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
     2911        infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
    30252912        if (nIndex > 0) {
    30262913            memcpy (&infoPtr->buttons[0], &oldButtons[0],
     
    30332920        }
    30342921
    3035         Free (oldButtons);
     2922        COMCTL32_Free (oldButtons);
    30362923    }
    30372924
     
    30532940
    30542941    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    3055 
    3056     TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd, wParam, lParam);
    3057 
    30582942    if (nIndex == -1)
    30592943        return FALSE;
     
    30722956    /* redraw the button only if the state of the button changed */
    30732957    if(bState != (btnPtr->fsState & TBSTATE_ENABLED))
    3074         InvalidateRect(hwnd, &btnPtr->rect, TRUE);
     2958    {
     2959        InvalidateRect(hwnd, &btnPtr->rect,
     2960            TOOLBAR_HasText(infoPtr, btnPtr));
     2961    }
    30752962
    30762963    return TRUE;
     
    31603047
    31613048    if (!(btnPtr = &infoPtr->buttons[nIndex])) return -1;
     3049
     3050    if (lpTbInfo->dwMask & TBIF_COMMAND)
     3051        lpTbInfo->idCommand = btnPtr->idCommand;
     3052    if (lpTbInfo->dwMask & TBIF_IMAGE)
     3053        lpTbInfo->iImage = btnPtr->iBitmap;
     3054    if (lpTbInfo->dwMask & TBIF_LPARAM)
     3055        lpTbInfo->lParam = btnPtr->dwData;
     3056    if (lpTbInfo->dwMask & TBIF_SIZE)
     3057        lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
     3058    if (lpTbInfo->dwMask & TBIF_STATE)
     3059        lpTbInfo->fsState = btnPtr->fsState;
     3060    if (lpTbInfo->dwMask & TBIF_STYLE)
     3061        lpTbInfo->fsStyle = btnPtr->fsStyle;
     3062     if (lpTbInfo->dwMask & TBIF_TEXT) {
     3063         LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
     3064         Str_GetPtrWtoA (lpText, lpTbInfo->pszText,lpTbInfo->cchText);
     3065         }
     3066    return nIndex;
     3067}
     3068
     3069
     3070static LRESULT
     3071TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
     3072{
     3073    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     3074    LPTBBUTTONINFOW lpTbInfo = (LPTBBUTTONINFOW)lParam;
     3075    TBUTTON_INFO *btnPtr;
     3076    INT nIndex;
     3077
     3078    if (infoPtr == NULL)
     3079        return -1;
     3080    if (lpTbInfo == NULL)
     3081        return -1;
     3082    if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
     3083        return -1;
     3084
     3085    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
     3086                                     lpTbInfo->dwMask & 0x80000000);
     3087    if (nIndex == -1)
     3088        return -1;
     3089
     3090    btnPtr = &infoPtr->buttons[nIndex];
     3091
     3092    if(!btnPtr)
     3093        return -1;
    31623094
    31633095    if (lpTbInfo->dwMask & TBIF_COMMAND)
     
    31743106        lpTbInfo->fsStyle = btnPtr->fsStyle;
    31753107    if (lpTbInfo->dwMask & TBIF_TEXT) {
    3176         /* TB_GETBUTTONINFO doesn't retrieve text from the string list, so we
    3177            can't use TOOLBAR_GetText here */
    3178         LPWSTR lpText;
    3179         if (HIWORD(btnPtr->iString) && (btnPtr->iString != -1)) {
    3180             lpText = (LPWSTR)btnPtr->iString;
    3181             Str_GetPtrWtoA (lpText, lpTbInfo->pszText,lpTbInfo->cchText);
    3182         } else
    3183             lpTbInfo->pszText[0] = '\0';
    3184     }
    3185     return nIndex;
    3186 }
    3187 
    3188 
    3189 static LRESULT
    3190 TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    3191 {
    3192     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    3193     LPTBBUTTONINFOW lpTbInfo = (LPTBBUTTONINFOW)lParam;
    3194     TBUTTON_INFO *btnPtr;
    3195     INT nIndex;
    3196 
    3197     if (infoPtr == NULL)
    3198         return -1;
    3199     if (lpTbInfo == NULL)
    3200         return -1;
    3201     if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
    3202         return -1;
    3203 
    3204     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
    3205                                      lpTbInfo->dwMask & 0x80000000);
    3206     if (nIndex == -1)
    3207         return -1;
    3208 
    3209     btnPtr = &infoPtr->buttons[nIndex];
    3210 
    3211     if(!btnPtr)
    3212         return -1;
    3213 
    3214     if (lpTbInfo->dwMask & TBIF_COMMAND)
    3215         lpTbInfo->idCommand = btnPtr->idCommand;
    3216     if (lpTbInfo->dwMask & TBIF_IMAGE)
    3217         lpTbInfo->iImage = btnPtr->iBitmap;
    3218     if (lpTbInfo->dwMask & TBIF_LPARAM)
    3219         lpTbInfo->lParam = btnPtr->dwData;
    3220     if (lpTbInfo->dwMask & TBIF_SIZE)
    3221         lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
    3222     if (lpTbInfo->dwMask & TBIF_STATE)
    3223         lpTbInfo->fsState = btnPtr->fsState;
    3224     if (lpTbInfo->dwMask & TBIF_STYLE)
    3225         lpTbInfo->fsStyle = btnPtr->fsStyle;
    3226     if (lpTbInfo->dwMask & TBIF_TEXT) {
    3227         /* TB_GETBUTTONINFO doesn't retrieve text from the string list, so we
    3228            can't use TOOLBAR_GetText here */
    3229         LPWSTR lpText;
    3230         if (HIWORD(btnPtr->iString) && (btnPtr->iString != -1)) {
    3231             lpText = (LPWSTR)btnPtr->iString;
    3232             Str_GetPtrW (lpText,lpTbInfo->pszText,lpTbInfo->cchText);
    3233         } else
    3234             lpTbInfo->pszText[0] = '\0';
     3108        LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
     3109        Str_GetPtrW (lpText,lpTbInfo->pszText,lpTbInfo->cchText);
    32353110    }
    32363111
     
    32983173TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
    32993174{
    3300     TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd, wParam, lParam);
    3301     /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
    3302     return (LRESULT)GETDISIMAGELIST(TOOLBAR_GetInfoPtr (hwnd), wParam);
     3175    return (LRESULT)GETDISIMAGELIST(TOOLBAR_GetInfoPtr (hwnd), 0);
    33033176}
    33043177
     
    33093182    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    33103183
    3311     TRACE("\n");
    3312 
    33133184    return infoPtr->dwExStyle;
    33143185}
     
    33183189TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
    33193190{
    3320     TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd, wParam, lParam);
    3321     /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
    3322     return (LRESULT)GETHOTIMAGELIST(TOOLBAR_GetInfoPtr (hwnd), wParam);
     3191    return (LRESULT)GETHOTIMAGELIST(TOOLBAR_GetInfoPtr (hwnd), 0);
    33233192}
    33243193
     
    33423211TOOLBAR_GetDefImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
    33433212{
    3344     TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd, wParam, lParam);
    3345     /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
    3346     return (LRESULT) GETDEFIMAGELIST(TOOLBAR_GetInfoPtr(hwnd), wParam);
     3213    return (LRESULT) GETDEFIMAGELIST(TOOLBAR_GetInfoPtr(hwnd), 0);
    33473214}
    33483215
     
    35653432    TBUTTON_INFO *btnPtr;
    35663433    INT nIndex;
    3567     DWORD oldState;
    35683434
    35693435    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
     
    35723438
    35733439    btnPtr = &infoPtr->buttons[nIndex];
    3574     oldState = btnPtr->fsState;
    35753440    if (LOWORD(lParam) == FALSE)
    35763441        btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
     
    35783443        btnPtr->fsState |= TBSTATE_INDETERMINATE;
    35793444
    3580     if(oldState != btnPtr->fsState)
    3581         InvalidateRect(hwnd, &btnPtr->rect, TRUE);
     3445    InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
    35823446
    35833447    return TRUE;
     
    36203484              debugstr_a((LPSTR)lpTbb->iString));
    36213485        len = strlen((LPSTR)lpTbb->iString) + 2;
    3622         ptr = Alloc(len);
     3486        ptr = COMCTL32_Alloc(len);
    36233487        strcpy(ptr, (LPSTR)lpTbb->iString);
    36243488        ptr[len - 1] = 0; /* ended by two '\0' */
    36253489        lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr);
    3626         Free(ptr);
     3490        COMCTL32_Free(ptr);
    36273491    }
    36283492
     
    36353499    oldButtons = infoPtr->buttons;
    36363500    infoPtr->nNumButtons++;
    3637     infoPtr->buttons = Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
     3501    infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
    36383502    /* pre insert copy */
    36393503    if (nIndex > 0) {
     
    36553519        infoPtr->buttons[nIndex].iString   = lpTbb->iString;
    36563520
    3657     if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & BTNS_SEP)) {
     3521    if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
    36583522        TTTOOLINFOA ti;
    36593523
     
    36753539    }
    36763540
    3677     Free (oldButtons);
     3541    COMCTL32_Free (oldButtons);
    36783542
    36793543    TOOLBAR_CalcToolbar (hwnd);
     
    37203584              debugstr_w((LPWSTR)lpTbb->iString));
    37213585        len = strlenW((LPWSTR)lpTbb->iString) + 2;
    3722         ptr = Alloc(len*sizeof(WCHAR));
     3586        ptr = COMCTL32_Alloc(len*sizeof(WCHAR));
    37233587        strcpyW(ptr, (LPWSTR)lpTbb->iString);
    37243588        ptr[len - 1] = 0; /* ended by two '\0' */
    37253589        lpTbb->iString = TOOLBAR_AddStringW(hwnd, 0, (LPARAM)ptr);
    3726         Free(ptr);
     3590        COMCTL32_Free(ptr);
    37273591    }
    37283592
     
    37353599    oldButtons = infoPtr->buttons;
    37363600    infoPtr->nNumButtons++;
    3737     infoPtr->buttons = Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
     3601    infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
    37383602    /* pre insert copy */
    37393603    if (nIndex > 0) {
     
    37553619        infoPtr->buttons[nIndex].iString   = lpTbb->iString;
    37563620
    3757     if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & BTNS_SEP)) {
     3621    if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
    37583622        TTTOOLINFOW ti;
    37593623
     
    37753639    }
    37763640
    3777     Free (oldButtons);
     3641    COMCTL32_Free (oldButtons);
    37783642
    37793643    TOOLBAR_CalcToolbar (hwnd);
     
    38723736
    38733737
    3874 static LRESULT
    3875 TOOLBAR_LoadImages (HWND hwnd, WPARAM wParam, LPARAM lParam)
    3876 {
    3877     TBADDBITMAP tbab;
    3878     tbab.hInst = (HINSTANCE)lParam;
    3879     tbab.nID = (UINT_PTR)wParam;
    3880 
    3881     TRACE("hwnd = %p, hInst = %p, nID = %u\n", hwnd, tbab.hInst, tbab.nID);
    3882 
    3883     return TOOLBAR_AddBitmap(hwnd, 0, (LPARAM)&tbab);
    3884 }
    3885 
    3886 
    3887 static LRESULT
    3888 TOOLBAR_MapAccelerator (HWND hwnd, WPARAM wParam, LPARAM lParam)
    3889 {
    3890     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    3891     WCHAR wAccel = (WCHAR)wParam;
    3892     UINT* pIDButton = (UINT*)lParam;
    3893     WCHAR wszAccel[] = {'&',wAccel,0};
    3894     int i;
    3895    
    3896     TRACE("hwnd = %p, wAccel = %x(%s), pIDButton = %p\n",
    3897         hwnd, wAccel, debugstr_wn(&wAccel,1), pIDButton);
    3898    
    3899     for (i = 0; i < infoPtr->nNumButtons; i++)
    3900     {
    3901         TBUTTON_INFO *btnPtr = infoPtr->buttons+i;
    3902         if (!(btnPtr->fsStyle & BTNS_NOPREFIX) &&
    3903             !(btnPtr->fsState & TBSTATE_HIDDEN))
    3904         {
    3905             int iLen = strlenW(wszAccel);
    3906             LPCWSTR lpszStr = TOOLBAR_GetText(infoPtr, btnPtr);
    3907            
    3908             if (!lpszStr)
    3909                 continue;
    3910 
    3911             while (*lpszStr)
    3912             {
    3913                 if ((lpszStr[0] == '&') && (lpszStr[1] == '&'))
    3914                 {
    3915                     lpszStr += 2;
    3916                     continue;
    3917                 }
    3918                 if (!strncmpiW(lpszStr, wszAccel, iLen))
    3919                 {
    3920                     *pIDButton = btnPtr->idCommand;
    3921                     return TRUE;
    3922                 }
    3923                 lpszStr++;
    3924             }
    3925         }
    3926     }
    3927     return FALSE;
    3928 }
    3929 
    3930 
    3931 static LRESULT
    3932 TOOLBAR_MarkButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
    3933 {
    3934     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    3935     INT nIndex;
    3936 
    3937     TRACE("hwnd = %p, wParam = %d, lParam = 0x%08lx\n", hwnd, wParam, lParam);
    3938 
    3939     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    3940     if (nIndex == -1)
    3941         return FALSE;
    3942 
    3943     if (LOWORD(lParam))
    3944         infoPtr->buttons[nIndex].fsState |= TBSTATE_MARKED;
    3945     else
    3946         infoPtr->buttons[nIndex].fsState &= ~TBSTATE_MARKED;
    3947 
    3948     return TRUE;
    3949 }
    3950 
     3738/* << TOOLBAR_LoadImages >> */
     3739/* << TOOLBAR_MapAccelerator >> */
     3740/* << TOOLBAR_MarkButton >> */
    39513741/* << TOOLBAR_MoveButton >> */
    39523742
     
    39583748    TBUTTON_INFO *btnPtr;
    39593749    INT nIndex;
    3960     DWORD oldState;
    39613750
    39623751    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
     
    39653754
    39663755    btnPtr = &infoPtr->buttons[nIndex];
    3967     oldState = btnPtr->fsState;
    39683756    if (LOWORD(lParam) == FALSE)
    39693757        btnPtr->fsState &= ~TBSTATE_PRESSED;
     
    39713759        btnPtr->fsState |= TBSTATE_PRESSED;
    39723760
    3973     if(oldState != btnPtr->fsState)
    3974         InvalidateRect(hwnd, &btnPtr->rect, TRUE);
     3761    InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
    39753762
    39763763    return TRUE;
    39773764}
    39783765
    3979 /* FIXME: there might still be some confusion her between number of buttons
    3980  * and number of bitmaps */
     3766
    39813767static LRESULT
    39823768TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    39863772    HBITMAP hBitmap;
    39873773    int i = 0, nOldButtons = 0, pos = 0;
    3988     int nOldBitmaps, nNewBitmaps;
    39893774    HIMAGELIST himlDef = 0;
    39903775
     
    40303815        return FALSE;
    40313816    }
    4032    
    4033     himlDef = GETDEFIMAGELIST(infoPtr, 0); /* fixme: correct? */
    4034     nOldBitmaps = ImageList_GetImageCount(himlDef);
     3817
     3818    infoPtr->nNumBitmaps = infoPtr->nNumBitmaps - nOldButtons + lpReplace->nButtons;
    40353819
    40363820    /* ImageList_Replace(GETDEFIMAGELIST(), pos, hBitmap, NULL); */
    40373821
    4038     for (i = pos + nOldBitmaps - 1; i >= pos; i--)
     3822
     3823    himlDef = GETDEFIMAGELIST(infoPtr, 0);
     3824    for (i = pos + nOldButtons - 1; i >= pos; i--) {
    40393825        ImageList_Remove(himlDef, i);
     3826    }
    40403827
    40413828    {
     
    40663853       DeleteDC (hdcBitmap);
    40673854
    4068        ImageList_AddMasked (himlDef, hbmLoad, comctl32_color.clrBtnFace);
    4069        nNewBitmaps = ImageList_GetImageCount(himlDef);
     3855       ImageList_AddMasked (himlDef, hbmLoad, CLR_DEFAULT);
    40703856       DeleteObject (hbmLoad);
    40713857    }
    40723858
    4073     infoPtr->nNumBitmaps = infoPtr->nNumBitmaps - nOldBitmaps + nNewBitmaps;
    4074 
    4075     TRACE(" pos %d  %d old bitmaps replaced by %d new ones.\n",
    4076             pos, nOldBitmaps, nNewBitmaps);
    4077 
    4078     InvalidateRect(hwnd, NULL, TRUE);
     3859    InvalidateRect(hwnd, NULL, FALSE);
    40793860
    40803861    return TRUE;
     
    43934174}
    43944175
    4395 /* This function differs a bit from what MSDN says it does:
    4396  * 1. lParam contains extended style flags to OR with current style
    4397  *  (MSDN isn't clear on the OR bit)
    4398  * 2. wParam appears to contain extended style flags to be reset
    4399  *  (MSDN says that this parameter is reserved)
    4400  */
    44014176static LRESULT
    44024177TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    44064181
    44074182    dwTemp = infoPtr->dwExStyle;
    4408     infoPtr->dwExStyle &= ~wParam;
    4409     infoPtr->dwExStyle |= (DWORD)lParam;
    4410 
    4411     TRACE("new style 0x%08lx\n", infoPtr->dwExStyle);
     4183    infoPtr->dwExStyle = (DWORD)lParam;
     4184
     4185    if (infoPtr->dwExStyle & (TBSTYLE_EX_MIXEDBUTTONS |
     4186                              TBSTYLE_EX_HIDECLIPPEDBUTTONS)) {
     4187        FIXME("Extended style not implemented %s %s\n",
     4188              (infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) ?
     4189              "TBSTYLE_EX_MIXEDBUTTONS" : "",
     4190              (infoPtr->dwExStyle & TBSTYLE_EX_HIDECLIPPEDBUTTONS) ?
     4191              "TBSTYLE_EX_HIDECLIPPEDBUTTONS" : "");
     4192    }
    44124193
    44134194    if (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL)
    44144195        FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
    44154196              (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL));
    4416 
    4417     TOOLBAR_CalcToolbar (hwnd);
    4418 
    4419     TOOLBAR_AutoSize(hwnd);
    4420 
    4421     InvalidateRect(hwnd, NULL, TRUE);
    44224197
    44234198    return (LRESULT)dwTemp;
     
    44354210    if (infoPtr->iVersion >= 5)
    44364211        id = wParam;
    4437 
    4438     TRACE("hwnd = %p, himl = %p, id = %d\n", hwnd, himl, id);
    44394212
    44404213    himlTemp = TOOLBAR_InsertImageList(&infoPtr->himlHot,
     
    44654238            btnPtr = &infoPtr->buttons[(INT)wParam];
    44664239            btnPtr->bHot = TRUE;
    4467                 InvalidateRect (hwnd, &btnPtr->rect, TRUE);
     4240                InvalidateRect (hwnd, &btnPtr->rect,
     4241                    TOOLBAR_HasText(infoPtr, btnPtr));
    44684242        }
    44694243        if (nOldHotItem>=0)
     
    44714245            btnPtr = &infoPtr->buttons[nOldHotItem];
    44724246            btnPtr->bHot = FALSE;
    4473                 InvalidateRect (hwnd, &btnPtr->rect, TRUE);
     4247                InvalidateRect (hwnd, &btnPtr->rect,
     4248                    TOOLBAR_HasText(infoPtr, btnPtr));
    44744249        }
    44754250    }
     
    45064281          infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
    45074282
     4283    /* FIXME: redraw ? */
    45084284    InvalidateRect(hwnd, NULL, TRUE);
    45094285
     
    45594335    infoPtr->nMaxTextRows = (INT)wParam;
    45604336
    4561     TOOLBAR_CalcToolbar(hwnd);
    45624337    return TRUE;
    45634338}
    45644339
    45654340
    4566 /* MSDN gives slightly wrong info on padding.
    4567  * 1. It is not only used on buttons with the BTNS_AUTOSIZE style
    4568  * 2. It is not used to create a blank area between the edge of the button
    4569  *    and the text or image if TBSTYLE_LIST is set. It is used to control
    4570  *    the gap between the image and text.
    4571  * 3. It is not applied to both sides. If TBSTYLE_LIST is set it is used
    4572  *    to control the bottom and right borders [with the border being
    4573  *    szPadding.cx - (GetSystemMetrics(SM_CXEDGE)+1)], otherwise the padding
    4574  *    is shared evenly on both sides of the button.
    4575  */
    45764341static LRESULT
    45774342TOOLBAR_SetPadding (HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    45834348    infoPtr->szPadding.cx = LOWORD((DWORD)lParam);
    45844349    infoPtr->szPadding.cy = HIWORD((DWORD)lParam);
    4585     TRACE("cx=%ld, cy=%ld\n",
     4350    FIXME("stub - nothing done with values, cx=%ld, cy=%ld\n",
    45864351          infoPtr->szPadding.cx, infoPtr->szPadding.cy);
    45874352    return (LRESULT) oldPad;
     
    46264391
    46274392        /* repaint toolbar */
    4628         InvalidateRect(hwnd, NULL, TRUE);
     4393        InvalidateRect(hwnd, NULL, FALSE);
    46294394    }
    46304395
     
    46584423        btnPtr->fsState = LOWORD(lParam);
    46594424        TOOLBAR_CalcToolbar (hwnd);
    4660         InvalidateRect(hwnd, 0, TRUE);
     4425        InvalidateRect(hwnd, 0, TOOLBAR_HasText(infoPtr, btnPtr));
    46614426        return TRUE;
    46624427    }
     
    46664431    {
    46674432        btnPtr->fsState = LOWORD(lParam);
    4668         InvalidateRect(hwnd, &btnPtr->rect, TRUE);
     4433        InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
     4434            btnPtr));
    46694435    }
    46704436
     
    46764442TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
    46774443{
    4678     SetWindowLongW(hwnd, GWL_STYLE, lParam);
     4444    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     4445    TBUTTON_INFO *btnPtr;
     4446    INT nIndex;
     4447
     4448    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
     4449    if (nIndex == -1)
     4450        return FALSE;
     4451
     4452    btnPtr = &infoPtr->buttons[nIndex];
     4453
     4454    /* process style change if current style doesn't match new style */
     4455    if(btnPtr->fsStyle != LOWORD(lParam))
     4456    {
     4457        btnPtr->fsStyle = LOWORD(lParam);
     4458        InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
     4459            btnPtr));
     4460
     4461        if (infoPtr->hwndToolTip) {
     4462            FIXME("change tool tip!\n");
     4463        }
     4464    }
    46794465
    46804466    return TRUE;
     
    46864472{
    46874473    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    4688 
    4689     TRACE("hwnd=%p, hwndTooltip=%p, lParam=0x%lx\n", hwnd, (HWND)wParam, lParam);
    46904474
    46914475    if (infoPtr == NULL)
     
    47374521    infoPtr->clrBtnHighlight = lParam->clrBtnHighlight;
    47384522    infoPtr->clrBtnShadow = lParam->clrBtnShadow;
    4739     InvalidateRect(hwnd, NULL, TRUE);
     4523    InvalidateRect(hwnd, 0, 0);
    47404524    return 0;
    47414525}
     
    47564540}
    47574541
    4758 
    4759 static LRESULT
    4760 TOOLBAR_GetStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    4761 {
    4762     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
    4763     WORD iString = HIWORD(wParam);
    4764     WORD buffersize = LOWORD(wParam);
    4765     LPSTR str = (LPSTR)lParam;
    4766     LRESULT ret = -1;
    4767 
    4768     TRACE("hwnd=%p, iString=%d, buffersize=%d, string=%p\n", hwnd, iString, buffersize, str);
    4769 
    4770     if (iString < infoPtr->nNumStrings)
    4771     {
    4772         ret = WideCharToMultiByte(CP_ACP, 0, infoPtr->strings[iString], -1, str, buffersize, NULL, NULL);
    4773 
    4774         TRACE("returning %s\n", debugstr_a(str));
    4775     }
    4776     else
    4777         ERR("String index %d out of range (largest is %d)\n", iString, infoPtr->nNumStrings - 1);
    4778 
    4779     return ret;
    4780 }
    4781 
    4782 
    4783 static LRESULT
    4784 TOOLBAR_GetStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    4785 {
    4786     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
    4787     WORD iString = HIWORD(wParam);
    4788     WORD len = LOWORD(wParam)/sizeof(WCHAR) - 1;
    4789     LPWSTR str = (LPWSTR)lParam;
    4790     LRESULT ret = -1;
    4791 
    4792     TRACE("hwnd=%p, iString=%d, buffersize=%d, string=%p\n", hwnd, iString, LOWORD(wParam), str);
    4793 
    4794     if (iString < infoPtr->nNumStrings)
    4795     {
    4796         len = min(len, strlenW(infoPtr->strings[iString]));
    4797         ret = (len+1)*sizeof(WCHAR);
    4798         memcpy(str, infoPtr->strings[iString], ret);
    4799         str[len] = '\0';
    4800 
    4801         TRACE("returning %s\n", debugstr_w(str));
    4802     }
    4803     else
    4804         ERR("String index %d out of range (largest is %d)\n", iString, infoPtr->nNumStrings - 1);
    4805 
    4806     return ret;
    4807 }
    4808 
    4809 /* UNDOCUMENTED MESSAGE: This appears to set some kind of size. Perhaps it
    4810  * is the maximum size of the toolbar? */
    4811 static LRESULT TOOLBAR_Unkwn45D(HWND hwnd, WPARAM wParam, LPARAM lParam)
    4812 {
    4813     SIZE * pSize = (SIZE*)lParam;
    4814     FIXME("hwnd=%p, wParam=0x%08x, size.cx=%ld, size.cy=%ld stub!\n", hwnd, wParam, pSize->cx, pSize->cy);
    4815     return 0;
    4816 }
    48174542
    48184543/*********************************************************************/
     
    48494574        btnPtr = &infoPtr->buttons[(INT)wParam];
    48504575        btnPtr->bHot = (no_hi) ? FALSE : TRUE;
    4851         InvalidateRect (hwnd, &btnPtr->rect, TRUE);
     4576        InvalidateRect (hwnd, &btnPtr->rect,
     4577                        TOOLBAR_HasText(infoPtr, btnPtr));
    48524578    }
    48534579    if (nOldHotItem>=0) {
    48544580        btnPtr = &infoPtr->buttons[nOldHotItem];
    48554581        btnPtr->bHot = FALSE;
    4856         InvalidateRect (hwnd, &btnPtr->rect, TRUE);
     4582        InvalidateRect (hwnd, &btnPtr->rect,
     4583                        TOOLBAR_HasText(infoPtr, btnPtr));
    48574584    }
    48584585    GetFocus();
     
    48664593}
    48674594
    4868 /* UNDOCUMENTED MESSAGE: This sets the toolbar global iListGap parameter
    4869  * which controls the amount of spacing between the image and the text
    4870  * of buttons for TBSTYLE_LIST toolbars. */
    4871 static LRESULT TOOLBAR_Unkwn460(HWND hwnd, WPARAM wParam, LPARAM lParam)
    4872 {
    4873     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
    4874 
    4875     TRACE("hwnd=%p iListGap=%d\n", hwnd, wParam);
    4876    
    4877     if (lParam != 0)
    4878         FIXME("lParam = 0x%08lx. Please report\n", lParam);
    4879    
    4880     infoPtr->iListGap = (INT)wParam;
    4881 
    4882     TOOLBAR_CalcToolbar(hwnd);
    4883     InvalidateRect(hwnd, NULL, TRUE);
    4884 
    4885     return 0;
    4886 }
    4887 
    4888 /* UNDOCUMENTED MESSAGE: This returns the number of maximum number
    4889  * of image lists associated with the various states. */
    4890 static LRESULT TOOLBAR_Unkwn462(HWND hwnd, WPARAM wParam, LPARAM lParam)
    4891 {
    4892     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
    4893 
    4894     TRACE("hwnd=%p wParam %08x lParam %08lx\n", hwnd, wParam, lParam);
    4895 
    4896     return max(infoPtr->cimlDef, max(infoPtr->cimlHot, infoPtr->cimlDis));
    4897 }
    48984595
    48994596static LRESULT
     
    49264623            HWND hwndParent = GetParent(hwnd);
    49274624
     4625            InvalidateRect(hwnd, 0, 1);
    49284626            GetWindowRect(hwnd, &rc);
    49294627            MapWindowPoints(0, hwndParent, (LPPOINT)&rc, 2);
     
    49514649}
    49524650
    4953 static LRESULT TOOLBAR_Unkwn464(HWND hwnd, WPARAM wParam, LPARAM lParam)
    4954 {
    4955     FIXME("hwnd=%p wParam %08x lParam %08lx\n", hwnd, wParam, lParam);
    4956 
    4957     InvalidateRect(hwnd, NULL, TRUE);
    4958     return 1;
    4959 }
    4960 
    49614651
    49624652static LRESULT
     
    49664656    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    49674657    LOGFONTA logFont;
    4968 
    4969     TRACE("hwnd = %p\n", hwnd);
    49704658
    49714659    /* initialize info structure */
     
    49764664
    49774665    infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
     4666    infoPtr->nRows = 1;
    49784667    infoPtr->nMaxTextRows = 1;
    49794668    infoPtr->cxMin = -1;
     
    49874676    infoPtr->nOldHit = -1;
    49884677    infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
    4989     infoPtr->hwndNotify = ((LPCREATESTRUCTW)lParam)->hwndParent;
     4678    infoPtr->hwndNotify = GetParent (hwnd);
    49904679    infoPtr->bTransparent = (dwStyle & TBSTYLE_TRANSPARENT);
    49914680    infoPtr->bBtnTranspnt = (dwStyle & (TBSTYLE_FLAT | TBSTYLE_LIST));
     
    49974686    infoPtr->clrBtnHighlight = CLR_DEFAULT;
    49984687    infoPtr->clrBtnShadow = CLR_DEFAULT;
    4999     /* not sure where the +1 comes from, but this comes to the same value
    5000      * as native so this is probably correct */
    5001     infoPtr->szPadding.cx = 2*(GetSystemMetrics(SM_CXEDGE)+OFFSET_X) + 1;
    5002     infoPtr->szPadding.cy = 2*(GetSystemMetrics(SM_CYEDGE)+OFFSET_Y);
    5003     infoPtr->iListGap = infoPtr->szPadding.cx / 2;
    5004     GetClientRect(hwnd, &infoPtr->client_rect);
     4688    infoPtr->szPadding.cx = 7;
     4689    infoPtr->szPadding.cy = 6;
    50054690    TOOLBAR_NotifyFormat(infoPtr, (WPARAM)hwnd, (LPARAM)NF_REQUERY);
    50064691
     
    50444729        DestroyWindow (infoPtr->hwndToolTip);
    50454730
    5046     /* delete temporary buffer for tooltip text */
    5047     if (infoPtr->pszTooltipText)
    5048         HeapFree(GetProcessHeap(), 0, infoPtr->pszTooltipText);
    5049 
    50504731    /* delete button data */
    50514732    if (infoPtr->buttons)
    5052         Free (infoPtr->buttons);
     4733        COMCTL32_Free (infoPtr->buttons);
    50534734
    50544735    /* delete strings */
     
    50574738        for (i = 0; i < infoPtr->nNumStrings; i++)
    50584739            if (infoPtr->strings[i])
    5059                 Free (infoPtr->strings[i]);
    5060 
    5061         Free (infoPtr->strings);
     4740                COMCTL32_Free (infoPtr->strings[i]);
     4741
     4742        COMCTL32_Free (infoPtr->strings);
    50624743    }
    50634744
     
    50754756
    50764757    /* free toolbar info data */
    5077     Free (infoPtr);
     4758    COMCTL32_Free (infoPtr);
    50784759    SetWindowLongA (hwnd, 0, 0);
    50794760
     
    51834864        btnPtr->fsState |= TBSTATE_PRESSED;
    51844865
    5185         InvalidateRect(hwnd, &btnPtr->rect, TRUE);
     4866        InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
     4867            btnPtr));
    51864868    }
    51874869    else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
     
    52184900
    52194901        /* for EX_DRAWDDARROWS style,  click must be in the drop-down arrow rect */
    5220         if ((btnPtr->fsState & TBSTATE_ENABLED) &&
    5221              ((btnPtr->fsStyle & BTNS_WHOLEDROPDOWN) ||
    5222               ((btnPtr->fsStyle & BTNS_DROPDOWN) &&
    5223                ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
    5224                (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))))
     4902        if ((btnPtr->fsState & TBSTATE_ENABLED) && (btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
     4903             ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
     4904              (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
    52254905        {
    52264906            LRESULT res;
     
    52364916            nmtb.cchText = 0;
    52374917            nmtb.pszText = 0;
    5238             CopyRect(&nmtb.rcButton, &btnPtr->rect);
     4918            memset(&nmtb.rcButton, 0, sizeof(RECT));
    52394919            res = TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
    52404920                                  TBN_DROPDOWN);
     
    52524932
    52534933        if (btnPtr->fsState & TBSTATE_ENABLED)
    5254             InvalidateRect(hwnd, &btnPtr->rect, TRUE);
     4934            InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
    52554935        UpdateWindow(hwnd);
    52564936        SetCapture (hwnd);
     
    52994979        infoPtr->buttons[infoPtr->nHotItem].bHot = TRUE;
    53004980
    5301     if (0 <= infoPtr->nButtonDown) {
    53024981        btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
    53034982        btnPtr->fsState &= ~TBSTATE_PRESSED;
    53044983
    5305         if (btnPtr->fsStyle & BTNS_CHECK) {
    5306                 if (btnPtr->fsStyle & BTNS_GROUP) {
     4984        if (btnPtr->fsStyle & TBSTYLE_CHECK) {
     4985                if (btnPtr->fsStyle & TBSTYLE_GROUP) {
    53074986                    nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
    53084987                        nHit);
     
    53225001        }
    53235002
    5324         if (nOldIndex != -1)
    5325             InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect, TRUE);
     5003        if (nOldIndex != -1)
     5004        {
     5005            InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
     5006                TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
     5007        }
    53265008
    53275009        /*
     
    53665048            TOOLBAR_SendNotify ((NMHDR *) &nmmouse, infoPtr, NM_CLICK);
    53675049        }
    5368     }
    53695050    return 0;
    53705051}
     
    53865067
    53875068        if (btnPtr->fsState & TBSTATE_ENABLED)
    5388             InvalidateRect(hwnd, &btnPtr->rect, TRUE);
     5069            InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
     5070              btnPtr));
    53895071    }
    53905072    return 0;
     
    54105092        rc1 = hotBtnPtr->rect;
    54115093        InflateRect (&rc1, 1, 1);
    5412         InvalidateRect (hwnd, &rc1, TRUE);
     5094        InvalidateRect (hwnd, &rc1, TOOLBAR_HasText(infoPtr,
     5095            hotBtnPtr));
    54135096    }
    54145097
     
    54715154    if (infoPtr->nOldHit != nHit)
    54725155    {
    5473         /* Remove the effect of an old hot button if the button was
     5156        /* Remove the effect of an old hot button if the button was enabled and was
    54745157           drawn with the hot button effect */
    5475         if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem)
     5158        if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
     5159                (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
    54765160        {
    54775161            oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
     
    54865170            infoPtr->nHotItem = nHit;
    54875171
    5488             btnPtr->bHot = TRUE;
     5172            /* only enabled buttons show hot effect */
     5173            if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED)
     5174            {
     5175                btnPtr->bHot = TRUE;
     5176            }
    54895177        }
    54905178
     
    55025190        /* now invalidate the old and new buttons so they will be painted */
    55035191        if (oldBtnPtr)
    5504             InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE);
    5505         if (btnPtr)
    5506             InvalidateRect(hwnd, &btnPtr->rect, TRUE);
     5192            InvalidateRect (hwnd, &oldBtnPtr->rect,
     5193                            TOOLBAR_HasText(infoPtr, oldBtnPtr));
     5194        if (btnPtr && (btnPtr->fsState & TBSTATE_ENABLED))
     5195            InvalidateRect(hwnd, &btnPtr->rect,
     5196                           TOOLBAR_HasText(infoPtr, btnPtr));
    55075197
    55085198        if (infoPtr->bCaptured) {
     
    55515241
    55525242    /* allocate memory for info structure */
    5553     infoPtr = (TOOLBAR_INFO *)Alloc (sizeof(TOOLBAR_INFO));
     5243    infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
    55545244    SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
    55555245
    55565246    /* paranoid!! */
    55575247    infoPtr->dwStructSize = sizeof(TBBUTTON);
    5558     infoPtr->nRows = 1;
    55595248
    55605249    /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
     
    56505339
    56515340
    5652 /* handles requests from the tooltip control on what text to display */
    5653 static LRESULT TOOLBAR_TTGetDispInfo (TOOLBAR_INFO *infoPtr, NMTTDISPINFOW *lpnmtdi)
    5654 {
    5655     int index = TOOLBAR_GetButtonIndex(infoPtr, lpnmtdi->hdr.idFrom, FALSE);
    5656 
    5657     TRACE("button index = %d\n", index);
    5658 
    5659     if (infoPtr->pszTooltipText)
    5660     {
    5661         HeapFree(GetProcessHeap(), 0, infoPtr->pszTooltipText);
    5662         infoPtr->pszTooltipText = NULL;
    5663     }
    5664 
    5665     if (index < 0)
    5666         return 0;
    5667 
    5668     if (infoPtr->bNtfUnicode)
    5669     {
    5670         WCHAR wszBuffer[INFOTIPSIZE+1];
    5671         NMTBGETINFOTIPW tbgit;
    5672         int len; /* in chars */
    5673 
    5674         wszBuffer[0] = '\0';
    5675         wszBuffer[INFOTIPSIZE] = '\0';
    5676 
    5677         tbgit.pszText = wszBuffer;
    5678         tbgit.cchTextMax = INFOTIPSIZE;
    5679         tbgit.iItem = lpnmtdi->hdr.idFrom;
    5680         tbgit.lParam = infoPtr->buttons[index].dwData;
    5681 
    5682         TOOLBAR_SendNotify(&tbgit.hdr, infoPtr, TBN_GETINFOTIPW);
    5683 
    5684         TRACE("TBN_GETINFOTIPW - got string %s\n", debugstr_w(tbgit.pszText));
    5685 
    5686         len = strlenW(tbgit.pszText);
    5687         if (len > sizeof(lpnmtdi->szText)/sizeof(lpnmtdi->szText[0])-1)
    5688         {
    5689             /* need to allocate temporary buffer in infoPtr as there
    5690              * isn't enough space in buffer passed to us by the
    5691              * tooltip control */
    5692             infoPtr->pszTooltipText = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR));
    5693             if (infoPtr->pszTooltipText)
    5694             {
    5695                 memcpy(infoPtr->pszTooltipText, tbgit.pszText, (len+1)*sizeof(WCHAR));
    5696                 lpnmtdi->lpszText = infoPtr->pszTooltipText;
    5697                 return 0;
    5698             }
    5699         }
    5700         else if (len > 0)
    5701         {
    5702             memcpy(lpnmtdi->lpszText, tbgit.pszText, (len+1)*sizeof(WCHAR));
    5703             return 0;
    5704         }
    5705     }
    5706     else
    5707     {
    5708         CHAR szBuffer[INFOTIPSIZE+1];
    5709         NMTBGETINFOTIPA tbgit;
    5710         int len; /* in chars */
    5711 
    5712         szBuffer[0] = '\0';
    5713         szBuffer[INFOTIPSIZE] = '\0';
    5714 
    5715         tbgit.pszText = szBuffer;
    5716         tbgit.cchTextMax = INFOTIPSIZE;
    5717         tbgit.iItem = lpnmtdi->hdr.idFrom;
    5718         tbgit.lParam = infoPtr->buttons[index].dwData;
    5719 
    5720         TOOLBAR_SendNotify(&tbgit.hdr, infoPtr, TBN_GETINFOTIPA);
    5721 
    5722         TRACE("TBN_GETINFOTIPA - got string %s\n", debugstr_a(tbgit.pszText));
    5723 
    5724         len = -1 + MultiByteToWideChar(CP_ACP, 0, tbgit.pszText, -1, NULL, 0);
    5725         if (len > sizeof(lpnmtdi->szText)/sizeof(lpnmtdi->szText[0])-1)
    5726         {
    5727             /* need to allocate temporary buffer in infoPtr as there
    5728              * isn't enough space in buffer passed to us by the
    5729              * tooltip control */
    5730             infoPtr->pszTooltipText = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR));
    5731             if (infoPtr->pszTooltipText)
    5732             {
    5733                 MultiByteToWideChar(CP_ACP, 0, tbgit.pszText, len+1, infoPtr->pszTooltipText, (len+1)*sizeof(WCHAR));
    5734                 lpnmtdi->lpszText = infoPtr->pszTooltipText;
    5735                 return 0;
    5736             }
    5737         }
    5738         else if (len > 0)
    5739         {
    5740             MultiByteToWideChar(CP_ACP, 0, tbgit.pszText, len+1, lpnmtdi->lpszText, (len+1)*sizeof(WCHAR));
    5741             return 0;
    5742         }
    5743     }
    5744 
    5745     /* if button has text, but it is not shown then automatically
    5746      * use that text as tooltip */
    5747     if ((infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) &&
    5748         !(infoPtr->buttons[index].fsStyle & BTNS_SHOWTEXT))
    5749     {
    5750         LPWSTR pszText = TOOLBAR_GetText(infoPtr, &infoPtr->buttons[index]);
    5751         int len = pszText ? strlenW(pszText) : 0;
    5752 
    5753         TRACE("using button hidden text %s\n", debugstr_w(pszText));
    5754 
    5755         if (len > sizeof(lpnmtdi->szText)/sizeof(lpnmtdi->szText[0])-1)
    5756         {
    5757             /* need to allocate temporary buffer in infoPtr as there
    5758              * isn't enough space in buffer passed to us by the
    5759              * tooltip control */
    5760             infoPtr->pszTooltipText = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR));
    5761             if (infoPtr->pszTooltipText)
    5762             {
    5763                 memcpy(infoPtr->pszTooltipText, pszText, (len+1)*sizeof(WCHAR));
    5764                 lpnmtdi->lpszText = infoPtr->pszTooltipText;
    5765                 return 0;
    5766             }
    5767         }
    5768         else if (len > 0)
    5769         {
    5770             memcpy(lpnmtdi->lpszText, pszText, (len+1)*sizeof(WCHAR));
    5771             return 0;
    5772         }
    5773     }
    5774 
    5775     TRACE("Sending tooltip notification to %p\n", infoPtr->hwndNotify);
    5776 
    5777     /* last resort: send notification on to app */
    5778     /* FIXME: find out what is really used here */
    5779     return SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, 0, (LPARAM)lpnmtdi);
    5780 }
    5781 
    5782 
    57835341inline static LRESULT
    57845342TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    57875345    LPNMHDR lpnmh = (LPNMHDR)lParam;
    57885346
    5789     switch (lpnmh->code)
    5790     {
    5791     case PGN_CALCSIZE:
    5792     {
    5793         LPNMPGCALCSIZE lppgc = (LPNMPGCALCSIZE)lParam;
    5794 
    5795         if (lppgc->dwFlag == PGF_CALCWIDTH) {
    5796             lppgc->iWidth = infoPtr->rcBound.right - infoPtr->rcBound.left;
    5797             TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
    5798                   lppgc->iWidth);
    5799         }
    5800         else {
    5801             lppgc->iHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
    5802             TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
    5803                   lppgc->iHeight);
    5804         }
    5805         return 0;
    5806     }
    5807 
    5808     case PGN_SCROLL:
    5809     {
    5810         LPNMPGSCROLL lppgs = (LPNMPGSCROLL)lParam;
    5811 
    5812         lppgs->iScroll = (lppgs->iDir & (PGF_SCROLLLEFT | PGF_SCROLLRIGHT)) ?
    5813                           infoPtr->nButtonWidth : infoPtr->nButtonHeight;
    5814         TRACE("processed PGN_SCROLL, returning scroll=%d, dir=%d\n",
    5815               lppgs->iScroll, lppgs->iDir);
    5816         return 0;
    5817     }
    5818 
    5819     case TTN_GETDISPINFOW:
    5820         return TOOLBAR_TTGetDispInfo(infoPtr, (LPNMTTDISPINFOW)lParam);
    5821 
    5822     case TTN_GETDISPINFOA:
    5823         FIXME("TTN_GETDISPINFOA - stub\n");
    5824         return 0;
    5825 
    5826     default:
    5827         return 0;
    5828     }
     5347    if (lpnmh->code == PGN_CALCSIZE) {
     5348        LPNMPGCALCSIZE lppgc = (LPNMPGCALCSIZE)lParam;
     5349
     5350        if (lppgc->dwFlag == PGF_CALCWIDTH) {
     5351            lppgc->iWidth = infoPtr->rcBound.right - infoPtr->rcBound.left;
     5352            TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
     5353                  lppgc->iWidth);
     5354        }
     5355        else {
     5356            lppgc->iHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
     5357            TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
     5358                  lppgc->iHeight);
     5359        }
     5360        return 0;
     5361    }
     5362
     5363    if (lpnmh->code == PGN_SCROLL) {
     5364        LPNMPGSCROLL lppgs = (LPNMPGSCROLL)lParam;
     5365
     5366        lppgs->iScroll = (lppgs->iDir & (PGF_SCROLLLEFT | PGF_SCROLLRIGHT)) ?
     5367                          infoPtr->nButtonWidth : infoPtr->nButtonHeight;
     5368        TRACE("processed PGN_SCROLL, returning scroll=%d, dir=%d\n",
     5369              lppgs->iScroll, lppgs->iDir);
     5370        return 0;
     5371    }
     5372
     5373
     5374    TRACE("passing WM_NOTIFY!\n");
     5375
     5376    if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
     5377        if (infoPtr->bNtfUnicode)
     5378            return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
     5379                                 wParam, lParam);
     5380        else
     5381            return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
     5382                                 wParam, lParam);
     5383
     5384#if 0
     5385        if (lpnmh->code == TTN_GETDISPINFOA) {
     5386            LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
     5387
     5388            FIXME("retrieving ASCII string\n");
     5389
     5390        }
     5391        else if (lpnmh->code == TTN_GETDISPINFOW) {
     5392            LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
     5393
     5394            FIXME("retrieving UNICODE string\n");
     5395
     5396        }
     5397#endif
     5398    }
     5399
     5400    return 0;
    58295401}
    58305402
     
    58465418    INT i;
    58475419
    5848     TRACE("wParam = 0x%x, lParam = 0x%08lx\n", wParam, lParam);
    5849 
    5850     if ((lParam == NF_QUERY) && ((HWND)wParam == infoPtr->hwndToolTip))
    5851         return NFR_UNICODE;
    5852 
    58535420    if (lParam == NF_REQUERY) {
    5854         i = SendMessageA(infoPtr->hwndNotify,
     5421        i = SendMessageA(GetParent(infoPtr->hwndSelf),
    58555422                         WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
    58565423        if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
     
    59005467      *  *previous* status of the redraw flag (either 0 or 1)
    59015468      *  instead of the MSDN documented value of 0 if handled.
    5902       *  (For laughs see the "consistency" with same function
     5469      *  (For laughs see the "consistancy" with same function
    59035470      *   in rebar.)
    59045471      *
     
    59755542            cx = infoPtr->nWidth;
    59765543
    5977             if ((dwStyle & CCS_BOTTOM) == CCS_NOMOVEY) {
     5544            if (dwStyle & CCS_NOMOVEY) {
    59785545                GetWindowRect(hwnd, &window_rect);
    59795546                ScreenToClient(parent, (LPPOINT)&window_rect.left);
    5980                 y = window_rect.top;
     5547                y = window_rect.top;
    59815548            }
    5982             if ((dwStyle & CCS_BOTTOM) == CCS_BOTTOM) {
    5983                 GetWindowRect(hwnd, &window_rect);
    5984                 y = parent_rect.bottom -
    5985                     ( window_rect.bottom - window_rect.top);
    5986             }
    59875549        }
    59885550
     
    60035565        }
    60045566
    6005         if(infoPtr->dwExStyle & TBSTYLE_EX_HIDECLIPPEDBUTTONS)
    6006         {
    6007             RECT delta_width, delta_height, client, dummy;
    6008             DWORD min_x, max_x, min_y, max_y;
    6009             TBUTTON_INFO *btnPtr;
    6010             INT i;
    6011 
    6012             GetClientRect(hwnd, &client);
    6013             if(client.right > infoPtr->client_rect.right)
    6014             {
    6015                 min_x = infoPtr->client_rect.right;
    6016                 max_x = client.right;
    6017             }
    6018             else
    6019             {
    6020                 max_x = infoPtr->client_rect.right;
    6021                 min_x = client.right;
    6022             }
    6023             if(client.bottom > infoPtr->client_rect.bottom)
    6024             {
    6025                 min_y = infoPtr->client_rect.bottom;
    6026                 max_y = client.bottom;
    6027             }
    6028             else
    6029             {
    6030                 max_y = infoPtr->client_rect.bottom;
    6031                 min_y = client.bottom;
    6032             }
    6033 
    6034             SetRect(&delta_width, min_x, 0, max_x, min_y);
    6035             SetRect(&delta_height, 0, min_y, max_x, max_y);
    6036 
    6037             TRACE("delta_width %s delta_height %s\n", wine_dbgstr_rect(&delta_width), wine_dbgstr_rect(&delta_height));
    6038             btnPtr = infoPtr->buttons;
    6039             for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
    6040                 if(IntersectRect(&dummy, &delta_width, &btnPtr->rect) ||
    6041                    IntersectRect(&dummy, &delta_height, &btnPtr->rect))
    6042                     InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    6043         }
    6044 
    6045         if((uPosFlags & (SWP_NOSIZE | SWP_NOMOVE)) == (SWP_NOSIZE | SWP_NOMOVE))
    6046             SetWindowPos (hwnd, 0,  x,  y, cx, cy, uPosFlags | SWP_NOZORDER);
    6047     }
    6048     GetClientRect(hwnd, &infoPtr->client_rect);
     5567        SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
     5568                        cx, cy, uPosFlags | SWP_NOZORDER);
     5569    }
    60495570    return 0;
    60505571}
     
    60675588                                 (TBSTYLE_FLAT | TBSTYLE_LIST));
    60685589        TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew);
    6069 
    6070         TRACE("new style 0x%08lx\n", lpStyle->styleNew);
    6071     }
    6072 
    6073     TOOLBAR_CalcToolbar(hwnd);
     5590    }
    60745591
    60755592    TOOLBAR_AutoSize (hwnd);
    60765593
    6077     InvalidateRect(hwnd, NULL, TRUE);
     5594    InvalidateRect(hwnd, NULL, FALSE);
    60785595
    60795596    return 0;
     
    60945611ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    60955612{
    6096     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    6097 
    60985613    TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
    60995614          hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
     
    62115726            return TOOLBAR_GetState (hwnd, wParam, lParam);
    62125727
    6213         case TB_GETSTRINGA:
    6214         return TOOLBAR_GetStringA (hwnd, wParam, lParam);
    6215 
    6216         case TB_GETSTRINGW:
    6217             return TOOLBAR_GetStringW (hwnd, wParam, lParam);
    6218 
    62195728        case TB_GETSTYLE:
    62205729            return TOOLBAR_GetStyle (hwnd, wParam, lParam);
     
    62645773            return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
    62655774
    6266         case TB_LOADIMAGES:
    6267             return TOOLBAR_LoadImages (hwnd, wParam, lParam);
    6268 
    6269         case TB_MAPACCELERATORA:
    6270         case TB_MAPACCELERATORW:
    6271             return TOOLBAR_MapAccelerator (hwnd, wParam, lParam);
    6272 
    6273         case TB_MARKBUTTON:
    6274             return TOOLBAR_MarkButton (hwnd, wParam, lParam);
    6275 
     5775        case TB_LOADIMAGES:                        /* 4.70 */
     5776            FIXME("missing standard imagelists\n");
     5777            return 0;
     5778
     5779/*      case TB_MAPACCELERATORA:                */ /* 4.71 */
     5780/*      case TB_MAPACCELERATORW:                */ /* 4.71 */
     5781/*      case TB_MARKBUTTON:                     */ /* 4.71 */
    62765782/*      case TB_MOVEBUTTON:                     */ /* 4.71 */
    62775783
     
    63595865            return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
    63605866
    6361         case TB_UNKWN45D:
    6362             return TOOLBAR_Unkwn45D(hwnd, wParam, lParam);
    6363 
    63645867        case TB_UNKWN45E:
    63655868            return TOOLBAR_Unkwn45E (hwnd, wParam, lParam);
    63665869
    6367         case TB_UNKWN460:
    6368             return TOOLBAR_Unkwn460(hwnd, wParam, lParam);
    6369 
    6370         case TB_UNKWN462:
    6371             return TOOLBAR_Unkwn462(hwnd, wParam, lParam);
    6372 
    63735870        case TB_UNKWN463:
    63745871            return TOOLBAR_Unkwn463 (hwnd, wParam, lParam);
    63755872
    6376         case TB_UNKWN464:
    6377             return TOOLBAR_Unkwn464(hwnd, wParam, lParam);
    63785873
    63795874/* Common Control Messages */
     
    64455940
    64465941        case WM_NOTIFYFORMAT:
    6447             return TOOLBAR_NotifyFormatFake (hwnd, wParam, lParam);
     5942            TOOLBAR_NotifyFormatFake (hwnd, wParam, lParam);
    64485943
    64495944        case WM_PAINT:
     
    64695964        case WM_MEASUREITEM:
    64705965        case WM_VKEYTOITEM:
    6471             return SendMessageA (infoPtr->hwndNotify, uMsg, wParam, lParam);
     5966            {
     5967                TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     5968                if(infoPtr != NULL)
     5969                    return SendMessageA (infoPtr->hwndNotify, uMsg, wParam, lParam);
     5970                else
     5971                    return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
     5972            }
    64725973
    64735974        /* We see this in Outlook Express 5.x and just does DefWindowProc */
     
    64955996    wndClass.cbClsExtra    = 0;
    64965997    wndClass.cbWndExtra    = sizeof(TOOLBAR_INFO *);
    6497     wndClass.hCursor       = LoadCursorA (0, (LPSTR)IDC_ARROWA);
     5998    wndClass.hCursor       = LoadCursorA (0, IDC_ARROWA);
    64985999    wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
    64996000    wndClass.lpszClassName = TOOLBARCLASSNAMEA;
     
    65226023        PIMLENTRY *pnies;
    65236024
    6524         c = (PIMLENTRY) Alloc(sizeof(IMLENTRY));
     6025        c = (PIMLENTRY) COMCTL32_Alloc(sizeof(IMLENTRY));
    65256026        c->id = id;
    65266027
    6527         pnies = Alloc((*cies + 1) * sizeof(PIMLENTRY));
     6028        pnies = COMCTL32_Alloc((*cies + 1) * sizeof(PIMLENTRY));
    65286029        memcpy(pnies, *pies, ((*cies) * sizeof(PIMLENTRY)));
    65296030        pnies[*cies] = c;
    65306031        (*cies)++;
    65316032
    6532         Free(*pies);
     6033        COMCTL32_Free(*pies);
    65336034        *pies = pnies;
    65346035    }
     
    65466047
    65476048    for (i = 0; i < *cies; i++)
    6548         Free((*pies)[i]);
    6549 
    6550     Free(*pies);
     6049        COMCTL32_Free((*pies)[i]);
     6050
     6051    COMCTL32_Free(*pies);
    65516052
    65526053    *cies = 0;
Note: See TracChangeset for help on using the changeset viewer.