Ignore:
Timestamp:
May 8, 2002, 1:26:30 PM (23 years ago)
Author:
sandervl
Message:

merge with latest Wine

File:
1 edited

Legend:

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

    r7815 r8382  
    44 * Copyright 1998,1999 Eric Kohl
    55 * Copyright 2000 Eric Kohl for CodeWeavers
     6 *
     7 * This library is free software; you can redistribute it and/or
     8 * modify it under the terms of the GNU Lesser General Public
     9 * License as published by the Free Software Foundation; either
     10 * version 2.1 of the License, or (at your option) any later version.
     11 *
     12 * This library is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15 * Lesser General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU Lesser General Public
     18 * License along with this library; if not, write to the Free Software
     19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    620 *
    721 *  Differences between MSDN and actual native control operation:
     
    5670#include "imagelist.h"
    5771#include "comctl32.h"
    58 #include "debugtools.h"
    59 
    60 DEFAULT_DEBUG_CHANNEL(toolbar);
     72#include "wine/debug.h"
     73
     74WINE_DEFAULT_DEBUG_CHANNEL(toolbar);
    6175
    6276typedef struct
     
    7387    RECT rect;
    7488} TBUTTON_INFO;
     89
     90typedef struct
     91{
     92    UINT nButtons;
     93    HINSTANCE hInst;
     94    UINT nID;
     95} TBITMAP_INFO;
    7596
    7697typedef struct
     
    91112    INT      nNumBitmaps;     /* number of bitmaps */
    92113    INT      nNumStrings;     /* number of strings */
     114    INT      nNumBitmapInfos;
    93115    BOOL     bUnicode;        /* ASCII (FALSE) or Unicode (TRUE)? */
    94116    BOOL     bCaptured;       /* mouse captured? */
     
    96118    INT      nOldHit;
    97119    INT      nHotItem;        /* index of the "hot" item */
     120    DWORD    dwBaseCustDraw;  /* CDRF_ response (w/o TBCDRF_) from PREPAINT */
     121    DWORD    dwItemCustDraw;  /* CDRF_ response (w/o TBCDRF_) from ITEMPREP */
     122    DWORD    dwItemCDFlag;    /* TBCDRF_ flags from last ITEMPREPAINT    */
     123    SIZE     szPadding;       /* padding values around button */
    98124    HFONT    hDefaultFont;
    99125    HFONT    hFont;           /* text font */
     
    115141
    116142    COLORREF   clrInsertMark;   /* insert mark color */
     143    COLORREF   clrBtnHighlight; /* color for Flat Separator */
     144    COLORREF   clrBtnShadow;    /* color for Flag Separator */
    117145    RECT     rcBound;         /* bounding rectangle */
    118146    INT      iVersion;
     
    120148    TBUTTON_INFO *buttons;      /* pointer to button array */
    121149    LPWSTR       *strings;      /* pointer to string array */
     150    TBITMAP_INFO *bitmaps;
    122151} TOOLBAR_INFO, *PTOOLBAR_INFO;
    123152
     
    147176#define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
    148177#define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
     178
     179/* Used to find undocumented extended styles */
     180#define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \
     181                        TBSTYLE_EX_UNDOC1 | \
     182                        TBSTYLE_EX_MIXEDBUTTONS | \
     183                        TBSTYLE_EX_HIDECLIPPEDBUTTONS)
     184
     185static LRESULT
     186TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam);
    149187
    150188
     
    302340
    303341    if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
     342        if (btnPtr->iBitmap == I_IMAGENONE) return FALSE;
    304343        ERR("index %d is not valid, max %d\n",
    305344            btnPtr->iBitmap, infoPtr->nNumBitmaps);
     
    308347
    309348    if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
    310         if (index == -1) return FALSE;
     349        if ((index == I_IMAGECALLBACK) ||
     350            (index == I_IMAGENONE)) return FALSE;
    311351        ERR("TBN_GETDISPINFO returned invalid index %d\n",
    312352            index);
     
    335375
    336376    if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
     377        if (btnPtr->iBitmap == I_IMAGENONE) return FALSE;
    337378        ERR("index %d is not valid, max %d\n",
    338379            btnPtr->iBitmap, infoPtr->nNumBitmaps);
     
    341382
    342383    if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
    343         if (index == -1) return FALSE;
     384        if ((index == I_IMAGECALLBACK) ||
     385            (index == I_IMAGENONE)) return FALSE;
    344386        ERR("TBN_GETDISPINFO returned invalid index %d\n",
    345387            index);
     
    351393
    352394static void
    353 TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc)
    354 {
    355     INT x = (lpRect->left + lpRect->right) / 2 - 1;
    356     INT yBottom = lpRect->bottom - 3;
    357     INT yTop = lpRect->top + 1;
    358 
    359     SelectObject ( hdc, GetSysColorPen (COLOR_3DSHADOW));
    360     MoveToEx (hdc, x, yBottom, NULL);
    361     LineTo (hdc, x, yTop);
    362     x++;
    363     SelectObject ( hdc, GetSysColorPen (COLOR_3DHILIGHT));
    364     MoveToEx (hdc, x, yBottom, NULL);
    365     LineTo (hdc, x, yTop);
     395TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc, TOOLBAR_INFO *infoPtr)
     396{
     397    RECT myrect;
     398    COLORREF oldcolor, newcolor;
     399
     400    myrect.left = (lpRect->left + lpRect->right) / 2 - 1;
     401    myrect.right = myrect.left + 1;
     402    myrect.top = lpRect->top + 2;
     403    myrect.bottom = lpRect->bottom - 2;
     404
     405    newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
     406                comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
     407    oldcolor = SetBkColor (hdc, newcolor);
     408    ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
     409
     410    myrect.left = myrect.right;
     411    myrect.right = myrect.left + 1;
     412
     413    newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
     414                comctl32_color.clrBtnHighlight : infoPtr->clrBtnHighlight;
     415    SetBkColor (hdc, newcolor);
     416    ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
     417
     418    SetBkColor (hdc, oldcolor);
    366419}
    367420
     
    379432*/
    380433static void
    381 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect, HDC hdc, TBUTTON_INFO *btnPtr)
     434TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect, HDC hdc, TBUTTON_INFO *btnPtr, TOOLBAR_INFO *infoPtr)
    382435{
    383436    RECT myrect;
     
    394447          myrect.left, myrect.top, myrect.right, myrect.bottom);
    395448
    396     newcolor = GetSysColor (COLOR_BTNSHADOW);
     449    newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
     450                comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
    397451    oldcolor = SetBkColor (hdc, newcolor);
    398452    ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
     
    401455    myrect.bottom = myrect.top + 1;
    402456
    403     newcolor = GetSysColor (COLOR_BTNHIGHLIGHT);
     457    newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
     458                comctl32_color.clrBtnHighlight : infoPtr->clrBtnHighlight;
    404459    SetBkColor (hdc, newcolor);
    405460    ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
     
    432487static void
    433488TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
    434                     HDC hdc, INT nState, DWORD dwStyle)
    435 {
    436     RECT   rcText = btnPtr->rect;
    437     HFONT  hOldFont;
    438     COLORREF clrOld;
     489                    HDC hdc, INT nState, DWORD dwStyle,
     490                    RECT *rcText, LPWSTR lpText, NMTBCUSTOMDRAW *tbcd)
     491{
     492    HFONT  hOldFont = 0;
     493    COLORREF clrOld = 0;
     494
     495    /* draw text */
     496    if (lpText) {
     497        TRACE("string rect=(%d,%d)-(%d,%d)\n",
     498              rcText->left, rcText->top, rcText->right, rcText->bottom);
     499
     500        hOldFont = SelectObject (hdc, infoPtr->hFont);
     501        if (!(nState & TBSTATE_ENABLED)) {
     502            clrOld = SetTextColor (hdc, tbcd->clrBtnHighlight);
     503            OffsetRect (rcText, 1, 1);
     504            DrawTextW (hdc, lpText, -1, rcText, infoPtr->dwDTFlags);
     505            SetTextColor (hdc, comctl32_color.clr3dShadow);
     506            OffsetRect (rcText, -1, -1);
     507        }
     508        else if (nState & TBSTATE_INDETERMINATE) {
     509            clrOld = SetTextColor (hdc, comctl32_color.clr3dShadow);
     510        }
     511        else if (btnPtr->bHot && (infoPtr->dwItemCDFlag & TBCDRF_HILITEHOTTRACK )) {
     512            clrOld = SetTextColor (hdc, tbcd->clrTextHighlight);
     513        }
     514        else {
     515            clrOld = SetTextColor (hdc, tbcd->clrText);
     516        }
     517
     518        DrawTextW (hdc, lpText, -1, rcText, infoPtr->dwDTFlags);
     519        SetTextColor (hdc, clrOld);
     520        SelectObject (hdc, hOldFont);
     521    }
     522}
     523
     524
     525static void
     526TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
     527{
     528    HBRUSH hbr = SelectObject (hdc, COMCTL32_hPattern55AABrush);
     529    INT cx = lpRect->right - lpRect->left;
     530    INT cy = lpRect->bottom - lpRect->top;
     531    PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
     532    SelectObject (hdc, hbr);
     533}
     534
     535
     536static void
     537TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
     538                    HDC hdc, INT x, INT y)
     539{
     540    /* FIXME: this function is a hack since it uses image list
     541              internals directly */
     542
     543    HIMAGELIST himl = infoPtr->himlDef;
     544    HBITMAP hbmMask;
     545    HDC hdcImageList;
     546    HDC hdcMask;
     547
     548    if (!himl)
     549        return;
     550
     551    /* create new dc's */
     552    hdcImageList = CreateCompatibleDC (0);
     553    hdcMask = CreateCompatibleDC (0);
     554
     555    /* create new bitmap */
     556    hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL);
     557    SelectObject (hdcMask, hbmMask);
     558
     559    /* copy the mask bitmap */
     560    SelectObject (hdcImageList, himl->hbmMask);
     561    SetBkColor (hdcImageList, RGB(255, 255, 255));
     562    SetTextColor (hdcImageList, RGB(0, 0, 0));
     563    BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
     564              hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
     565
     566    /* draw the new mask */
     567    SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
     568    BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
     569              hdcMask, 0, 0, 0xB8074A);
     570
     571    SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
     572    BitBlt (hdc, x, y, himl->cx, himl->cy,
     573              hdcMask, 0, 0, 0xB8074A);
     574
     575    DeleteObject (hbmMask);
     576    DeleteDC (hdcMask);
     577    DeleteDC (hdcImageList);
     578}
     579
     580
     581static UINT
     582TOOLBAR_TranslateState(TBUTTON_INFO *btnPtr)
     583{
     584    UINT retstate = 0;
     585
     586    retstate |= (btnPtr->fsState & TBSTATE_CHECKED) ? CDIS_CHECKED  : 0;
     587    retstate |= (btnPtr->fsState & TBSTATE_PRESSED) ? CDIS_SELECTED : 0;
     588    retstate |= (btnPtr->fsState & TBSTATE_ENABLED) ? 0 : CDIS_DISABLED;
     589    retstate |= (btnPtr->fsState & TBSTATE_MARKED ) ? CDIS_MARKED   : 0;
     590    retstate |= (btnPtr->bHot                     ) ? CDIS_HOT      : 0;
     591    retstate |= (btnPtr->fsState & TBSTATE_INDETERMINATE) ? CDIS_INDETERMINATE : 0;
     592    /* FIXME: don't set CDIS_GRAYED, CDIS_FOCUS, CDIS_DEFAULT       */
     593    /*        don't test TBSTATE_HIDDEN                             */
     594    return retstate;
     595}
     596
     597
     598static void
     599TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
     600{
     601    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     602    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     603    BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) &&
     604                            (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
     605    RECT rc, rcArrow, rcBitmap, rcText, rcFill;
    439606    LPWSTR lpText = NULL;
    440     HIMAGELIST himl = infoPtr->himlDef;
    441 
    442     TRACE ("iString: %x\n", btnPtr->iString);
     607    NMTBCUSTOMDRAW tbcd;
     608    DWORD ntfret;
     609    INT offset;
     610
     611    if (btnPtr->fsState & TBSTATE_HIDDEN)
     612        return;
     613
     614    rc = btnPtr->rect;
     615    CopyRect (&rcFill, &rc);
     616    CopyRect (&rcArrow, &rc);
     617    CopyRect(&rcBitmap, &rc);
     618    CopyRect(&rcText, &rc);
    443619
    444620    /* get a pointer to the text */
    445621    lpText = TOOLBAR_GetText(infoPtr, btnPtr);
    446622
     623    if (hasDropDownArrow)
     624    {
     625        if (dwStyle & TBSTYLE_FLAT)
     626            rc.right = max(rc.left, rc.right - DDARROW_WIDTH);
     627        else
     628            rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2);
     629        rcArrow.left = rc.right;
     630    }
     631
     632    /* Center the bitmap horizontally and vertically */
     633    if (dwStyle & TBSTYLE_LIST)
     634        rcBitmap.left += 3;
     635    else
     636        rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2;
     637
     638    if(lpText)
     639        rcBitmap.top+=2; /* this looks to be the correct value from vmware comparison - cmm */
     640    else
     641        rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2;
     642
     643    TRACE("iBitmap: %d, start=(%d,%d) w=%d, h=%d\n",
     644          btnPtr->iBitmap, rcBitmap.left, rcBitmap.top,
     645          infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
     646    TRACE ("iString: %x\n", btnPtr->iString);
    447647    TRACE ("Stringtext: %s\n", debugstr_w(lpText));
    448648
     
    452652        InflateRect (&rcText, -3, -3);
    453653
    454         if (himl && TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
     654        if (infoPtr->himlDef &&
     655            TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
    455656                /* The following test looked like this before
    456657                 * I changed it. IE4 "Links" toolbar would not
     
    477678        }
    478679
    479         if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
     680        if (btnPtr->fsState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
    480681            OffsetRect (&rcText, 1, 1);
    481 
    482         TRACE("string rect=(%d,%d)-(%d,%d)\n",
    483               rcText.left, rcText.top, rcText.right, rcText.bottom);
    484 
    485         hOldFont = SelectObject (hdc, infoPtr->hFont);
    486         if (!(nState & TBSTATE_ENABLED)) {
    487             clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
    488             OffsetRect (&rcText, 1, 1);
    489             DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
    490             SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
    491             OffsetRect (&rcText, -1, -1);
    492             DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
    493         }
    494         else if (nState & TBSTATE_INDETERMINATE) {
    495             clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
    496             DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
    497         }
    498         else {
    499             clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
    500             DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
    501         }
    502 
    503         SetTextColor (hdc, clrOld);
    504         SelectObject (hdc, hOldFont);
    505     }
    506 }
    507 
    508 
    509 static void
    510 TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
    511 {
    512     HBRUSH hbr = SelectObject (hdc, COMCTL32_hPattern55AABrush);
    513     INT cx = lpRect->right - lpRect->left;
    514     INT cy = lpRect->bottom - lpRect->top;
    515     PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
    516     SelectObject (hdc, hbr);
    517 }
    518 
    519 
    520 static void
    521 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
    522                     HDC hdc, INT x, INT y)
    523 {
    524     /* FIXME: this function is a hack since it uses image list
    525               internals directly */
    526 
    527     HIMAGELIST himl = infoPtr->himlDef;
    528     HBITMAP hbmMask;
    529     HDC hdcImageList;
    530     HDC hdcMask;
    531 
    532     if (!himl)
    533         return;
    534 
    535     /* create new dc's */
    536     hdcImageList = CreateCompatibleDC (0);
    537     hdcMask = CreateCompatibleDC (0);
    538 
    539     /* create new bitmap */
    540     hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL);
    541     SelectObject (hdcMask, hbmMask);
    542 
    543     /* copy the mask bitmap */
    544     SelectObject (hdcImageList, himl->hbmMask);
    545     SetBkColor (hdcImageList, RGB(255, 255, 255));
    546     SetTextColor (hdcImageList, RGB(0, 0, 0));
    547     BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
    548               hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
    549 
    550     /* draw the new mask */
    551     SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
    552     BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
    553               hdcMask, 0, 0, 0xB8074A);
    554 
    555     SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
    556     BitBlt (hdc, x, y, himl->cx, himl->cy,
    557               hdcMask, 0, 0, 0xB8074A);
    558 
    559     DeleteObject (hbmMask);
    560     DeleteDC (hdcMask);
    561     DeleteDC (hdcImageList);
    562 }
    563 
    564 
    565 static void
    566 TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
    567 {
    568     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    569     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    570     BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) &&
    571                             (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
    572     RECT rc, rcArrow, rcBitmap;
    573 
    574     if (btnPtr->fsState & TBSTATE_HIDDEN)
    575         return;
    576 
    577     rc = btnPtr->rect;
    578     CopyRect (&rcArrow, &rc);
    579     CopyRect(&rcBitmap, &rc);
     682    }
     683
     684    /* Initialize fields in all cases, because we use these later */
     685    ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
     686    tbcd.clrText = comctl32_color.clrBtnText;
     687    tbcd.clrTextHighlight = comctl32_color.clrHighlightText;
     688    tbcd.clrBtnFace = comctl32_color.clrBtnFace;
     689    tbcd.clrBtnHighlight = comctl32_color.clrBtnHighlight;
     690    tbcd.clrMark = comctl32_color.clrHighlight;
     691    tbcd.clrHighlightHotTrack = 0;
     692    tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
     693    tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
     694    /* MSDN says that this is the text rectangle.              */
     695    /* But (why always a but) tracing of v5.7 of native shows  */
     696    /* that this is really a *relative* rectangle based on the */
     697    /* the nmcd.rc. Also the left and top are always 0 ignoring*/
     698    /* any bitmap that might be present.                       */
     699    tbcd.rcText.left = 0;
     700    tbcd.rcText.top = 0;
     701    tbcd.rcText.right = rcText.right - rc.left;
     702    tbcd.rcText.bottom = rcText.bottom - rc.top;
     703
     704    /* FIXME: what should these be set to ????? */
     705    tbcd.hbrMonoDither = 0;
     706    tbcd.hbrLines = 0;
     707    tbcd.hpenLines = 0;
     708
     709    /* Issue Item Prepaint notify */
     710    infoPtr->dwItemCustDraw = 0;
     711    infoPtr->dwItemCDFlag = 0;
     712    if (infoPtr->dwBaseCustDraw & CDRF_NOTIFYITEMDRAW)
     713    {
     714        tbcd.nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
     715        tbcd.nmcd.hdc = hdc;
     716        tbcd.nmcd.rc = rc;
     717        tbcd.nmcd.dwItemSpec = btnPtr->idCommand;
     718        tbcd.nmcd.uItemState = TOOLBAR_TranslateState(btnPtr);
     719        tbcd.nmcd.lItemlParam = btnPtr->dwData;
     720        ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
     721        infoPtr->dwItemCustDraw = ntfret & 0xffff;
     722        infoPtr->dwItemCDFlag = ntfret & 0xffff0000;
     723        if (infoPtr->dwItemCustDraw & CDRF_SKIPDEFAULT)
     724            return;
     725        /* save the only part of the rect that the user can change */
     726        rcText.right = tbcd.rcText.right + rc.left;
     727        rcText.bottom = tbcd.rcText.bottom + rc.top;
     728    }
    580729
    581730    if (!infoPtr->bBtnTranspnt)
    582         FillRect( hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
    583 
    584     if (hasDropDownArrow)
    585     {
    586         if (dwStyle & TBSTYLE_FLAT)
    587             rc.right = max(rc.left, rc.right - DDARROW_WIDTH);
    588         else
    589             rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2);
    590         rcArrow.left = rc.right;
    591     }
    592 
    593     /* Center the bitmap horizontally and vertically */
    594     if (dwStyle & TBSTYLE_LIST)
    595         rcBitmap.left += 3;
    596     else
    597         rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2;
    598 
    599     if(TOOLBAR_HasText(infoPtr, btnPtr))
    600         rcBitmap.top+=2; /* this looks to be the correct value from vmware comparison - cmm */
    601     else
    602         rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2;
    603 
    604     TRACE("iBitmap: %d, start=(%d,%d) w=%d, h=%d\n",
    605           btnPtr->iBitmap, rcBitmap.left, rcBitmap.top,
    606           infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
     731        FillRect( hdc, &rcFill, GetSysColorBrush(COLOR_BTNFACE));
    607732
    608733    /* separator */
     
    615740        if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) {
    616741            if (btnPtr->fsStyle & TBSTYLE_DROPDOWN)
    617                 TOOLBAR_DrawDDFlatSeparator (&rc, hdc, btnPtr);
     742                TOOLBAR_DrawDDFlatSeparator (&rc, hdc, btnPtr, infoPtr);
    618743            else
    619                 TOOLBAR_DrawFlatSeparator (&rc, hdc);
    620         }
    621         return;
     744                TOOLBAR_DrawFlatSeparator (&rc, hdc, infoPtr);
     745        }
     746        else if (btnPtr->fsStyle != TBSTYLE_SEP) {
     747            FIXME("Draw some kind of separator: fsStyle=%x\n",
     748                  btnPtr->fsStyle);
     749        }
     750        goto FINALNOTIFY;
    622751    }
    623752
    624753    /* disabled */
    625754    if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
    626         if (!(dwStyle & TBSTYLE_FLAT))
     755        if (!(dwStyle & TBSTYLE_FLAT) && !(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
    627756        {
    628757            DrawEdge (hdc, &rc, EDGE_RAISED,
     
    644773            TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
    645774
    646         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    647         return;
     775        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
     776        goto FINALNOTIFY;
    648777    }
    649778
    650779    /* pressed TBSTYLE_BUTTON */
    651780    if (btnPtr->fsState & TBSTATE_PRESSED) {
    652         if (dwStyle & TBSTYLE_FLAT)
     781        offset = (infoPtr->dwItemCDFlag & TBCDRF_NOOFFSET) ? 0 : 1;
     782        if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
    653783        {
    654             DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
    655             if (hasDropDownArrow)
    656             DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
    657         }
    658         else
    659         {
    660             DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
    661             if (hasDropDownArrow)
    662             DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
     784            if (dwStyle & TBSTYLE_FLAT)
     785            {
     786                DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
     787                if (hasDropDownArrow)
     788                    DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
     789            }
     790            else
     791            {
     792                DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
     793                if (hasDropDownArrow)
     794                    DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
     795            }
    663796        }
    664797
     
    667800
    668801        TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
    669                                hdc, rcBitmap.left+1, rcBitmap.top+1,
     802                               hdc, rcBitmap.left+offset, rcBitmap.top+offset,
    670803                               ILD_NORMAL);
    671804
    672         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    673         return;
     805        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
     806        goto FINALNOTIFY;
    674807    }
    675808
     
    677810    if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
    678811        (btnPtr->fsState & TBSTATE_CHECKED)) {
    679         if (dwStyle & TBSTYLE_FLAT)
    680             DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
    681                         BF_RECT | BF_ADJUST);
    682         else
    683             DrawEdge (hdc, &rc, EDGE_SUNKEN,
    684                         BF_RECT | BF_MIDDLE | BF_ADJUST);
     812        if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
     813        {
     814            if (dwStyle & TBSTYLE_FLAT)
     815                DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
     816                          BF_RECT | BF_ADJUST);
     817            else
     818                DrawEdge (hdc, &rc, EDGE_SUNKEN,
     819                          BF_RECT | BF_MIDDLE | BF_ADJUST);
     820        }
    685821
    686822        TOOLBAR_DrawPattern (hdc, &rc);
     
    690826                               ILD_NORMAL);
    691827
    692         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    693         return;
     828        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
     829        goto FINALNOTIFY;
    694830    }
    695831
    696832    /* indeterminate */
    697833    if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
    698         DrawEdge (hdc, &rc, EDGE_RAISED,
    699                     BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     834        if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
     835            DrawEdge (hdc, &rc, EDGE_RAISED,
     836                      BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    700837
    701838        TOOLBAR_DrawPattern (hdc, &rc);
    702839        TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
    703         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    704         return;
     840        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
     841        goto FINALNOTIFY;
    705842    }
    706843
     
    710847        if (btnPtr->bHot)
    711848        {
    712             DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT);
    713             if (hasDropDownArrow)
    714             DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT);
     849            if ( infoPtr->dwItemCDFlag & TBCDRF_HILITEHOTTRACK )
     850            {
     851                COLORREF oldclr;
     852
     853                oldclr = SetBkColor(hdc, tbcd.clrHighlightHotTrack);
     854                ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, 0);
     855                if (hasDropDownArrow)
     856                    ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rcArrow, NULL, 0, 0);
     857                SetBkColor(hdc, oldclr);
     858            }
     859            else
     860            {
     861                if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
     862                {
     863                    DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT);
     864                    if (hasDropDownArrow)
     865                        DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT);
     866                }
     867            }
    715868        }
    716869#if 1
     
    746899    else
    747900    {
    748         DrawEdge (hdc, &rc, EDGE_RAISED,
    749                 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     901        if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
     902            DrawEdge (hdc, &rc, EDGE_RAISED,
     903                      BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    750904
    751905        if (hasDropDownArrow)
    752906        {
    753             DrawEdge (hdc, &rcArrow, EDGE_RAISED,
    754                     BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     907            if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
     908                DrawEdge (hdc, &rcArrow, EDGE_RAISED,
     909                          BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    755910            TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
    756911        }
     
    758913        TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
    759914                               hdc, rcBitmap.left, rcBitmap.top,
    760                                ILD_NORMAL);
    761     }
    762 
    763     TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
     915                               ILD_NORMAL);}
     916   
     917
     918    TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
     919
     920 FINALNOTIFY:
     921    if (infoPtr->dwItemCustDraw & CDRF_NOTIFYPOSTPAINT)
     922    {
     923        tbcd.nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT;
     924        tbcd.nmcd.hdc = hdc;
     925        tbcd.nmcd.rc = rc;
     926        tbcd.nmcd.dwItemSpec = btnPtr->idCommand;
     927        tbcd.nmcd.uItemState = TOOLBAR_TranslateState(btnPtr);
     928        tbcd.nmcd.lItemlParam = btnPtr->dwData;
     929        tbcd.rcText = rcText;
     930        tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
     931        tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
     932        ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
     933    }
     934
    764935}
    765936
     
    772943    INT i, oldBKmode = 0;
    773944    RECT rcTemp;
     945    NMTBCUSTOMDRAW tbcd;
     946    DWORD ntfret;
    774947
    775948    /* if imagelist belongs to the app, it can be changed
     
    779952
    780953    TOOLBAR_DumpToolbar (infoPtr, __LINE__);
     954
     955    /* Send initial notify */
     956    ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
     957    tbcd.nmcd.dwDrawStage = CDDS_PREPAINT;
     958    tbcd.nmcd.hdc = hdc;
     959    tbcd.nmcd.rc = ps->rcPaint;
     960    ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
     961    infoPtr->dwBaseCustDraw = ntfret & 0xffff;
    781962
    782963    if (infoPtr->bBtnTranspnt)
     
    793974    if (infoPtr->bBtnTranspnt && (oldBKmode != TRANSPARENT))
    794975        SetBkMode (hdc, oldBKmode);
     976
     977    if (infoPtr->dwBaseCustDraw & CDRF_NOTIFYPOSTPAINT)
     978    {
     979        ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
     980        tbcd.nmcd.dwDrawStage = CDDS_POSTPAINT;
     981        tbcd.nmcd.hdc = hdc;
     982        tbcd.nmcd.rc = ps->rcPaint;
     983        ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
     984    }
    795985}
    796986
     
    8201010        LPWSTR lpText = TOOLBAR_GetText(infoPtr, btnPtr);
    8211011
    822         /* first get size of all the text */
    823         GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize);
    824 
    825         /* feed above size into the rectangle for DrawText */
    826         myrect.left = myrect.top = 0;
    827         myrect.right = lpSize->cx;
    828         myrect.bottom = lpSize->cy;
    829 
    830         /* Use DrawText to get true size as drawn (less pesky "&") */
    831         DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE |
    832                    DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ?
     1012        if(lpText != NULL) {
     1013            /* first get size of all the text */
     1014            GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize);
     1015
     1016            /* feed above size into the rectangle for DrawText */
     1017            myrect.left = myrect.top = 0;
     1018            myrect.right = lpSize->cx;
     1019            myrect.bottom = lpSize->cy;
     1020
     1021            /* Use DrawText to get true size as drawn (less pesky "&") */
     1022            DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE |
     1023                   DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ?
    8331024                                  DT_NOPREFIX : 0));
    8341025
    835         /* feed back to caller  */
    836         lpSize->cx = myrect.right;
    837         lpSize->cy = myrect.bottom;
     1026            /* feed back to caller  */
     1027            lpSize->cx = myrect.right;
     1028            lpSize->cy = myrect.bottom;
     1029        }
    8381030    }
    8391031
     
    8911083* the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
    8921084* flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
     1085*
     1086* Note: TBSTYLE_WRAPABLE or TBSTYLE_EX_UNDOC1 can be used also to allow
     1087* vertical toolbar lists.
    8931088*/
    8941089
     
    9051100    /*  no layout is necessary. Applications may use this style */
    9061101    /*  to perform their own layout on the toolbar.             */
    907     if( !(dwStyle & TBSTYLE_WRAPABLE) )
    908         return;
     1102    if( !(dwStyle & TBSTYLE_WRAPABLE) &&
     1103        !(infoPtr->dwExStyle & TBSTYLE_EX_UNDOC1) )  return;
    9091104
    9101105    btnPtr = infoPtr->buttons;
     
    9721167            /*  go to the next until it reaches a non separator.      */
    9731168            /*  Wrap the last separator if it is before a button.     */
    974             while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
    975                         (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
     1169            while( ( ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
     1170                      !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN)) ||
     1171                     (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
    9761172                        i < infoPtr->nNumButtons )
    9771173            {
     
    10811277    TOOLBAR_CalcStrings (hwnd, &sizeString);
    10821278
     1279    for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
     1280    {
     1281        if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap))
     1282            usesBitmaps = TRUE;
     1283    }
    10831284    if (dwStyle & TBSTYLE_LIST)
    10841285    {
    1085         for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
    1086         {
    1087             if (infoPtr->buttons[i].iBitmap >= 0)
    1088                 usesBitmaps = TRUE;
    1089         }
    10901286        infoPtr->nButtonHeight = max((usesBitmaps) ? infoPtr->nBitmapHeight :
    1091                                      0, sizeString.cy) + 6;
     1287                                     0, sizeString.cy) + infoPtr->szPadding.cy;
    10921288        infoPtr->nButtonWidth = ((usesBitmaps) ? infoPtr->nBitmapWidth :
    10931289                                 0) + sizeString.cx + 6;
     
    10981294    }
    10991295    else {
    1100         for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
    1101         {
    1102             if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap))
    1103                 usesBitmaps = TRUE;
    1104         }
    1105 
    11061296        if (sizeString.cy > 0)
    11071297        {
     
    12521442        btnPtr->nRow = nRows + nSepRows;
    12531443
    1254         TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d\n",
    1255               i, btnPtr->fsStyle, bWrap, nRows, nSepRows, btnPtr->nRow);
     1444        TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d, (%d,%d)-(%d,%d)\n",
     1445              i, btnPtr->fsStyle, bWrap, nRows, nSepRows, btnPtr->nRow,
     1446              x, y, x+cx, y+cy);
    12561447
    12571448        if( bWrap )
     
    12751466            }
    12761467            x = infoPtr->nIndent;
     1468
     1469            /* Increment row number unless this is the last button    */
     1470            /* and it has Wrap set.                                   */
     1471            if (i != infoPtr->nNumButtons-1)
    12771472                nRows++;
    12781473        }
     
    12831478    /* infoPtr->nRows is the number of rows on the toolbar */
    12841479    infoPtr->nRows = nRows + nSepRows + 1;
     1480
     1481#if 0
     1482    /********************************************************************
     1483     * The following while interesting, does not match the values       *
     1484     * created above for the button rectangles, nor the rcBound rect.   *
     1485     * We will comment it out and remove it later.                      *
     1486     *                                                                  *
     1487     * The problem showed up as heights in the pager control that was   *
     1488     * wrong.                                                           *
     1489     ********************************************************************/
    12851490
    12861491    /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following   */
     
    12901495                        nSepRows * (infoPtr->nBitmapHeight + 1) +
    12911496                        BOTTOM_BORDER;
     1497#endif
     1498
     1499    infoPtr->nHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
     1500
    12921501    TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth);
    12931502}
     
    13331542    if (CommandIsIndex) {
    13341543        TRACE("command is really index command=%d\n", idCommand);
     1544        if (idCommand >= infoPtr->nNumButtons) return -1;
    13351545        return idCommand;
    13361546    }
     
    17912001
    17922002                /* set colors and select objects */
    1793                 oldBk = SetBkColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
     2003                oldBk = SetBkColor (lpdis->hDC, (lpdis->itemState & ODS_FOCUS)?comctl32_color.clrHighlight:comctl32_color.clrWindow);
    17942004                if (btnInfo->bVirtual)
    1795                    oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_GRAYTEXT));
     2005                   oldText = SetTextColor (lpdis->hDC, comctl32_color.clrGrayText);
    17962006                else
    1797                    oldText = SetTextColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHTTEXT:COLOR_WINDOWTEXT));
     2007                   oldText = SetTextColor (lpdis->hDC, (lpdis->itemState & ODS_FOCUS)?comctl32_color.clrHighlightText:comctl32_color.clrWindowText);
    17982008                hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
    17992009                hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
     
    20002210    }
    20012211
     2212    TRACE("Number of bitmap infos: %d\n", infoPtr->nNumBitmapInfos);
     2213
     2214    if (infoPtr->nNumBitmapInfos == 0)
     2215    {
     2216        infoPtr->bitmaps = COMCTL32_Alloc(sizeof(TBITMAP_INFO));
     2217    }
     2218    else
     2219    {
     2220        TBITMAP_INFO *oldBitmaps = infoPtr->bitmaps;
     2221        infoPtr->bitmaps = COMCTL32_Alloc((infoPtr->nNumBitmapInfos + 1) * sizeof(TBITMAP_INFO));
     2222        memcpy(&infoPtr->bitmaps[0], &oldBitmaps[0], infoPtr->nNumBitmapInfos);
     2223    }
     2224
     2225    infoPtr->bitmaps[infoPtr->nNumBitmapInfos].nButtons = nButtons;
     2226    infoPtr->bitmaps[infoPtr->nNumBitmapInfos].hInst = lpAddBmp->hInst;
     2227    infoPtr->bitmaps[infoPtr->nNumBitmapInfos].nID = lpAddBmp->nID;
     2228
     2229    infoPtr->nNumBitmapInfos++;
     2230    TRACE("Number of bitmap infos: %d\n", infoPtr->nNumBitmapInfos);
     2231
    20022232    if (nIndex != -1)
    20032233    {
     
    28243054
    28253055
    2826 /* << TOOLBAR_GetColorScheme >> */
    2827 
    2828 
    28293056static LRESULT
    28303057TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    29323159
    29333160/* << TOOLBAR_GetObject >> */
    2934 /* << TOOLBAR_GetPadding >> */
     3161
     3162
     3163static LRESULT
     3164TOOLBAR_GetPadding (HWND hwnd)
     3165{
     3166    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     3167    DWORD oldPad;
     3168
     3169    oldPad = MAKELONG(infoPtr->szPadding.cx, infoPtr->szPadding.cy);
     3170    return (LRESULT) oldPad;
     3171}
    29353172
    29363173
     
    32153452    TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE);
    32163453
    3217     if (nIndex < 0)
    3218         return FALSE;
    3219 
    3220     TRACE("inserting button index=%d\n", nIndex);
    3221     if (nIndex > infoPtr->nNumButtons) {
     3454    if (nIndex == -1) {
     3455       /* EPP: this seems to be an undocumented call (from my IE4)
     3456        * I assume in that case that:
     3457        * - lpTbb->iString is a string pointer (not a string index in strings[] table
     3458        * - index of insertion is at the end of existing buttons
     3459        * I only see this happen with nIndex == -1, but it could have a special
     3460        * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
     3461        */
    32223462        nIndex = infoPtr->nNumButtons;
    3223         TRACE("adjust index=%d\n", nIndex);
    3224     }
    3225 
    3226     oldButtons = infoPtr->buttons;
    3227     infoPtr->nNumButtons++;
    3228     infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
    3229     /* pre insert copy */
    3230     if (nIndex > 0) {
    3231         memcpy (&infoPtr->buttons[0], &oldButtons[0],
    3232                 nIndex * sizeof(TBUTTON_INFO));
    3233     }
    3234 
     3463
     3464    } else if (nIndex < 0)
     3465       return FALSE;
    32353466
    32363467    /* If the string passed is not an index, assume address of string
     
    32483479        lpTbb->iString = TOOLBAR_AddStringW(hwnd, 0, (LPARAM)ptr);
    32493480        COMCTL32_Free(ptr);
     3481    }
     3482
     3483    TRACE("inserting button index=%d\n", nIndex);
     3484    if (nIndex > infoPtr->nNumButtons) {
     3485        nIndex = infoPtr->nNumButtons;
     3486        TRACE("adjust index=%d\n", nIndex);
     3487    }
     3488
     3489    oldButtons = infoPtr->buttons;
     3490    infoPtr->nNumButtons++;
     3491    infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
     3492    /* pre insert copy */
     3493    if (nIndex > 0) {
     3494        memcpy (&infoPtr->buttons[0], &oldButtons[0],
     3495                nIndex * sizeof(TBUTTON_INFO));
    32503496    }
    32513497
     
    32853531    COMCTL32_Free (oldButtons);
    32863532
     3533    TOOLBAR_CalcToolbar (hwnd);
     3534
    32873535    InvalidateRect (hwnd, NULL, TRUE);
    32883536
     
    34073655
    34083656
    3409 /* << TOOLBAR_ReplaceBitmap >> */
    3410 
     3657static LRESULT
     3658TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
     3659{
     3660    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     3661    LPTBREPLACEBITMAP lpReplace = (LPTBREPLACEBITMAP) lParam;
     3662    HBITMAP hBitmap;
     3663    int i = 0, nOldButtons = 0, pos = 0;
     3664
     3665    TRACE("hInstOld %x nIDOld %x hInstNew %x nIDNew %x nButtons %x\n",
     3666          lpReplace->hInstOld, lpReplace->nIDOld, lpReplace->hInstNew, lpReplace->nIDNew,
     3667          lpReplace->nButtons);
     3668
     3669    if (lpReplace->hInstOld == -1)
     3670    {
     3671        FIXME("changing standard bitmaps not implemented\n");
     3672        return FALSE;
     3673    }
     3674    else if (lpReplace->hInstOld != 0)
     3675    {
     3676        FIXME("resources not in the current module not implemented\n");
     3677        return FALSE;
     3678    }
     3679    else
     3680    {
     3681        hBitmap = (HBITMAP) lpReplace->nIDNew;
     3682    }
     3683
     3684    TRACE("To be replaced hInstOld %x nIDOld %x\n", lpReplace->hInstOld, lpReplace->nIDOld);
     3685    for (i = 0; i < infoPtr->nNumBitmapInfos; i++) {
     3686        TBITMAP_INFO *tbi = &infoPtr->bitmaps[i];
     3687        TRACE("tbimapinfo %d hInstOld %x nIDOld %x\n", i, tbi->hInst, tbi->nID);
     3688        if (tbi->hInst == lpReplace->hInstOld && tbi->nID == lpReplace->nIDOld)
     3689        {
     3690            TRACE("Found: nButtons %d hInst %x nID %x\n", tbi->nButtons, tbi->hInst, tbi->nID);
     3691            nOldButtons = tbi->nButtons;
     3692            tbi->nButtons = lpReplace->nButtons;
     3693            tbi->hInst = lpReplace->hInstNew;
     3694            tbi->nID = lpReplace->nIDNew;
     3695            TRACE("tbimapinfo changed %d hInstOld %x nIDOld %x\n", i, tbi->hInst, tbi->nID);
     3696            break;
     3697        }
     3698        pos += tbi->nButtons;
     3699    }
     3700
     3701    if (nOldButtons == 0)
     3702    {
     3703        WARN("No hinst/bitmap found! hInst %x nID %x\n", lpReplace->hInstOld, lpReplace->nIDOld);
     3704        return FALSE;
     3705    }
     3706
     3707    infoPtr->nNumBitmaps = infoPtr->nNumBitmaps - nOldButtons + lpReplace->nButtons;
     3708
     3709    /* ImageList_Replace(infoPtr->himlDef, pos, hBitmap, NULL); */
     3710
     3711
     3712    for (i = pos + nOldButtons - 1; i >= pos; i--) {
     3713        ImageList_Remove(infoPtr->himlDef, i);
     3714    }
     3715
     3716    ImageList_AddMasked(infoPtr->himlDef, hBitmap, CLR_DEFAULT);
     3717
     3718    InvalidateRect(hwnd, NULL, FALSE);
     3719
     3720    return TRUE;
     3721}
    34113722
    34123723static LRESULT
     
    35993910{
    36003911    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    3601 
    3602     if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
     3912    INT cx = LOWORD(lParam), cy = HIWORD(lParam);
     3913
     3914    if ((cx < 0) || (cy < 0))
    36033915    {
    3604         ERR("invalid parameter\n");
     3916        ERR("invalid parameter 0x%08lx\n", (DWORD)lParam);
    36053917        return FALSE;
    36063918    }
     
    36123924     * Further testing shows that we must actually perform the change too.
    36133925     */
    3614     infoPtr->nButtonWidth = (INT)LOWORD(lParam);
    3615     infoPtr->nButtonHeight = (INT)HIWORD(lParam);
     3926    /*
     3927     * The documentation also does not mention that if 0 is supplied for
     3928     * either size, the system changes it to the default of 24 wide and
     3929     * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02
     3930     */
     3931    infoPtr->nButtonWidth = (cx) ? cx : 24;
     3932    infoPtr->nButtonHeight = (cy) ? cy : 22;
    36163933    return TRUE;
    36173934}
     
    36813998
    36823999
    3683 /* << TOOLBAR_SetColorScheme >> */
    3684 
    3685 
    36864000static LRESULT
    36874001TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    37184032}
    37194033
    3720 
    37214034static LRESULT
    37224035TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    37274040    dwTemp = infoPtr->dwExStyle;
    37284041    infoPtr->dwExStyle = (DWORD)lParam;
     4042
     4043    if (infoPtr->dwExStyle & (TBSTYLE_EX_MIXEDBUTTONS |
     4044                              TBSTYLE_EX_HIDECLIPPEDBUTTONS)) {
     4045        FIXME("Extended style not implemented %s %s\n",
     4046              (infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) ?
     4047              "TBSTYLE_EX_MIXEDBUTTONS" : "",
     4048              (infoPtr->dwExStyle & TBSTYLE_EX_HIDECLIPPEDBUTTONS) ?
     4049              "TBSTYLE_EX_HIDECLIPPEDBUTTONS" : "");
     4050    }
     4051
     4052    if (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL)
     4053        FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
     4054              (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL));
    37294055
    37304056    return (LRESULT)dwTemp;
     
    38694195
    38704196
    3871 /* << TOOLBAR_SetPadding >> */
     4197static LRESULT
     4198TOOLBAR_SetPadding (HWND hwnd, WPARAM wParam, LPARAM lParam)
     4199{
     4200    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     4201    DWORD  oldPad;
     4202
     4203    oldPad = MAKELONG(infoPtr->szPadding.cx, infoPtr->szPadding.cy);
     4204    infoPtr->szPadding.cx = LOWORD((DWORD)lParam);
     4205    infoPtr->szPadding.cy = HIWORD((DWORD)lParam);
     4206    FIXME("stub - nothing done with values, cx=%ld, cy=%ld\n",
     4207          infoPtr->szPadding.cx, infoPtr->szPadding.cy);
     4208    return (LRESULT) oldPad;
     4209}
    38724210
    38734211
     
    40154353
    40164354static LRESULT
     4355TOOLBAR_GetColorScheme (HWND hwnd, LPCOLORSCHEME lParam)
     4356{
     4357    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     4358
     4359    lParam->clrBtnHighlight = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
     4360                               comctl32_color.clrBtnHighlight :
     4361                               infoPtr->clrBtnHighlight;
     4362    lParam->clrBtnShadow = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
     4363                           comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
     4364    return 1;
     4365}
     4366
     4367
     4368static LRESULT
     4369TOOLBAR_SetColorScheme (HWND hwnd, LPCOLORSCHEME lParam)
     4370{
     4371    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     4372
     4373    TRACE("new colors Hl=%lx Shd=%lx, old colors Hl=%lx Shd=%lx\n",
     4374          lParam->clrBtnHighlight, lParam->clrBtnShadow,
     4375          infoPtr->clrBtnHighlight, infoPtr->clrBtnShadow);
     4376
     4377    infoPtr->clrBtnHighlight = lParam->clrBtnHighlight;
     4378    infoPtr->clrBtnShadow = lParam->clrBtnShadow;
     4379    InvalidateRect(hwnd, 0, 0);
     4380    return 0;
     4381}
     4382
     4383
     4384static LRESULT
    40174385TOOLBAR_SetVersion (HWND hwnd, INT iVersion)
    40184386{
     
    40234391
    40244392    return iOldVersion;
     4393}
     4394
     4395
     4396/*********************************************************************/
     4397/*                                                                   */
     4398/* This is undocumented and appears to be a "Super" TB_SETHOTITEM    */
     4399/* without the restriction of TBSTYLE_FLAT. This implementation is   */
     4400/* based on relay traces of the native control and IE 5.5            */
     4401/*                                                                   */
     4402/*********************************************************************/
     4403static LRESULT
     4404TOOLBAR_Unkwn45E (HWND hwnd, WPARAM wParam, LPARAM lParam)
     4405{
     4406    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
     4407    INT nOldHotItem = infoPtr->nHotItem;
     4408    TBUTTON_INFO *btnPtr;
     4409    INT no_hi = 0;
     4410    NMTBHOTITEM nmhotitem;
     4411
     4412    if ((INT) wParam < 0 || (INT)wParam > infoPtr->nNumButtons)
     4413        wParam = -2;
     4414
     4415    infoPtr->nHotItem = (INT)wParam;
     4416    if (nOldHotItem != infoPtr->nHotItem) {
     4417        nmhotitem.dwFlags = (DWORD)lParam;
     4418        if ( !(nmhotitem.dwFlags & HICF_ENTERING) )
     4419            nmhotitem.idOld = (nOldHotItem >= 0) ?
     4420                infoPtr->buttons[nOldHotItem].idCommand : 0;
     4421        if ( !(nmhotitem.dwFlags & HICF_LEAVING) )
     4422            nmhotitem.idNew = (infoPtr->nHotItem >= 0) ?
     4423                infoPtr->buttons[infoPtr->nHotItem].idCommand : 0;
     4424        no_hi = TOOLBAR_SendNotify((NMHDR*)&nmhotitem, infoPtr, TBN_HOTITEMCHANGE);
     4425    }
     4426    if ((INT)wParam >=0) {
     4427        btnPtr = &infoPtr->buttons[(INT)wParam];
     4428        btnPtr->bHot = (no_hi) ? FALSE : TRUE;
     4429        InvalidateRect (hwnd, &btnPtr->rect,
     4430                        TOOLBAR_HasText(infoPtr, btnPtr));
     4431    }
     4432    if (nOldHotItem>=0) {
     4433        btnPtr = &infoPtr->buttons[nOldHotItem];
     4434        btnPtr->bHot = FALSE;
     4435        InvalidateRect (hwnd, &btnPtr->rect,
     4436                        TOOLBAR_HasText(infoPtr, btnPtr));
     4437    }
     4438    GetFocus();
     4439    TRACE("old item=%d, new item=%d, flags=%08lx, notify=%d\n",
     4440          nOldHotItem, infoPtr->nHotItem, (DWORD)lParam, no_hi);
     4441
     4442    if (nOldHotItem < 0)
     4443        return -1;
     4444
     4445    return (LRESULT)nOldHotItem;
     4446}
     4447
     4448
     4449static LRESULT
     4450TOOLBAR_Unkwn463 (HWND hwnd, WPARAM wParam, LPARAM lParam)
     4451{
     4452    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     4453    LPSIZE lpsize = (LPSIZE)lParam;
     4454
     4455    if (lpsize == NULL)
     4456        return FALSE;
     4457
     4458    /*
     4459     * Testing shows the following:
     4460     *   wParam    = 0 adjust cx value
     4461     *             = 1 set cy value to max size.
     4462     *   lParam    pointer to SIZE structure
     4463     *
     4464     */
     4465    TRACE("[0463] wParam %d, lParam 0x%08lx -> 0x%08lx 0x%08lx\n",
     4466          wParam, lParam, lpsize->cx, lpsize->cy);
     4467
     4468    switch(wParam) {
     4469    case 0:
     4470        if (lpsize->cx == -1) {
     4471            /* **** this is wrong, native measures each button and sets it */
     4472            lpsize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
     4473        }
     4474        else if(HIWORD(lpsize->cx)) {
     4475            RECT rc;
     4476            HWND hwndParent = GetParent(hwnd);
     4477
     4478            InvalidateRect(hwnd, 0, 1);
     4479            GetWindowRect(hwnd, &rc);
     4480            MapWindowPoints(0, hwndParent, (LPPOINT)&rc, 2);
     4481            TRACE("mapped to (%d,%d)-(%d,%d)\n",
     4482                rc.left, rc.top, rc.right, rc.bottom);
     4483            lpsize->cx = max(rc.right-rc.left,
     4484                             infoPtr->rcBound.right - infoPtr->rcBound.left);
     4485        }
     4486        else {
     4487            lpsize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
     4488        }
     4489        break;
     4490    case 1:
     4491        lpsize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
     4492        /* lpsize->cy = infoPtr->nHeight; */
     4493        break;
     4494    default:
     4495        ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n",
     4496            wParam);
     4497        return 0;
     4498    }
     4499    TRACE("[0463] set to -> 0x%08lx 0x%08lx\n",
     4500          lpsize->cx, lpsize->cy);
     4501    return 1;
    40254502}
    40264503
     
    40584535    infoPtr->bAnchor = FALSE; /* no anchor highlighting */
    40594536    infoPtr->iVersion = 0;
    4060     infoPtr->bNtfUnicode = FALSE;
    40614537    infoPtr->hwndSelf = hwnd;
    40624538    infoPtr->bDoRedraw = TRUE;
     4539    infoPtr->clrBtnHighlight = CLR_DEFAULT;
     4540    infoPtr->clrBtnShadow = CLR_DEFAULT;
     4541    infoPtr->szPadding.cx = 7;
     4542    infoPtr->szPadding.cy = 6;
     4543    TOOLBAR_NotifyFormat(infoPtr, (WPARAM)hwnd, (LPARAM)NF_REQUERY);
    40634544
    40644545    SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
     
    41374618    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    41384619    NMTBCUSTOMDRAW tbcd;
    4139     INT ret = FALSE, ntfret;
     4620    INT ret = FALSE;
     4621    DWORD ntfret;
    41404622
    41414623    if (dwStyle & TBSTYLE_CUSTOMERASE) {
     
    41444626        tbcd.nmcd.hdc = (HDC)wParam;
    41454627        ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
     4628        infoPtr->dwBaseCustDraw = ntfret & 0xffff;
     4629
    41464630        /* FIXME: in general the return flags *can* be or'ed together */
    4147         switch (ntfret)
     4631        switch (infoPtr->dwBaseCustDraw)
    41484632            {
    41494633            case CDRF_DODEFAULT:
     
    41524636                return TRUE;
    41534637            default:
    4154                 FIXME("[%04x] response %d not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
     4638                FIXME("[%04x] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
    41554639                      hwnd, ntfret);
    41564640            }
     
    41764660        ret = DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
    41774661
    4178     if (dwStyle & TBSTYLE_CUSTOMERASE) {
     4662    if ((dwStyle & TBSTYLE_CUSTOMERASE) &&
     4663        (infoPtr->dwBaseCustDraw & CDRF_NOTIFYPOSTERASE)) {
    41794664        ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
    41804665        tbcd.nmcd.dwDrawStage = CDDS_POSTERASE;
    41814666        tbcd.nmcd.hdc = (HDC)wParam;
    41824667        ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
    4183         switch (ntfret)
     4668        infoPtr->dwBaseCustDraw = ntfret & 0xffff;
     4669        switch (infoPtr->dwBaseCustDraw)
    41844670            {
    41854671            case CDRF_DODEFAULT:
     
    41884674                return TRUE;
    41894675            default:
    4190                 FIXME("[%04x] response %d not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
     4676                FIXME("[%04x] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
    41914677                      hwnd, ntfret);
    41924678            }
     
    43454831        infoPtr->buttons[infoPtr->nHotItem].bHot = TRUE;
    43464832
    4347     if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
    43484833        btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
    43494834        btnPtr->fsState &= ~TBSTATE_PRESSED;
    43504835
    4351         if (nHit == infoPtr->nButtonDown) {
    4352             if (btnPtr->fsStyle & TBSTYLE_CHECK) {
     4836        if (btnPtr->fsStyle & TBSTYLE_CHECK) {
    43534837                if (btnPtr->fsStyle & TBSTYLE_GROUP) {
    43544838                    nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
    4355                         infoPtr->nButtonDown);
    4356                     if (nOldIndex == infoPtr->nButtonDown)
     4839                        nHit);
     4840                    if (nOldIndex == nHit)
    43574841                        bSendMessage = FALSE;
    4358                     if ((nOldIndex != infoPtr->nButtonDown) &&
     4842                    if ((nOldIndex != nHit) &&
    43594843                        (nOldIndex != -1))
    43604844                        infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
     
    43674851                        btnPtr->fsState |= TBSTATE_CHECKED;
    43684852                }
    4369             }
    4370         }
    4371         else
    4372             bSendMessage = FALSE;
     4853        }
    43734854
    43744855        if (nOldIndex != -1)
     
    43834864         * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
    43844865         */
    4385         ReleaseCapture ();
     4866        if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0))
     4867            ReleaseCapture ();
    43864868
    43874869        /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
     
    44044886                        TBN_ENDDRAG);
    44054887
    4406         if (bSendMessage)
    4407             SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
    4408                           MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
     4888        SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
     4889          MAKEWPARAM(infoPtr->buttons[nHit].idCommand, 0), (LPARAM)hwnd);
    44094890
    44104891        /* !!! Undocumented - toolbar at 4.71 level and above sends
     
    44164897        TOOLBAR_SendNotify ((NMHDR *) &nmmouse, infoPtr,
    44174898                        NM_CLICK);
    4418     }
    4419 
    44204899    return 0;
    44214900}
     
    44884967TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
    44894968{
    4490     TBUTTON_INFO *btnPtr, *oldBtnPtr;
     4969    TBUTTON_INFO *btnPtr = NULL, *oldBtnPtr = NULL;
    44914970    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    44924971    POINT pt;
    44934972    INT   nHit;
    44944973    TRACKMOUSEEVENT trackinfo;
     4974    NMTBHOTITEM nmhotitem;
    44954975
    44964976    /* fill in the TRACKMOUSEEVENT struct */
     
    45305010            oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
    45315011            oldBtnPtr->bHot = FALSE;
    4532                    
    4533             InvalidateRect (hwnd, &oldBtnPtr->rect,
    4534                 TOOLBAR_HasText(infoPtr, oldBtnPtr));
    4535         }
     5012        }
    45365013
    45375014        /* It's not a separator or in nowhere. It's a hot button. */
     
    45465023            {
    45475024                btnPtr->bHot = TRUE;
    4548                 InvalidateRect(hwnd, &btnPtr->rect,
    4549                     TOOLBAR_HasText(infoPtr, btnPtr));
    45505025            }
    4551 
    4552         }
    4553 
    4554     if (infoPtr->bCaptured) {
     5026        }
     5027
     5028        nmhotitem.dwFlags = HICF_MOUSE;
     5029        if (oldBtnPtr)
     5030            nmhotitem.idOld = oldBtnPtr->idCommand;
     5031        else
     5032            nmhotitem.dwFlags |= HICF_ENTERING;
     5033        if (btnPtr)
     5034            nmhotitem.idNew = btnPtr->idCommand;
     5035        else
     5036            nmhotitem.dwFlags |= HICF_LEAVING;
     5037        TOOLBAR_SendNotify((NMHDR*)&nmhotitem, infoPtr, TBN_HOTITEMCHANGE);
     5038
     5039        /* now invalidate the old and new buttons so they will be painted */
     5040        if (oldBtnPtr)
     5041            InvalidateRect (hwnd, &oldBtnPtr->rect,
     5042                            TOOLBAR_HasText(infoPtr, oldBtnPtr));
     5043        if (btnPtr && (btnPtr->fsState & TBSTATE_ENABLED))
     5044            InvalidateRect(hwnd, &btnPtr->rect,
     5045                           TOOLBAR_HasText(infoPtr, btnPtr));
     5046
     5047        if (infoPtr->bCaptured) {
    45555048            btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
    45565049            if (infoPtr->nOldHit == infoPtr->nButtonDown) {
     
    47055198
    47065199        if (lppgc->dwFlag == PGF_CALCWIDTH) {
    4707             lppgc->iWidth = infoPtr->nWidth;
     5200            lppgc->iWidth = infoPtr->rcBound.right - infoPtr->rcBound.left;
    47085201            TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
    4709                   infoPtr->nWidth);
     5202                  lppgc->iWidth);
    47105203        }
    47115204        else {
    4712             lppgc->iHeight = infoPtr->nHeight;
     5205            lppgc->iHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
    47135206            TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
    4714                   infoPtr->nHeight);
     5207                  lppgc->iHeight);
    47155208        }
    47165209        return 0;
     
    47215214
    47225215    if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
    4723         SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,   wParam, lParam);
     5216        if (infoPtr->bNtfUnicode)
     5217            return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
     5218                                 wParam, lParam);
     5219        else
     5220            return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
     5221                                 wParam, lParam);
    47245222
    47255223#if 0
     
    47405238
    47415239    return 0;
     5240}
     5241
     5242
     5243static LRESULT
     5244TOOLBAR_NotifyFormatFake(HWND hwnd, WPARAM wParam, LPARAM lParam)
     5245{
     5246    /* remove this routine when Toolbar is improved to pass infoPtr
     5247     * around instead of hwnd.
     5248     */
     5249    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
     5250    return TOOLBAR_NotifyFormat(infoPtr, wParam, lParam);
     5251}
     5252
     5253
     5254static LRESULT
     5255TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     5256{
     5257    INT i;
     5258
     5259    if (lParam == NF_REQUERY) {
     5260        i = SendMessageA(GetParent(infoPtr->hwndSelf),
     5261                         WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
     5262        if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
     5263            ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     5264                i);
     5265            i = NFR_ANSI;
     5266        }
     5267        infoPtr->bNtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
     5268        return (LRESULT)i;
     5269    }
     5270    return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
    47425271}
    47435272
     
    49085437
    49095438
     5439static LRESULT
     5440TOOLBAR_SysColorChange (HWND hwnd)
     5441{
     5442    COMCTL32_RefreshSysColors();
     5443
     5444    return 0;
     5445}
     5446
     5447
    49105448
    49115449static LRESULT WINAPI
     
    49895527            return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
    49905528
    4991 /*      case TB_GETCOLORSCHEME:                 */ /* 4.71 */
    4992 
    49935529        case TB_GETDISABLEDIMAGELIST:
    49945530            return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
     
    50165552
    50175553/*      case TB_GETOBJECT:                      */ /* 4.71 */
    5018 /*      case TB_GETPADDING:                     */ /* 4.71 */
     5554
     5555        case TB_GETPADDING:
     5556            return TOOLBAR_GetPadding (hwnd);
    50195557
    50205558        case TB_GETRECT:
     
    50385576        case TB_GETUNICODEFORMAT:
    50395577            return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
    5040 
    5041         case CCM_GETVERSION:
    5042             return TOOLBAR_GetVersion (hwnd);
    50435578
    50445579        case TB_HIDEBUTTON:
     
    50895624            return TOOLBAR_PressButton (hwnd, wParam, lParam);
    50905625
    5091 /*      case TB_REPLACEBITMAP: */
     5626        case TB_REPLACEBITMAP:
     5627            return TOOLBAR_ReplaceBitmap (hwnd, wParam, lParam);
    50925628
    50935629        case TB_SAVERESTOREA:
     
    51185654            return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
    51195655
    5120 /*      case TB_SETCOLORSCHEME:                 */ /* 4.71 */
    5121 
    51225656        case TB_SETDISABLEDIMAGELIST:
    51235657            return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
     
    51495683            return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
    51505684
    5151 /*      case TB_SETPADDING:                     */ /* 4.71 */
     5685        case TB_SETPADDING:
     5686            return TOOLBAR_SetPadding (hwnd, wParam, lParam);
    51525687
    51535688        case TB_SETPARENT:
     
    51695704            return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
    51705705
     5706        case TB_UNKWN45E:
     5707            return TOOLBAR_Unkwn45E (hwnd, wParam, lParam);
     5708
     5709        case TB_UNKWN463:
     5710            return TOOLBAR_Unkwn463 (hwnd, wParam, lParam);
     5711
     5712
     5713/* Common Control Messages */
     5714
     5715/*      case TB_GETCOLORSCHEME:                 */ /* identical to CCM_ */
     5716        case CCM_GETCOLORSCHEME:
     5717            return TOOLBAR_GetColorScheme (hwnd, (LPCOLORSCHEME)lParam);
     5718
     5719/*      case TB_SETCOLORSCHEME:                 */ /* identical to CCM_ */
     5720        case CCM_SETCOLORSCHEME:
     5721            return TOOLBAR_SetColorScheme (hwnd, (LPCOLORSCHEME)lParam);
     5722
     5723        case CCM_GETVERSION:
     5724            return TOOLBAR_GetVersion (hwnd);
     5725
    51715726        case CCM_SETVERSION:
    51725727            return TOOLBAR_SetVersion (hwnd, (INT)wParam);
     
    52235778            return TOOLBAR_Notify (hwnd, wParam, lParam);
    52245779
    5225 /*      case WM_NOTIFYFORMAT: */
     5780        case WM_NOTIFYFORMAT:
     5781            TOOLBAR_NotifyFormatFake (hwnd, wParam, lParam);
    52265782
    52275783        case WM_PAINT:
     
    52375793            return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
    52385794
    5239 /*      case WM_SYSCOLORCHANGE: */
     5795        case WM_SYSCOLORCHANGE:
     5796            return TOOLBAR_SysColorChange (hwnd);
    52405797
    52415798/*      case WM_WININICHANGE: */
     
    52545811            }
    52555812
     5813        /* We see this in Outlook Express 5.x and just does DefWindowProc */
     5814        case PGM_FORWARDMOUSE:
     5815            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     5816
    52565817        default:
    52575818            if (uMsg >= WM_USER)
Note: See TracChangeset for help on using the changeset viewer.