Changeset 10535 for trunk/src


Ignore:
Timestamp:
Mar 17, 2004, 5:38:52 PM (22 years ago)
Author:
sandervl
Message:

Wine merge + status & rebar fixes

Location:
trunk/src/comctl32
Files:
4 edited

Legend:

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

    r10530 r10535  
    89378937#ifdef __WIN32OS2__
    89388938#ifdef DEBUG
    8939 void dprintfMsg(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
     8939static void dprintfMsg(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    89408940{
    89418941 char *msg = NULL;
  • trunk/src/comctl32/rebar.c

    r10139 r10535  
    120120 *    Still to do:
    121121 *  2. Following still not handled: RBBS_FIXEDBMP,
    122  *            RBBS_USECHEVRON, CCS_NORESIZE,
     122 *            CCS_NORESIZE,
    123123 *            CCS_NOMOVEX, CCS_NOMOVEY
    124124 *  3. Following are only partially handled:
     
    137137 *  7. The following notifications are not implemented:
    138138 *        NM_CUSTOMDRAW, NM_RELEASEDCAPTURE
    139  *        RB_CHEVRONPUSHED, RBN_MINMAX
     139 *        RBN_MINMAX
    140140 */
    141141
     142#include <stdarg.h>
    142143#include <stdlib.h>
    143144#include <string.h>
    144145
     146#include "windef.h"
    145147#include "winbase.h"
    146148#include "wingdi.h"
    147149#include "wine/unicode.h"
     150#include "winuser.h"
     151#include "winnls.h"
    148152#include "commctrl.h"
    149 /* #include "spy.h" */
     153#include "comctl32.h"
    150154#include "wine/debug.h"
    151155
     
    191195    RECT    rcCapText;      /* calculated caption text rectangle */
    192196    RECT    rcChild;        /* calculated child rectangle */
     197    RECT    rcChevron;      /* calculated chevron rectangle */
    193198
    194199    LPWSTR    lpText;
     
    207212#define DRAW_RIGHTSEP   0x00000010
    208213#define DRAW_BOTTOMSEP  0x00000020
     214#define DRAW_CHEVRONHOT 0x00000040
     215#define DRAW_CHEVRONPUSHED 0x00000080
     216#define DRAW_LAST_IN_ROW   0x00000100
     217#define DRAW_FIRST_IN_ROW  0x00000200
    209218#define NTF_INVALIDATE  0x01000000
    210 
    211 typedef struct
    212 {
    213     INT      istartband;  /* index of first band in row */
    214     INT      iendband;    /* index of last band in row */
    215 } REBAR_ROW;
    216 
    217219
    218220typedef struct
     
    245247    POINTS   dragStart;   /* x,y of button down */
    246248    POINTS   dragNow;     /* x,y of this MouseMove */
    247     INT      ihitBand;    /* band number of band whose gripper was grabbed */
     249    INT      iOldBand;    /* last band that had the mouse cursor over it */
    248250    INT      ihitoffset;  /* offset of hotspot from gripper.left */
    249251    POINT    origin;      /* left/upper corner of client */
    250 
    251     REBAR_ROW  *rows;       /* pointer to row indexes              */
     252    INT      ichevronhotBand; /* last band that had a hot chevron */
     253    INT      iGrabbedBand;/* band number of band whose gripper was grabbed */
     254
    252255    REBAR_BAND *bands;      /* pointer to the array of rebar bands */
    253256} REBAR_INFO;
     
    290293#define GRIPPER_WIDTH  3
    291294
     295/* Width of the chevron button if present */
     296#define CHEVRON_WIDTH  10
     297
    292298/* Height of divider for Rebar if not disabled (CCS_NODIVIDER)     */
    293299/* either top or bottom                                            */
     
    299305/* ----   End of REBAR layout constants.                      ---- */
    300306
     307#define RB_GETBANDINFO_OLD (WM_USER+5) /* obsoleted after IE3, but we have to support it anyway */
    301308
    302309/*  The following 6 defines return the proper rcBand element       */
     
    331338static UINT mindragy = 0;
    332339
    333 static char *band_stylename[] = {
     340static const char *band_stylename[] = {
    334341    "RBBS_BREAK",              /* 0001 */
    335342    "RBBS_FIXEDSIZE",          /* 0002 */
     
    343350    NULL };
    344351
    345 static char *band_maskname[] = {
     352static const char *band_maskname[] = {
    346353    "RBBIM_STYLE",         /*    0x00000001 */
    347354    "RBBIM_COLORS",        /*    0x00000002 */
     
    408415        TRACE("band info:");
    409416        if (pB->fMask & RBBIM_SIZE)
    410             DPRINTF(" cx=%u", pB->cx);
     417            TRACE(" cx=%u", pB->cx);
    411418        if (pB->fMask & RBBIM_IDEALSIZE)
    412             DPRINTF(" xIdeal=%u", pB->cxIdeal);
     419            TRACE(" xIdeal=%u", pB->cxIdeal);
    413420        if (pB->fMask & RBBIM_HEADERSIZE)
    414             DPRINTF(" xHeader=%u", pB->cxHeader);
     421            TRACE(" xHeader=%u", pB->cxHeader);
    415422        if (pB->fMask & RBBIM_LPARAM)
    416             DPRINTF(" lParam=0x%08lx", pB->lParam);
    417         DPRINTF("\n");
     423            TRACE(" lParam=0x%08lx", pB->lParam);
     424        TRACE("\n");
    418425    }
    419426    if (pB->fMask & RBBIM_CHILDSIZE)
     
    434441          iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
    435442          iP->calcSize.cx, iP->calcSize.cy);
    436     TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, ihitBand=%d\n",
     443    TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, iGrabbedBand=%d\n",
    437444          iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
    438445          iP->dragNow.x, iP->dragNow.y,
    439           iP->ihitBand);
     446          iP->iGrabbedBand);
    440447    TRACE("hwnd=%p: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
    441448          iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
     
    453460        if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
    454461            if (pB->fMask & RBBIM_SIZE)
    455                 DPRINTF(" cx=%u", pB->cx);
     462                TRACE(" cx=%u", pB->cx);
    456463            if (pB->fMask & RBBIM_IDEALSIZE)
    457                 DPRINTF(" xIdeal=%u", pB->cxIdeal);
     464                TRACE(" xIdeal=%u", pB->cxIdeal);
    458465            if (pB->fMask & RBBIM_LPARAM)
    459                 DPRINTF(" lParam=0x%08lx", pB->lParam);
    460         }
    461         DPRINTF("\n");
     466                TRACE(" lParam=0x%08lx", pB->lParam);
     467        }
     468        TRACE("\n");
    462469        if (RBBIM_CHILDSIZE)
    463470            TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
     
    468475        TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
    469476              i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy);
    470         TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n",
     477        TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%ld,%ld)-(%ld,%ld), Grip=(%ld,%ld)-(%ld,%ld)\n",
    471478              i, pB->fStatus, pB->fDraw,
    472479              pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom,
    473480              pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom);
    474         TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n",
     481        TRACE("band # %u: Img=(%ld,%ld)-(%ld,%ld), Txt=(%ld,%ld)-(%ld,%ld), Child=(%ld,%ld)-(%ld,%ld)\n",
    475482              i,
    476483              pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom,
     
    481488}
    482489
     490static void
     491REBAR_DrawChevron (HDC hdc, INT left, INT top, INT colorRef)
     492{
     493    INT x, y;
     494    HPEN hPen, hOldPen;
     495
     496    if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
     497    hOldPen = SelectObject ( hdc, hPen );
     498    x = left + 2;
     499    y = top;
     500    MoveToEx (hdc, x, y, NULL);
     501    LineTo (hdc, x+5, y++); x++;
     502    MoveToEx (hdc, x, y, NULL);
     503    LineTo (hdc, x+3, y++); x++;
     504    MoveToEx (hdc, x, y, NULL);
     505    LineTo (hdc, x+1, y++);
     506    SelectObject( hdc, hOldPen );
     507    DeleteObject( hPen );
     508}
    483509
    484510static HWND
     
    610636    }
    611637
     638    if (!IsRectEmpty(&lpBand->rcChevron))
     639    {
     640        if (lpBand->fDraw & DRAW_CHEVRONPUSHED)
     641        {
     642            DrawEdge(hdc, &lpBand->rcChevron, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE);
     643            REBAR_DrawChevron(hdc, lpBand->rcChevron.left+1, lpBand->rcChevron.top + 11, COLOR_WINDOWFRAME);
     644        }
     645        else if (lpBand->fDraw & DRAW_CHEVRONHOT)
     646        {
     647            DrawEdge(hdc, &lpBand->rcChevron, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
     648            REBAR_DrawChevron(hdc, lpBand->rcChevron.left, lpBand->rcChevron.top + 10, COLOR_WINDOWFRAME);
     649        }
     650        else
     651            REBAR_DrawChevron(hdc, lpBand->rcChevron.left, lpBand->rcChevron.top + 10, COLOR_WINDOWFRAME);
     652    }
     653
    612654    if (lpBand->uCDret == (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW)) {
    613655        nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT;
     
    628670{
    629671    REBAR_BAND *lpBand;
    630     UINT i, oldrow;
     672    UINT i;
    631673
    632674    if (!infoPtr->DoRedraw) return;
    633675
    634     oldrow = infoPtr->bands[0].iRow;
    635676    for (i = 0; i < infoPtr->uNumBands; i++) {
    636677        lpBand = &infoPtr->bands[i];
     
    681722            (lpBand->rcoldBand.bottom !=lpBand->rcBand.bottom)) {
    682723            lpBand->fDraw |= NTF_INVALIDATE;
    683             TRACE("band %d row=%d: changed to (%d,%d)-(%d,%d) from (%d,%d)-(%d,%d)\n",
     724            TRACE("band %d row=%d: changed to (%ld,%ld)-(%ld,%ld) from (%ld,%ld)-(%ld,%ld)\n",
    684725                  i, lpBand->iRow,
    685726                  lpBand->rcBand.left, lpBand->rcBand.top,
     
    689730        }
    690731        else
    691             TRACE("band %d row=%d: unchanged (%d,%d)-(%d,%d)\n",
     732            TRACE("band %d row=%d: unchanged (%ld,%ld)-(%ld,%ld)\n",
    692733                  i, lpBand->iRow,
    693734                  lpBand->rcBand.left, lpBand->rcBand.top,
     
    765806        else
    766807            lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
    767         TRACE("Phase 1 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
     808        TRACE("Phase 1 band %d, (%ld,%ld)-(%ld,%ld), orig x=%d, xsep=%d\n",
    768809              i, lpBand->rcBand.left, lpBand->rcBand.top,
    769810              lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
     
    835876        else
    836877            lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
    837         TRACE("Phase 2 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
     878        TRACE("Phase 2 band %d, (%ld,%ld)-(%ld,%ld), orig x=%d, xsep=%d\n",
    838879              i, lpBand->rcBand.left, lpBand->rcBand.top,
    839880              lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
     
    951992                   lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top+yoff,
    952993                   lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
     994          if ((lpBand->fStyle & RBBS_USECHEVRON) && (lpBand->rcChild.right - lpBand->rcChild.left < lpBand->cxIdeal))
     995          {
     996              lpBand->rcChild.right -= CHEVRON_WIDTH;
     997              SetRect(&lpBand->rcChevron, lpBand->rcChild.right,
     998                      lpBand->rcChild.top, lpBand->rcChild.right + CHEVRON_WIDTH,
     999                      lpBand->rcChild.bottom);
     1000          }
    9531001      }
    9541002      else {
     
    9631011           (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
    9641012          TRACE("Child rectangle changed for band %u\n", i);
    965           TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
     1013          TRACE("    from (%ld,%ld)-(%ld,%ld)  to (%ld,%ld)-(%ld,%ld)\n",
    9661014                oldChild.left, oldChild.top,
    9671015                oldChild.right, oldChild.bottom,
     
    9701018      }
    9711019      if (lpBand->fDraw & NTF_INVALIDATE) {
    972           TRACE("invalidating (%d,%d)-(%d,%d)\n",
     1020          TRACE("invalidating (%ld,%ld)-(%ld,%ld)\n",
    9731021                lpBand->rcBand.left,
    9741022                lpBand->rcBand.top,
     
    11021150             (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
    11031151            TRACE("Child rectangle changed for band %u\n", i);
    1104             TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
     1152            TRACE("    from (%ld,%ld)-(%ld,%ld)  to (%ld,%ld)-(%ld,%ld)\n",
    11051153                  oldChild.left, oldChild.top,
    11061154                  oldChild.right, oldChild.bottom,
     
    11091157        }
    11101158        if (lpBand->fDraw & NTF_INVALIDATE) {
    1111             TRACE("invalidating (%d,%d)-(%d,%d)\n",
     1159            TRACE("invalidating (%ld,%ld)-(%ld,%ld)\n",
    11121160                  lpBand->rcBand.left,
    11131161                  lpBand->rcBand.top,
     
    11421190    GetClientRect (infoPtr->hwndSelf, &rc);
    11431191
    1144     TRACE( " old [%ld x %ld], new [%ld x %ld], client [%d x %d]\n",
     1192    TRACE( " old [%ld x %ld], new [%ld x %ld], client [%ld x %ld]\n",
    11451193           infoPtr->oldSize.cx, infoPtr->oldSize.cy,
    11461194           infoPtr->calcSize.cx, infoPtr->calcSize.cy,
     
    12281276        infoPtr->hwndSelf, infoPtr->dwStyle,
    12291277        x, y, width, height);
    1230 
    12311278#ifdef __WIN32OS2__
    12321279//NOTE: this one is causing problems!!!!
     
    12711318            if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
    12721319                TRACE("Child rect changed by NOTIFY for band %u\n", i);
    1273                 TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
     1320                TRACE("    from (%ld,%ld)-(%ld,%ld)  to (%ld,%ld)-(%ld,%ld)\n",
    12741321                      lpBand->rcChild.left, lpBand->rcChild.top,
    12751322                      lpBand->rcChild.right, lpBand->rcChild.bottom,
     
    13021349
    13031350                /* center combo box inside child area */
    1304                 TRACE("moving child (Combo(Ex)) %p to (%d,%d) for (%d,%d)\n",
     1351                TRACE("moving child (Combo(Ex)) %p to (%ld,%d) for (%ld,%d)\n",
    13051352                      lpBand->hwndChild,
    13061353                      lpBand->rcChild.left, yPos,
     
    13171364            }
    13181365            else {
    1319                 TRACE("moving child (Other) %p to (%d,%d) for (%d,%d)\n",
     1366                TRACE("moving child (Other) %p to (%ld,%ld) for (%ld,%ld)\n",
    13201367                      lpBand->hwndChild,
    13211368                      lpBand->rcChild.left, lpBand->rcChild.top,
     
    13771424
    13781425    GetClientRect (infoPtr->hwndSelf, &rcClient);
    1379     TRACE("Client is (%d,%d)-(%d,%d)\n",
     1426    TRACE("Client is (%ld,%ld)-(%ld,%ld)\n",
    13801427          rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
    13811428
    13821429    if (lpRect) {
    13831430        rcAdj = *lpRect;
    1384         TRACE("adjustment rect is (%d,%d)-(%d,%d)\n",
     1431        TRACE("adjustment rect is (%ld,%ld)-(%ld,%ld)\n",
    13851432              rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom);
    13861433    }
     
    14331480        lpBand->iRow = row;
    14341481
     1482        SetRectEmpty(&lpBand->rcChevron);
     1483
    14351484        if (HIDDENBAND(lpBand)) continue;
    14361485
     
    14461495        /* separator from previous band */
    14471496        cxsep = (cntonrow == 0) ? 0 : SEP_WIDTH;
    1448 
    1449         /* Header: includes gripper, text, image */
    1450         cx = lpBand->cxHeader;
    1451         if (lpBand->fStyle & RBBS_FIXEDSIZE) cx = lpBand->lcx;
     1497        cx = lpBand->lcx;
    14521498
    14531499        if (infoPtr->dwStyle & CCS_VERT)
     
    15381584            x = rightx;
    15391585        }
    1540         TRACE("P1 band %u, row %d, (%d,%d)-(%d,%d)\n",
     1586        TRACE("P1 band %u, row %d, (%ld,%ld)-(%ld,%ld)\n",
    15411587              i, row,
    15421588              lpBand->rcBand.left, lpBand->rcBand.top,
     
    16171663    /*   y/x     current height/width of all rows                    */
    16181664    if (lpRect) {
    1619         INT i, j, prev_rh, new_rh, adj_rh, prev_idx, current_idx;
     1665        INT i, prev_rh, new_rh, adj_rh, prev_idx, current_idx;
    16201666        REBAR_BAND *prev, *current, *walk;
     1667        UINT j;
    16211668
    16221669/* FIXME:  problem # 2 */
     
    16251672             (x < adjcx) : (y < adjcy)
    16261673#else
    1627              (adjcx - x > 4) : (adjcy - y > 4)
     1674             (adjcx - x > 5) : (adjcy - y > 4)
    16281675#endif
    16291676             ) &&
     
    16781725                        y += adj_rh;
    16791726                    }
    1680                     TRACE("P2 moving band %d to own row at (%d,%d)-(%d,%d)\n",
     1727                    TRACE("P2 moving band %d to own row at (%ld,%ld)-(%ld,%ld)\n",
    16811728                          current_idx,
    16821729                          current->rcBand.left, current->rcBand.top,
    16831730                          current->rcBand.right, current->rcBand.bottom);
    1684                     TRACE("P2 prev band %d at (%d,%d)-(%d,%d)\n",
     1731                    TRACE("P2 prev band %d at (%ld,%ld)-(%ld,%ld)\n",
    16851732                          prev_idx,
    16861733                          prev->rcBand.left, prev->rcBand.top,
     
    17131760
    17141761
    1715     /* ******* Start Phase 2a - create array of start and end  ******* */
    1716     /*                          indexes by row                         */
    1717 
    1718     if (infoPtr->uNumRows != origrows) {
    1719         if (infoPtr->rows) COMCTL32_Free (infoPtr->rows);
    1720         infoPtr->rows = COMCTL32_Alloc (sizeof (REBAR_ROW) * infoPtr->uNumRows);
    1721     }
    1722 
    1723     row = 0;
    1724     for (i = 0; i < infoPtr->uNumBands; i++) {
    1725         lpBand = &infoPtr->bands[i];
    1726         if (HIDDENBAND(lpBand)) continue;
    1727 
    1728         if (lpBand->iRow > row) {
    1729             row++;
    1730             infoPtr->rows[row-1].istartband = i;
    1731         }
    1732         if (row == 0) {
    1733             ERR("P2a bug!!!!!!\n");
    1734         }
    1735         infoPtr->rows[row-1].iendband = i;
    1736     }
    1737 
    1738     for (i = 0; i < infoPtr->uNumRows; i++) {
    1739         REBAR_ROW *p;
    1740 
    1741         p = &infoPtr->rows[i];
    1742         TRACE("P2a row %d, starts %d, ends %d\n",
    1743               i+1, p->istartband, p->iendband);
    1744     }
    1745 
    1746     /* ******* End Phase 2a - create array of start and end    ******* */
    1747     /*                          indexes by row                         */
     1762    /* ******* Start Phase 2a - mark first and last band in each ******* */
     1763
     1764    prevBand = NULL;
     1765    for (i = 0; i < infoPtr->uNumBands; i++) {   
     1766        lpBand = &infoPtr->bands[i];     
     1767        if (HIDDENBAND(lpBand))
     1768            continue;
     1769        if( !prevBand ) {
     1770            lpBand->fDraw |= DRAW_FIRST_IN_ROW;
     1771            prevBand = lpBand;
     1772        }
     1773        else if( prevBand->iRow == lpBand->iRow )
     1774            prevBand = lpBand;
     1775        else {
     1776            prevBand->fDraw |= DRAW_LAST_IN_ROW;
     1777            lpBand->fDraw |= DRAW_FIRST_IN_ROW;
     1778            prevBand = lpBand;
     1779        }
     1780    }
     1781    if( prevBand )
     1782        prevBand->fDraw |= DRAW_LAST_IN_ROW;
     1783
     1784    /* ******* End Phase 2a - mark first and last band in each ******* */
    17481785
    17491786
     
    17551792    if (((infoPtr->dwStyle & CCS_VERT) ? clientcx > x : clientcy > y) &&
    17561793        infoPtr->uNumBands) {
    1757         INT diff, i, iband, j;
     1794        INT diff, i;
     1795        UINT j;
    17581796
    17591797        diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y;
    1760         for (i = infoPtr->uNumRows; i >= 1; i--) {
    1761             /* if row has more than 1 band, ignore row   */
    1762             if (infoPtr->rows[i-1].istartband != infoPtr->rows[i-1].iendband)
    1763                 continue;
    1764             /* point to only band in row  */
    1765             iband = infoPtr->rows[i-1].istartband;
    1766             lpBand = &infoPtr->bands[iband];
     1798
     1799        /* iterate backwards thru the rows */
     1800        for (i = infoPtr->uNumBands-1; i>=0; i--) {
     1801            lpBand = &infoPtr->bands[i];
    17671802            if(HIDDENBAND(lpBand)) continue;
     1803
     1804            /* if row has more than 1 band, ignore it */
     1805            if( !(lpBand->fDraw&DRAW_FIRST_IN_ROW) )
     1806                continue;
     1807            if( !(lpBand->fDraw&DRAW_LAST_IN_ROW) )
     1808                continue;
     1809
    17681810            if (lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
    17691811            if (((INT)lpBand->cyMaxChild < 1) ||
     
    17711813                if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue;
    17721814                ERR("P2b band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
    1773                     iband, lpBand->cyMaxChild, lpBand->cyIntegral);
     1815                    i, lpBand->cyMaxChild, lpBand->cyIntegral);
    17741816                continue;
    17751817            }
     
    17841826            else
    17851827                lpBand->rcBand.bottom = lpBand->rcBand.top + j;
    1786             TRACE("P2b band %d, row %d changed to (%d,%d)-(%d,%d)\n",
    1787                   iband, lpBand->iRow,
     1828            TRACE("P2b band %d, row %d changed to (%ld,%ld)-(%ld,%ld)\n",
     1829                  i, lpBand->iRow,
    17881830                  lpBand->rcBand.left, lpBand->rcBand.top,
    17891831                  lpBand->rcBand.right, lpBand->rcBand.bottom);
     
    18061848
    18071849    if (infoPtr->uNumBands) {
    1808         REBAR_ROW *p;
     1850        int startband;
    18091851
    18101852        /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
     
    18141856        if (infoPtr->dwStyle & RBS_BANDBORDERS) {
    18151857
    1816             for(i = 0; i < infoPtr->uNumRows; i++) {
    1817                 p = &infoPtr->rows[i];
    1818                 for (j = p->istartband; j <= p->iendband; j++) {
    1819                     lpBand = &infoPtr->bands[j];
    1820                     if (HIDDENBAND(lpBand)) continue;
    1821                     if (j != p->iendband)
    1822                         lpBand->fDraw |= DRAW_RIGHTSEP;
    1823                     if (i != infoPtr->uNumRows-1)
    1824                         lpBand->fDraw |= DRAW_BOTTOMSEP;
    1825                 }
     1858            for (i=0; i<infoPtr->uNumBands; i++) {
     1859                lpBand = &infoPtr->bands[i];
     1860                if (HIDDENBAND(lpBand))
     1861                    continue;
     1862
     1863                /* not righthand bands */
     1864                if( !(lpBand->fDraw & DRAW_LAST_IN_ROW) )
     1865                    lpBand->fDraw |= DRAW_RIGHTSEP;
     1866
     1867                /* not the last row */
     1868                if( lpBand->iRow != infoPtr->uNumRows )
     1869                    lpBand->fDraw |= DRAW_BOTTOMSEP;
    18261870            }
    18271871        }
     
    18291873        /* Distribute the extra space on the horizontal and adjust  */
    18301874        /* all bands in row to same height.                         */
    1831         for (i=1; i<=infoPtr->uNumRows; i++) {
    1832             p = &infoPtr->rows[i-1];
    1833             mcy = 0;
    1834 
    1835             TRACE("P3 processing row %d, starting band %d, ending band %d\n",
    1836                   i, p->istartband, p->iendband);
    1837 
    1838             /* Find the largest height of the bands in the row */
    1839             for (j = p->istartband; j <= p->iendband; j++) {
    1840                 lpBand = &infoPtr->bands[j];
    1841                 if (HIDDENBAND(lpBand)) continue;
    1842                 if (mcy < ircBw(lpBand))
    1843                     mcy = ircBw(lpBand);
    1844             }
    1845 
    1846             REBAR_AdjustBands (infoPtr, p->istartband, p->iendband,
     1875        mcy = 0;
     1876        startband = -1;
     1877        for (i=0; i<infoPtr->uNumBands; i++) {
     1878
     1879            lpBand = &infoPtr->bands[i];
     1880
     1881            if( lpBand->fDraw & DRAW_FIRST_IN_ROW )
     1882            {
     1883                startband = i;
     1884                mcy = 0;
     1885            }
     1886
     1887            if ( (mcy < ircBw(lpBand)) && !HIDDENBAND(lpBand) )
     1888                mcy = ircBw(lpBand);
     1889
     1890            if( lpBand->fDraw & DRAW_LAST_IN_ROW )
     1891            {
     1892                TRACE("P3 processing row %d, starting band %d, ending band %d\n",
     1893                      lpBand->iRow, startband, i);
     1894                if( startband < 0 )
     1895                    ERR("Last band %d with no first, row %d\n", i, lpBand->iRow);
     1896
     1897                REBAR_AdjustBands (infoPtr, startband, i,
    18471898                               (infoPtr->dwStyle & CCS_VERT) ?
    18481899                               clientcy : clientcx, mcy);
     1900            }
    18491901        }
    18501902
     
    19001952    UINT header=0;
    19011953    UINT textheight=0;
    1902     INT i, nonfixed;
     1954    UINT i, nonfixed;
    19031955    REBAR_BAND *tBand;
    19041956
     
    20382090}
    20392091
    2040 static void
     2092static BOOL
    20412093REBAR_CommonSetupBand (HWND hwnd, LPREBARBANDINFOA lprbbi, REBAR_BAND *lpBand)
    20422094     /* Function:  This routine copies the supplied values from   */
    20432095     /*  user input (lprbbi) to the internal band structure.      */
    2044 {
     2096     /*  It returns true if something changed and false if not.   */
     2097{
     2098    BOOL bChanged = FALSE;
     2099
    20452100    lpBand->fMask |= lprbbi->fMask;
    20462101
    2047     if (lprbbi->fMask & RBBIM_STYLE)
     2102    if( (lprbbi->fMask & RBBIM_STYLE) &&
     2103        (lpBand->fStyle != lprbbi->fStyle ) )
     2104    {
    20482105        lpBand->fStyle = lprbbi->fStyle;
    2049 
    2050     if (lprbbi->fMask & RBBIM_COLORS) {
     2106        bChanged = TRUE;
     2107    }
     2108
     2109    if( (lprbbi->fMask & RBBIM_COLORS) &&
     2110       ( ( lpBand->clrFore != lprbbi->clrFore ) ||
     2111         ( lpBand->clrBack != lprbbi->clrBack ) ) )
     2112    {
    20512113        lpBand->clrFore = lprbbi->clrFore;
    20522114        lpBand->clrBack = lprbbi->clrBack;
    2053     }
    2054 
    2055     if (lprbbi->fMask & RBBIM_IMAGE)
     2115        bChanged = TRUE;
     2116    }
     2117
     2118    if( (lprbbi->fMask & RBBIM_IMAGE) &&
     2119       ( lpBand->iImage != lprbbi->iImage ) )
     2120    {
    20562121        lpBand->iImage = lprbbi->iImage;
    2057 
    2058     if (lprbbi->fMask & RBBIM_CHILD) {
     2122        bChanged = TRUE;
     2123    }
     2124
     2125    if( (lprbbi->fMask & RBBIM_CHILD) &&
     2126       (lprbbi->hwndChild != lpBand->hwndChild ) )
     2127    {
    20592128        if (lprbbi->hwndChild) {
    20602129            lpBand->hwndChild = lprbbi->hwndChild;
     
    20712140            lpBand->hwndPrevParent = 0;
    20722141        }
    2073     }
    2074 
    2075     if (lprbbi->fMask & RBBIM_CHILDSIZE) {
     2142        bChanged = TRUE;
     2143    }
     2144
     2145    if( (lprbbi->fMask & RBBIM_CHILDSIZE) &&
     2146        ( (lpBand->cxMinChild != lprbbi->cxMinChild) ||
     2147          (lpBand->cyMinChild != lprbbi->cyMinChild ) ||
     2148          ( (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) &&
     2149            ( (lpBand->cyChild    != lprbbi->cyChild ) ||
     2150              (lpBand->cyMaxChild != lprbbi->cyMaxChild ) ||
     2151              (lpBand->cyIntegral != lprbbi->cyIntegral ) ) ) ||
     2152          ( (lprbbi->cbSize < sizeof (REBARBANDINFOA)) &&
     2153            ( (lpBand->cyChild ||
     2154               lpBand->cyMaxChild ||
     2155               lpBand->cyIntegral ) ) ) ) )
     2156    {
    20762157        lpBand->cxMinChild = lprbbi->cxMinChild;
    20772158        lpBand->cyMinChild = lprbbi->cyMinChild;
     
    20872168            lpBand->cyIntegral = 0;
    20882169        }
    2089     }
    2090 
    2091     if (lprbbi->fMask & RBBIM_SIZE)
     2170        bChanged = TRUE;
     2171    }
     2172
     2173    if( (lprbbi->fMask & RBBIM_SIZE) &&
     2174        (lpBand->cx != lprbbi->cx ) )
     2175    {
    20922176        lpBand->cx = lprbbi->cx;
    2093 
    2094     if (lprbbi->fMask & RBBIM_BACKGROUND)
     2177        bChanged = TRUE;
     2178    }
     2179
     2180    if( (lprbbi->fMask & RBBIM_BACKGROUND) &&
     2181       ( lpBand->hbmBack != lprbbi->hbmBack ) )
     2182    {
    20952183        lpBand->hbmBack = lprbbi->hbmBack;
    2096 
    2097     if (lprbbi->fMask & RBBIM_ID)
     2184        bChanged = TRUE;
     2185    }
     2186
     2187    if( (lprbbi->fMask & RBBIM_ID) &&
     2188        (lpBand->wID != lprbbi->wID ) )
     2189    {
    20982190        lpBand->wID = lprbbi->wID;
     2191        bChanged = TRUE;
     2192    }
    20992193
    21002194    /* check for additional data */
    21012195    if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
    2102         if (lprbbi->fMask & RBBIM_IDEALSIZE)
     2196        if( (lprbbi->fMask & RBBIM_IDEALSIZE) &&
     2197            ( lpBand->cxIdeal != lprbbi->cxIdeal ) )
     2198        {
    21032199            lpBand->cxIdeal = lprbbi->cxIdeal;
    2104 
    2105         if (lprbbi->fMask & RBBIM_LPARAM)
     2200            bChanged = TRUE;
     2201        }
     2202
     2203        if( (lprbbi->fMask & RBBIM_LPARAM) &&
     2204            (lpBand->lParam != lprbbi->lParam ) )
     2205        {
    21062206            lpBand->lParam = lprbbi->lParam;
    2107 
    2108         if (lprbbi->fMask & RBBIM_HEADERSIZE)
     2207            bChanged = TRUE;
     2208        }
     2209
     2210        if( (lprbbi->fMask & RBBIM_HEADERSIZE) &&
     2211            (lpBand->cxHeader != lprbbi->cxHeader ) )
     2212        {
    21092213            lpBand->cxHeader = lprbbi->cxHeader;
    2110     }
     2214            bChanged = TRUE;
     2215        }
     2216    }
     2217
     2218    return bChanged;
    21112219}
    21122220
     
    21192227{
    21202228    REBAR_BAND *lpBand;
    2121     INT i, oldrow;
     2229    UINT i;
     2230    INT oldrow;
    21222231    HDC hdc = (HDC)wParam;
    21232232    RECT rect;
     
    21452254                    DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
    21462255                }
    2147                 TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n",
     2256                TRACE ("drawing band separator bottom (%ld,%ld)-(%ld,%ld)\n",
    21482257                       rcRowSep.left, rcRowSep.top,
    21492258                       rcRowSep.right, rcRowSep.bottom);
     
    21632272                DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
    21642273            }
    2165             TRACE("drawing band separator right (%d,%d)-(%d,%d)\n",
     2274            TRACE("drawing band separator right (%ld,%ld)-(%ld,%ld)\n",
    21662275                  rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
    21672276        }
     
    21902299
    21912300        rect = lpBand->rcBand;
    2192         TRACE("%s background color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
     2301        TRACE("%s background color=0x%06lx, band (%ld,%ld)-(%ld,%ld), clip (%ld,%ld)-(%ld,%ld)\n",
    21932302              (lpBand->clrBack == CLR_NONE) ? "none" :
    21942303                ((lpBand->clrBack == CLR_DEFAULT) ? "dft" : ""),
     
    22062315
    22072316static void
    2208 REBAR_InternalHitTest (REBAR_INFO *infoPtr, LPPOINT lpPt, UINT *pFlags, INT *pBand)
     2317REBAR_InternalHitTest (REBAR_INFO *infoPtr, const LPPOINT lpPt, UINT *pFlags, INT *pBand)
    22092318{
    22102319    REBAR_BAND *lpBand;
    22112320    RECT rect;
    2212     INT  iCount;
     2321    UINT  iCount;
    22132322
    22142323    GetClientRect (infoPtr->hwndSelf, &rect);
     
    22262335        else {
    22272336            /* somewhere inside */
    2228             infoPtr->ihitBand = -1;
    22292337            for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
    22302338                lpBand = &infoPtr->bands[iCount];
     
    22352343                    if (PtInRect (&lpBand->rcGripper, *lpPt)) {
    22362344                        *pFlags = RBHT_GRABBER;
    2237                         infoPtr->ihitBand = iCount;
    22382345                        TRACE("ON GRABBER %d\n", iCount);
    22392346                        return;
     
    22542361                        return;
    22552362                    }
     2363                    else if (PtInRect (&lpBand->rcChevron, *lpPt)) {
     2364                        *pFlags = RBHT_CHEVRON;
     2365                        TRACE("ON CHEVRON %d\n", iCount);
     2366                        return;
     2367                    }
    22562368                    else {
    22572369                        *pFlags = RBHT_NOWHERE;
     
    22772389        return;
    22782390    }
    2279 
    2280     TRACE("flags=0x%X\n", *pFlags);
    2281     return;
    22822391}
    22832392
     
    23442453    READJ(band, Readjust);
    23452454
    2346     TRACE("band %d:  left=%d, right=%d, move=%d, rtn=%d, rcBand=(%d,%d)-(%d,%d)\n",
     2455    TRACE("band %d:  left=%d, right=%d, move=%d, rtn=%d, rcBand=(%ld,%ld)-(%ld,%ld)\n",
    23472456          i, Leadjust, Readjust, movement, ret,
    23482457          band->rcBand.left, band->rcBand.top,
     
    23752484            infoPtr->dragStart.y = 0;
    23762485            infoPtr->dragNow = infoPtr->dragStart;
    2377             infoPtr->ihitBand = -1;
     2486            infoPtr->iGrabbedBand = -1;
    23782487            ReleaseCapture ();
    23792488            return ;
     
    23822491    }
    23832492
    2384     ihitBand = infoPtr->ihitBand;
     2493    ihitBand = infoPtr->iGrabbedBand;
    23852494    hitBand = &infoPtr->bands[ihitBand];
    23862495    imaxdBand = ihitBand; /* to suppress warning message */
     
    25272636        if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
    25282637            childhwnd = lpBand->hwndChild;
    2529         COMCTL32_Free (infoPtr->bands);
     2638        Free (infoPtr->bands);
    25302639        infoPtr->bands = NULL;
    25312640        infoPtr->uNumBands = 0;
     
    25392648
    25402649        infoPtr->uNumBands--;
    2541         infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
     2650        infoPtr->bands = Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
    25422651        if (uBand > 0) {
    25432652            memcpy (&infoPtr->bands[0], &oldBands[0],
     
    25502659        }
    25512660
    2552         COMCTL32_Free (oldBands);
     2661        Free (oldBands);
    25532662    }
    25542663
     
    26312740    if (lprbbi == NULL)
    26322741        return FALSE;
    2633     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
     2742    if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
    26342743        return FALSE;
    26352744    if ((UINT)wParam >= infoPtr->uNumBands)
     
    27172826    if (lprbbi == NULL)
    27182827        return FALSE;
    2719     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
     2828    if (lprbbi->cbSize < REBARBANDINFOW_V3_SIZE)
    27202829        return FALSE;
    27212830    if ((UINT)wParam >= infoPtr->uNumBands)
     
    28682977    CopyRect (lprc, &lpBand->rcBand);
    28692978
    2870     TRACE("band %d, (%d,%d)-(%d,%d)\n", iBand,
     2979    TRACE("band %d, (%ld,%ld)-(%ld,%ld)\n", iBand,
    28712980          lprc->left, lprc->top, lprc->right, lprc->bottom);
    28722981
     
    28882997{
    28892998    INT iRow = (INT)wParam;
    2890     int ret = 0;
    2891     int i, j = 0;
     2999    int j = 0, ret = 0;
     3000    UINT i;
    28923001    REBAR_BAND *lpBand;
    28933002
     
    29913100    if (lprbbi == NULL)
    29923101        return FALSE;
    2993     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
     3102    if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
    29943103        return FALSE;
    29953104
     
    29993108
    30003109    if (infoPtr->uNumBands == 0) {
    3001         infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
     3110        infoPtr->bands = (REBAR_BAND *)Alloc (sizeof (REBAR_BAND));
    30023111        uIndex = 0;
    30033112    }
     
    30053114        REBAR_BAND *oldBands = infoPtr->bands;
    30063115        infoPtr->bands =
    3007             (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
     3116            (REBAR_BAND *)Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
    30083117        if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
    30093118            uIndex = infoPtr->uNumBands;
     
    30213130        }
    30223131
    3023         COMCTL32_Free (oldBands);
     3132        Free (oldBands);
    30243133    }
    30253134
     
    30423151        INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
    30433152        if (len > 1) {
    3044             lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR));
     3153            lpBand->lpText = (LPWSTR)Alloc (len*sizeof(WCHAR));
    30453154            MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
    30463155        }
     
    30723181    if (lprbbi == NULL)
    30733182        return FALSE;
    3074     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
     3183    if (lprbbi->cbSize < REBARBANDINFOW_V3_SIZE)
    30753184        return FALSE;
    30763185
     
    30803189
    30813190    if (infoPtr->uNumBands == 0) {
    3082         infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
     3191        infoPtr->bands = (REBAR_BAND *)Alloc (sizeof (REBAR_BAND));
    30833192        uIndex = 0;
    30843193    }
     
    30863195        REBAR_BAND *oldBands = infoPtr->bands;
    30873196        infoPtr->bands =
    3088             (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
     3197            (REBAR_BAND *)Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
    30893198        if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
    30903199            uIndex = infoPtr->uNumBands;
     
    30973206
    30983207        /* post copy */
    3099         if (uIndex < infoPtr->uNumBands - 1) {
     3208        if (uIndex <= infoPtr->uNumBands - 1) {
    31003209            memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
    3101                     (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
    3102         }
    3103 
    3104         COMCTL32_Free (oldBands);
     3210                    (infoPtr->uNumBands - uIndex) * sizeof(REBAR_BAND));
     3211        }
     3212
     3213        Free (oldBands);
    31053214    }
    31063215
     
    31233232        INT len = lstrlenW (lprbbi->lpText);
    31243233        if (len > 0) {
    3125             lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     3234            lpBand->lpText = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR));
    31263235            strcpyW (lpBand->lpText, lprbbi->lpText);
    31273236        }
     
    31313240    /* On insert of second band, revalidate band 1 to possible add gripper */
    31323241    if (infoPtr->uNumBands == 2)
    3133         REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
     3242        REBAR_ValidateBand (infoPtr, &infoPtr->bands[uIndex ? 0 : 1]);
    31343243
    31353244    REBAR_DumpBand (infoPtr);
     
    32123321            lpBand->cxHeader;
    32133322    if (movement < 0) {
    3214         ERR("something is wrong, band=(%d,%d)-(%d,%d), cxheader=%d\n",
     3323        ERR("something is wrong, band=(%ld,%ld)-(%ld,%ld), cxheader=%d\n",
    32153324            lpBand->rcBand.left, lpBand->rcBand.top,
    32163325            lpBand->rcBand.right, lpBand->rcBand.bottom,
     
    33333442    memcpy (&holder, &oldBands[uFrom], sizeof(REBAR_BAND));
    33343443
    3335     /* close up rest of bands (psuedo delete) */
     3444    /* close up rest of bands (pseudo delete) */
    33363445    if (uFrom < infoPtr->uNumBands - 1) {
    33373446        memcpy (&oldBands[uFrom], &oldBands[uFrom+1],
     
    33413450    /* allocate new space and copy rest of bands into it */
    33423451    infoPtr->bands =
    3343         (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
     3452        (REBAR_BAND *)Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
    33443453
    33453454    /* pre insert copy */
     
    33583467    }
    33593468
    3360     COMCTL32_Free (oldBands);
     3469    Free (oldBands);
    33613470
    33623471    TRACE("moved band %d to index %d\n", uFrom, uTo);
     
    33773486
    33783487
     3488/* return TRUE if two strings are different */
     3489static BOOL
     3490REBAR_strdifW( LPCWSTR a, LPCWSTR b )
     3491{
     3492    return ( (a && !b) || (b && !a) || (a && b && lstrcmpW(a, b) ) );
     3493}
     3494
    33793495static LRESULT
    33803496REBAR_SetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     
    33823498    LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
    33833499    REBAR_BAND *lpBand;
     3500    BOOL bChanged;
    33843501
    33853502    if (lprbbi == NULL)
    33863503        return FALSE;
    3387     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
     3504    if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
    33883505        return FALSE;
    33893506    if ((UINT)wParam >= infoPtr->uNumBands)
     
    33963513    lpBand = &infoPtr->bands[(UINT)wParam];
    33973514
    3398     REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
     3515    bChanged = REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
    33993516    if (lprbbi->fMask & RBBIM_TEXT) {
    3400         if (lpBand->lpText) {
    3401             COMCTL32_Free (lpBand->lpText);
    3402             lpBand->lpText = NULL;
    3403         }
    3404         if (lprbbi->lpText) {
    3405             INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
    3406             lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR));
    3407             MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
    3408         }
     3517        LPWSTR wstr = NULL;
     3518
     3519        if (lprbbi->lpText)
     3520        {
     3521            INT len;
     3522            len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
     3523            if (len > 1)
     3524                wstr = (LPWSTR)Alloc (len*sizeof(WCHAR));
     3525            if (wstr)
     3526                MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, wstr, len );
     3527        }
     3528        if (REBAR_strdifW(lpBand->lpText, wstr)) {
     3529            if (lpBand->lpText) {
     3530                Free (lpBand->lpText);
     3531                lpBand->lpText = NULL;
     3532            }
     3533            if (wstr) {
     3534                lpBand->lpText = wstr;
     3535                wstr = NULL;
     3536            }
     3537            bChanged = TRUE;
     3538        }
     3539        if (wstr)
     3540            Free (wstr);
    34093541    }
    34103542
     
    34133545    REBAR_DumpBand (infoPtr);
    34143546
    3415     if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) {
     3547    if (bChanged && (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE))) {
    34163548          REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
    34173549          InvalidateRect(infoPtr->hwndSelf, 0, 1);
     
    34213553}
    34223554
    3423 
    34243555static LRESULT
    34253556REBAR_SetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     
    34273558    LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
    34283559    REBAR_BAND *lpBand;
     3560    BOOL bChanged;
    34293561
    34303562    if (lprbbi == NULL)
    34313563        return FALSE;
    3432     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
     3564    if (lprbbi->cbSize < REBARBANDINFOW_V3_SIZE)
    34333565        return FALSE;
    34343566    if ((UINT)wParam >= infoPtr->uNumBands)
     
    34413573    lpBand = &infoPtr->bands[(UINT)wParam];
    34423574
    3443     REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
    3444     if (lprbbi->fMask & RBBIM_TEXT) {
     3575    bChanged = REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
     3576    if( (lprbbi->fMask & RBBIM_TEXT) &&
     3577        REBAR_strdifW( lpBand->lpText, lprbbi->lpText ) ) {
    34453578        if (lpBand->lpText) {
    3446             COMCTL32_Free (lpBand->lpText);
     3579            Free (lpBand->lpText);
    34473580            lpBand->lpText = NULL;
    34483581        }
    34493582        if (lprbbi->lpText) {
    34503583            INT len = lstrlenW (lprbbi->lpText);
    3451             lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    3452             strcpyW (lpBand->lpText, lprbbi->lpText);
    3453         }
     3584            if (len > 0)
     3585            {
     3586                lpBand->lpText = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR));
     3587                strcpyW (lpBand->lpText, lprbbi->lpText);
     3588            }
     3589        }
     3590        bChanged = TRUE;
    34543591    }
    34553592
     
    34583595    REBAR_DumpBand (infoPtr);
    34593596
    3460     if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) {
     3597    if ( bChanged && (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) ) {
    34613598      REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
    34623599      InvalidateRect(infoPtr->hwndSelf, 0, 1);
     
    36083745    }
    36093746
     3747    infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
    36103748    REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
    36113749    InvalidateRect(infoPtr->hwndSelf, 0, 1);
     
    36243762       return FALSE;
    36253763
    3626     TRACE("[%d %d %d %d]\n",
     3764    TRACE("[%ld %ld %ld %ld]\n",
    36273765          lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
    36283766
    36293767    /*  what is going on???? */
    36303768    GetWindowRect(infoPtr->hwndSelf, &t1);
    3631     TRACE("window rect [%d %d %d %d]\n",
     3769    TRACE("window rect [%ld %ld %ld %ld]\n",
    36323770          t1.left, t1.top, t1.right, t1.bottom);
    36333771    GetClientRect(infoPtr->hwndSelf, &t1);
    3634     TRACE("client rect [%d %d %d %d]\n",
     3772    TRACE("client rect [%ld %ld %ld %ld]\n",
    36353773          t1.left, t1.top, t1.right, t1.bottom);
    36363774
     
    36543792        GetWindowRect(infoPtr->hwndSelf, &wnrc1);
    36553793        GetClientRect(infoPtr->hwndSelf, &clrc1);
    3656         TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
     3794        TRACE("window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) cs=(%d,%d %dx%d)\n",
    36573795              wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
    36583796              clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
     
    36693807{
    36703808    REBAR_BAND *lpBand;
    3671     INT i;
     3809    UINT i;
    36723810
    36733811
     
    36803818            /* delete text strings */
    36813819            if (lpBand->lpText) {
    3682                 COMCTL32_Free (lpBand->lpText);
     3820                Free (lpBand->lpText);
    36833821                lpBand->lpText = NULL;
    36843822            }
     
    36883826
    36893827        /* free band array */
    3690         COMCTL32_Free (infoPtr->bands);
     3828        Free (infoPtr->bands);
    36913829        infoPtr->bands = NULL;
    36923830    }
     
    37003838
    37013839    /* free rebar info data */
    3702     COMCTL32_Free (infoPtr);
     3840    Free (infoPtr);
    37033841    TRACE("destroyed!\n");
    37043842    return 0;
     
    37233861}
    37243862
     3863static LRESULT
     3864REBAR_PushChevron(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3865{
     3866    if (wParam >= 0 && (UINT)wParam < infoPtr->uNumBands)
     3867    {
     3868        NMREBARCHEVRON nmrbc;
     3869        REBAR_BAND *lpBand = &infoPtr->bands[wParam];
     3870
     3871        TRACE("Pressed chevron on band %d\n", wParam);
     3872
     3873        /* redraw chevron in pushed state */
     3874        lpBand->fDraw |= DRAW_CHEVRONPUSHED;
     3875        RedrawWindow(infoPtr->hwndSelf, &lpBand->rcChevron,0,
     3876          RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
     3877
     3878        /* notify app so it can display a popup menu or whatever */
     3879        nmrbc.uBand = wParam;
     3880        nmrbc.wID = lpBand->wID;
     3881        nmrbc.lParam = lpBand->lParam;
     3882        nmrbc.rc = lpBand->rcChevron;
     3883        nmrbc.lParamNM = lParam;
     3884        REBAR_Notify((NMHDR*)&nmrbc, infoPtr, RBN_CHEVRONPUSHED);
     3885
     3886        /* redraw chevron in previous state */
     3887        lpBand->fDraw &= ~DRAW_CHEVRONPUSHED;
     3888        InvalidateRect(infoPtr->hwndSelf, &lpBand->rcChevron, TRUE);
     3889
     3890        return TRUE;
     3891    }
     3892    return FALSE;
     3893}
    37253894
    37263895static LRESULT
     
    37283897{
    37293898    REBAR_BAND *lpBand;
    3730 
    3731     /* If InternalHitTest did not find a hit on the Gripper, */
    3732     /* then ignore the button click.                         */
    3733     if (infoPtr->ihitBand == -1) return 0;
    3734 
    3735     SetCapture (infoPtr->hwndSelf);
    3736 
    3737     /* save off the LOWORD and HIWORD of lParam as initial x,y */
    3738     lpBand = &infoPtr->bands[infoPtr->ihitBand];
    3739     infoPtr->dragStart = MAKEPOINTS(lParam);
    3740     infoPtr->dragNow = infoPtr->dragStart;
    3741     if (infoPtr->dwStyle & CCS_VERT)
    3742         infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.top+REBAR_PRE_GRIPPER);
    3743     else
    3744         infoPtr->ihitoffset = infoPtr->dragStart.x - (lpBand->rcBand.left+REBAR_PRE_GRIPPER);
    3745 
     3899    UINT htFlags;
     3900    UINT iHitBand;
     3901    POINT ptMouseDown;
     3902    ptMouseDown.x = (INT)LOWORD(lParam);
     3903    ptMouseDown.y = (INT)HIWORD(lParam);
     3904
     3905    REBAR_InternalHitTest(infoPtr, &ptMouseDown, &htFlags, &iHitBand);
     3906    lpBand = &infoPtr->bands[iHitBand];
     3907
     3908    if (htFlags == RBHT_CHEVRON)
     3909    {
     3910        REBAR_PushChevron(infoPtr, iHitBand, 0);
     3911    }
     3912    else if (htFlags == RBHT_GRABBER || htFlags == RBHT_CAPTION)
     3913    {
     3914        TRACE("Starting drag\n");
     3915
     3916        SetCapture (infoPtr->hwndSelf);
     3917        infoPtr->iGrabbedBand = iHitBand;
     3918
     3919        /* save off the LOWORD and HIWORD of lParam as initial x,y */
     3920        infoPtr->dragStart = MAKEPOINTS(lParam);
     3921        infoPtr->dragNow = infoPtr->dragStart;
     3922        if (infoPtr->dwStyle & CCS_VERT)
     3923            infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.top+REBAR_PRE_GRIPPER);
     3924        else
     3925            infoPtr->ihitoffset = infoPtr->dragStart.x - (lpBand->rcBand.left+REBAR_PRE_GRIPPER);
     3926    }
    37463927    return 0;
    37473928}
    3748 
    37493929
    37503930static LRESULT
    37513931REBAR_LButtonUp (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
    37523932{
    3753     NMHDR layout;
    3754     RECT rect;
    3755     INT ihitBand;
    3756 
    3757     /* If InternalHitTest did not find a hit on the Gripper, */
    3758     /* then ignore the button click.                         */
    3759     if (infoPtr->ihitBand == -1) return 0;
    3760 
    3761     ihitBand = infoPtr->ihitBand;
    3762     infoPtr->dragStart.x = 0;
    3763     infoPtr->dragStart.y = 0;
    3764     infoPtr->dragNow = infoPtr->dragStart;
    3765     infoPtr->ihitBand = -1;
    3766 
    3767     ReleaseCapture ();
    3768 
    3769     if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
    3770         REBAR_Notify((NMHDR *) &layout, infoPtr, RBN_LAYOUTCHANGED);
    3771         REBAR_Notify_NMREBAR (infoPtr, ihitBand, RBN_ENDDRAG);
    3772         infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
    3773     }
    3774 
    3775     GetClientRect(infoPtr->hwndSelf, &rect);
    3776     InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
     3933    if (infoPtr->iGrabbedBand >= 0)
     3934    {
     3935        NMHDR layout;
     3936        RECT rect;
     3937
     3938        infoPtr->dragStart.x = 0;
     3939        infoPtr->dragStart.y = 0;
     3940        infoPtr->dragNow = infoPtr->dragStart;
     3941
     3942        ReleaseCapture ();
     3943
     3944        if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
     3945            REBAR_Notify(&layout, infoPtr, RBN_LAYOUTCHANGED);
     3946            REBAR_Notify_NMREBAR (infoPtr, infoPtr->iGrabbedBand, RBN_ENDDRAG);
     3947            infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
     3948        }
     3949
     3950        infoPtr->iGrabbedBand = -1;
     3951
     3952        GetClientRect(infoPtr->hwndSelf, &rect);
     3953        InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
     3954    }
    37773955
    37783956    return 0;
    37793957}
    37803958
     3959static LRESULT
     3960REBAR_MouseLeave (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3961{
     3962    if (infoPtr->ichevronhotBand >= 0)
     3963    {
     3964        REBAR_BAND *lpChevronBand = &infoPtr->bands[infoPtr->ichevronhotBand];
     3965        if (lpChevronBand->fDraw & DRAW_CHEVRONHOT)
     3966        {
     3967            lpChevronBand->fDraw &= ~DRAW_CHEVRONHOT;
     3968            InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
     3969        }
     3970    }
     3971    infoPtr->iOldBand = -1;
     3972    infoPtr->ichevronhotBand = -2;
     3973
     3974    return TRUE;
     3975}
    37813976
    37823977static LRESULT
    37833978REBAR_MouseMove (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
    37843979{
    3785     REBAR_BAND *band1, *band2;
     3980    REBAR_BAND *lpChevronBand;
    37863981    POINTS ptsmove;
    37873982
    3788     /* Validate entry as hit on Gripper has occurred */
    3789     if (GetCapture() != infoPtr->hwndSelf) return 0;
    3790     if (infoPtr->ihitBand == -1) return 0;
    3791 
    37923983    ptsmove = MAKEPOINTS(lParam);
    37933984
    3794     /* if mouse did not move much, exit */
    3795     if ((abs(ptsmove.x - infoPtr->dragNow.x) <= mindragx) &&
    3796         (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
    3797 
    3798     band1 = &infoPtr->bands[infoPtr->ihitBand-1];
    3799     band2 = &infoPtr->bands[infoPtr->ihitBand];
    3800 
    3801     /* Test for valid drag case - must not be first band in row */
    3802     if (infoPtr->dwStyle & CCS_VERT) {
    3803         if ((ptsmove.x < band2->rcBand.left) ||
    3804             (ptsmove.x > band2->rcBand.right) ||
    3805             ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
    3806             FIXME("Cannot drag to other rows yet!!\n");
    3807         }
    3808         else {
    3809             REBAR_HandleLRDrag (infoPtr, &ptsmove);
    3810         }
    3811     }
    3812     else {
    3813         if ((ptsmove.y < band2->rcBand.top) ||
    3814             (ptsmove.y > band2->rcBand.bottom) ||
    3815             ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
    3816             FIXME("Cannot drag to other rows yet!!\n");
    3817         }
    3818         else {
    3819             REBAR_HandleLRDrag (infoPtr, &ptsmove);
    3820         }
    3821     }
     3985    /* if we are currently dragging a band */
     3986    if (infoPtr->iGrabbedBand >= 0)
     3987    {
     3988        REBAR_BAND *band1, *band2;
     3989   
     3990        if (GetCapture() != infoPtr->hwndSelf)
     3991            ERR("We are dragging but haven't got capture?!?\n");
     3992
     3993        band1 = &infoPtr->bands[infoPtr->iGrabbedBand-1];
     3994        band2 = &infoPtr->bands[infoPtr->iGrabbedBand];
     3995
     3996        /* if mouse did not move much, exit */
     3997        if ((abs(ptsmove.x - infoPtr->dragNow.x) <= mindragx) &&
     3998            (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
     3999
     4000        /* Test for valid drag case - must not be first band in row */
     4001        if (infoPtr->dwStyle & CCS_VERT) {
     4002            if ((ptsmove.x < band2->rcBand.left) ||
     4003              (ptsmove.x > band2->rcBand.right) ||
     4004              ((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) {
     4005                FIXME("Cannot drag to other rows yet!!\n");
     4006            }
     4007            else {
     4008                REBAR_HandleLRDrag (infoPtr, &ptsmove);
     4009            }
     4010        }
     4011        else {
     4012            if ((ptsmove.y < band2->rcBand.top) ||
     4013              (ptsmove.y > band2->rcBand.bottom) ||
     4014              ((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) {
     4015                FIXME("Cannot drag to other rows yet!!\n");
     4016            }
     4017            else {
     4018                REBAR_HandleLRDrag (infoPtr, &ptsmove);
     4019            }
     4020        }
     4021    }
     4022    else
     4023    {
     4024        POINT ptMove;
     4025        INT iHitBand;
     4026        UINT htFlags;
     4027        TRACKMOUSEEVENT trackinfo;
     4028
     4029        ptMove.x = (INT)ptsmove.x;
     4030        ptMove.y = (INT)ptsmove.y;
     4031        REBAR_InternalHitTest(infoPtr, &ptMove, &htFlags, &iHitBand);
     4032
     4033        if (infoPtr->iOldBand >= 0 && infoPtr->iOldBand == infoPtr->ichevronhotBand)
     4034        {
     4035            lpChevronBand = &infoPtr->bands[infoPtr->ichevronhotBand];
     4036            if (lpChevronBand->fDraw & DRAW_CHEVRONHOT)
     4037            {
     4038                lpChevronBand->fDraw &= ~DRAW_CHEVRONHOT;
     4039                InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
     4040            }
     4041            infoPtr->ichevronhotBand = -2;
     4042        }
     4043
     4044        if (htFlags == RBHT_CHEVRON)
     4045        {
     4046            /* fill in the TRACKMOUSEEVENT struct */
     4047            trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
     4048            trackinfo.dwFlags = TME_QUERY;
     4049            trackinfo.hwndTrack = infoPtr->hwndSelf;
     4050            trackinfo.dwHoverTime = 0;
     4051
     4052            /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
     4053            _TrackMouseEvent(&trackinfo);
     4054
     4055            /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
     4056            if(!(trackinfo.dwFlags & TME_LEAVE))
     4057            {
     4058                trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
     4059
     4060                /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
     4061                /* and can properly deactivate the hot chevron */
     4062                _TrackMouseEvent(&trackinfo);
     4063            }
     4064
     4065            lpChevronBand = &infoPtr->bands[iHitBand];
     4066            if (!(lpChevronBand->fDraw & DRAW_CHEVRONHOT))
     4067            {
     4068                lpChevronBand->fDraw |= DRAW_CHEVRONHOT;
     4069                InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
     4070                infoPtr->ichevronhotBand = iHitBand;
     4071            }
     4072        }
     4073        infoPtr->iOldBand = iHitBand;
     4074    }
     4075
    38224076    return 0;
    38234077}
     
    38314085                    -GetSystemMetrics(SM_CYEDGE));
    38324086    }
    3833     TRACE("new client=(%d,%d)-(%d,%d)\n",
     4087    TRACE("new client=(%ld,%ld)-(%ld,%ld)\n",
    38344088          ((LPRECT)lParam)->left, ((LPRECT)lParam)->top,
    38354089          ((LPRECT)lParam)->right, ((LPRECT)lParam)->bottom);
     
    38564110        GetWindowRect(hwnd, &wnrc1);
    38574111        GetClientRect(hwnd, &clrc1);
    3858         TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
     4112        TRACE("window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) cs=(%d,%d %dx%d)\n",
    38594113              wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
    38604114              clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
     
    38634117
    38644118    /* allocate memory for info structure */
    3865     infoPtr = (REBAR_INFO *)COMCTL32_Alloc (sizeof(REBAR_INFO));
     4119    infoPtr = (REBAR_INFO *)Alloc (sizeof(REBAR_INFO));
    38664120    SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
    38674121
     
    38714125    infoPtr->clrBtnText = GetSysColor (COLOR_BTNTEXT);
    38724126    infoPtr->clrBtnFace = GetSysColor (COLOR_BTNFACE);
    3873     infoPtr->ihitBand = -1;
     4127    infoPtr->iOldBand = -1;
     4128    infoPtr->ichevronhotBand = -2;
     4129    infoPtr->iGrabbedBand = -1;
    38744130    infoPtr->hwndSelf = hwnd;
    38754131    infoPtr->DoRedraw = TRUE;
    3876     infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA);
    3877     infoPtr->hcurHorz  = LoadCursorA (0, IDC_SIZEWEA);
    3878     infoPtr->hcurVert  = LoadCursorA (0, IDC_SIZENSA);
    3879     infoPtr->hcurDrag  = LoadCursorA (0, IDC_SIZEA);
     4132    infoPtr->hcurArrow = LoadCursorA (0, (LPSTR)IDC_ARROWA);
     4133    infoPtr->hcurHorz  = LoadCursorA (0, (LPSTR)IDC_SIZEWEA);
     4134    infoPtr->hcurVert  = LoadCursorA (0, (LPSTR)IDC_SIZENSA);
     4135    infoPtr->hcurDrag  = LoadCursorA (0, (LPSTR)IDC_SIZEA);
    38804136    infoPtr->bUnicode = IsWindowUnicode (hwnd);
    38814137    infoPtr->fStatus = CREATE_RUNNING;
     
    39894245        GetWindowRect (infoPtr->hwndSelf, &rcWindow);
    39904246        OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
    3991         TRACE("rect (%d,%d)-(%d,%d)\n",
     4247        TRACE("rect (%ld,%ld)-(%ld,%ld)\n",
    39924248              rcWindow.left, rcWindow.top,
    39934249              rcWindow.right, rcWindow.bottom);
     
    40304286    hdc = wParam==0 ? BeginPaint (infoPtr->hwndSelf, &ps) : (HDC)wParam;
    40314287
    4032     TRACE("painting (%d,%d)-(%d,%d) client (%d,%d)-(%d,%d)\n",
     4288    TRACE("painting (%ld,%ld)-(%ld,%ld) client (%ld,%ld)-(%ld,%ld)\n",
    40334289          ps.rcPaint.left, ps.rcPaint.top,
    40344290          ps.rcPaint.right, ps.rcPaint.bottom,
     
    41554411        infoPtr->fStatus &= ~CREATE_RUNNING;
    41564412        GetWindowRect ( infoPtr->hwndSelf, &rcWin);
    4157         TRACE("win rect (%d,%d)-(%d,%d)\n",
     4413        TRACE("win rect (%ld,%ld)-(%ld,%ld)\n",
    41584414              rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
    41594415
     
    41624418            /* native control seems to do this */
    41634419            GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
    4164             TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n",
     4420            TRACE("sizing rebar, message and client zero, parent client (%ld,%ld)\n",
    41654421                  rcClient.right, rcClient.bottom);
    41664422        }
     
    41764432            /* do the actual WM_SIZE request */
    41774433            GetClientRect (infoPtr->hwndSelf, &rcClient);
    4178             TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
     4434            TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%ld,%ld)\n",
    41794435                  infoPtr->calcSize.cx, infoPtr->calcSize.cy,
    41804436                  LOWORD(lParam), HIWORD(lParam),
     
    41964452            /* native seems to use the current client rect for the size      */
    41974453            infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
    4198             TRACE("sizing rebar to client (%d,%d) size is zero but AUTOSIZE set\n",
     4454            TRACE("sizing rebar to client (%ld,%ld) size is zero but AUTOSIZE set\n",
    41994455                  rcClient.right, rcClient.bottom);
    42004456        }
    42014457        else {
    4202             TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
     4458#ifdef __WIN32OS2__
     4459            INT  width, x, y, height;
     4460            RECT parent_rect, rcWin;
     4461
     4462            if(HIWORD(lParam) != (rcClient.bottom - rcClient.top) ||
     4463               LOWORD(lParam) != (rcClient.right  - rcClient.left))
     4464            {
     4465                /* Need to resize width to match parent */
     4466                GetWindowRect ( infoPtr->hwndSelf, &rcWin);
     4467                height = (rcWin.bottom - rcWin.top);
     4468 
     4469                /* width and height don't apply */
     4470                GetClientRect (GetParent(infoPtr->hwndSelf), &parent_rect);
     4471                width = parent_rect.right - parent_rect.left;
     4472                TRACE("Rebar: resize to match parent");
     4473                SetWindowPos (infoPtr->hwndSelf, 0, 0, 0, width, height, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
     4474                return 0;;
     4475            }
     4476#endif
     4477            TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%ld,%ld)\n",
    42034478                  infoPtr->calcSize.cx, infoPtr->calcSize.cy,
    42044479                  LOWORD(lParam), HIWORD(lParam),
     
    42144489        autosize.rcActual = autosize.rcTarget;  /* ??? */
    42154490        REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
    4216         TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n",
     4491        TRACE("RBN_AUTOSIZE client=(%ld,%ld), lp=%08lx\n",
    42174492              autosize.rcTarget.right, autosize.rcTarget.bottom, lParam);
    42184493    }
     
    42554530                         wParam, lParam);
    42564531    GetWindowRect(infoPtr->hwndSelf, &rc);
    4257     TRACE("hwnd %p new pos (%d,%d)-(%d,%d)\n",
     4532    TRACE("hwnd %p new pos (%ld,%ld)-(%ld,%ld)\n",
    42584533          infoPtr->hwndSelf, rc.left, rc.top, rc.right, rc.bottom);
    42594534    return ret;
    42604535}
    42614536
     4537#ifdef __WIN32OS2__
     4538#ifdef DEBUG
     4539static void dprintfMsg(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
     4540{
     4541 char *msg = NULL;
     4542
     4543  switch (uMsg)
     4544  {
     4545  case RB_DELETEBAND:
     4546      msg = "RB_DELETEBAND";
     4547      break;
     4548  case RB_GETBANDBORDERS:
     4549      msg = "RB_GETBANDBORDERS";
     4550      break;
     4551  case RB_GETBANDCOUNT:
     4552      msg = "RB_GETBANDCOUNT";
     4553      break;
     4554  case RB_GETBANDINFO_OLD:
     4555      msg = "RB_GETBANDINFO_OLD";
     4556      break;
     4557  case RB_GETBANDINFOA:
     4558      msg = "RB_GETBANDINFOA";
     4559      break;
     4560  case RB_GETBANDINFOW:
     4561      msg = "RB_GETBANDINFOW";
     4562      break;
     4563  case RB_GETBARHEIGHT:
     4564      msg = "RB_GETBARHEIGHT";
     4565      break;
     4566  case RB_GETBARINFO:
     4567      msg = "RB_GETBARINFO";
     4568      break;
     4569  case RB_GETBKCOLOR:
     4570      msg = "RB_GETBKCOLOR";
     4571      break;
     4572  case RB_GETPALETTE:
     4573      msg = "RB_GETPALETTE";
     4574      break;
     4575  case RB_GETRECT:
     4576      msg = "RB_GETRECT";
     4577      break;
     4578  case RB_GETROWCOUNT:
     4579      msg = "RB_GETROWCOUNT";
     4580      break;
     4581  case RB_GETROWHEIGHT:
     4582      msg = "RB_GETROWHEIGHT";
     4583      break;
     4584  case RB_GETTEXTCOLOR:
     4585      msg = "RB_GETTEXTCOLOR";
     4586      break;
     4587  case RB_GETTOOLTIPS:
     4588      msg = "RB_GETTOOLTIPS";
     4589      break;
     4590  case RB_GETUNICODEFORMAT:
     4591      msg = "RB_GETUNICODEFORMAT";
     4592      break;
     4593  case CCM_GETVERSION:
     4594      msg = "CCM_GETVERSION";
     4595      break;
     4596  case RB_HITTEST:
     4597      msg = "RB_HITTEST";
     4598      break;
     4599  case RB_IDTOINDEX:
     4600      msg = "RB_IDTOINDEX";
     4601      break;
     4602  case RB_INSERTBANDA:
     4603      msg = "RB_INSERTBANDA";
     4604      break;
     4605  case RB_INSERTBANDW:
     4606      msg = "RB_INSERTBANDW";
     4607      break;
     4608  case RB_MAXIMIZEBAND:
     4609      msg = "RB_MAXIMIZEBAND";
     4610      break;
     4611  case RB_MINIMIZEBAND:
     4612      msg = "RB_MINIMIZEBAND";
     4613      break;
     4614  case RB_MOVEBAND:
     4615      msg = "RB_MOVEBAND";
     4616      break;
     4617  case RB_PUSHCHEVRON:
     4618      msg = "RB_PUSHCHEVRON";
     4619      break;
     4620  case RB_SETBANDINFOA:
     4621      msg = "RB_SETBANDINFOA";
     4622      break;
     4623  case RB_SETBANDINFOW:
     4624      msg = "RB_SETBANDINFOW";
     4625      break;
     4626  case RB_SETBARINFO:
     4627      msg = "RB_SETBARINFO";
     4628      break;
     4629  case RB_SETBKCOLOR:
     4630      msg = "RB_SETBKCOLOR";
     4631      break;
     4632  case RB_SETPARENT:
     4633      msg = "RB_SETPARENT";
     4634      break;
     4635  case RB_SETTEXTCOLOR:
     4636      msg = "RB_SETTEXTCOLOR";
     4637      break;
     4638  case RB_SETUNICODEFORMAT:
     4639      msg = "RB_SETUNICODEFORMAT";
     4640      break;
     4641  case CCM_SETVERSION:
     4642      msg = "CCM_SETVERSION";
     4643      break;
     4644  case RB_SHOWBAND:
     4645      msg = "RB_SHOWBAND";
     4646      break;
     4647  case RB_SIZETORECT:
     4648      msg = "RB_SIZETORECT";
     4649      break;
     4650/*      case RB_BEGINDRAG: */
     4651/*      case RB_DRAGMOVE: */
     4652/*      case RB_ENDDRAG: */
     4653/*      case RB_GETCOLORSCHEME: */
     4654/*      case RB_GETDROPTARGET: */
     4655/*      case RB_SETCOLORSCHEME: */
     4656/*      case RB_SETPALETTE: */
     4657/*          return REBAR_GetPalette (infoPtr, wParam, lParam); */
     4658/*      case RB_SETTOOLTIPS: */
     4659
     4660  default:
     4661      return;
     4662  }
     4663  dprintf(("Rebar %x %s %x %x", hwnd, msg, wParam, lParam));
     4664}
     4665#endif
     4666#endif //__WIN32OS2__
    42624667
    42634668static LRESULT WINAPI
     
    42664671    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    42674672
     4673#if defined(DEBUG) && defined(__WIN32OS2__)
     4674    dprintfMsg(hwnd, uMsg, wParam, lParam);
     4675#else
    42684676    TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
    4269           hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
     4677          hwnd, uMsg, wParam, lParam);
     4678#endif
    42704679    if (!infoPtr && (uMsg != WM_NCCREATE))
    42714680            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     
    42864695            return REBAR_GetBandCount (infoPtr);
    42874696
    4288         case RB_GETBANDINFO:    /* obsoleted after IE3, but we have to
    4289                                    support it anyway. */
     4697        case RB_GETBANDINFO_OLD:
    42904698        case RB_GETBANDINFOA:
    42914699            return REBAR_GetBandInfoA (infoPtr, wParam, lParam);
     
    43504758        case RB_MOVEBAND:
    43514759            return REBAR_MoveBand (infoPtr, wParam, lParam);
     4760
     4761        case RB_PUSHCHEVRON:
     4762            return REBAR_PushChevron (infoPtr, wParam, lParam);
    43524763
    43534764        case RB_SETBANDINFOA:
     
    44264837        case WM_MOUSEMOVE:
    44274838            return REBAR_MouseMove (infoPtr, wParam, lParam);
     4839
     4840        case WM_MOUSELEAVE:
     4841            return REBAR_MouseLeave (infoPtr, wParam, lParam);
    44284842
    44294843        case WM_NCCALCSIZE:
     
    45154929REBAR_Unregister (void)
    45164930{
    4517     UnregisterClassA (REBARCLASSNAMEA, (HINSTANCE)NULL);
    4518 }
     4931    UnregisterClassA (REBARCLASSNAMEA, NULL);
     4932}
  • trunk/src/comctl32/status.c

    r8526 r10535  
    2020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2121 *
    22  * FIXME:
    23  * 1) Implement all CCS_* styles.
    24  * 2) Should we hide grip if the parent window is maximized?
     22 * NOTE
     23 *
     24 * This code was audited for completeness against the documented features
     25 * of Comctl32.dll version 6.0 on Sep. 24, 2002, by Dimitrie O. Paun.
     26 *
     27 * Unless otherwise noted, we believe this code to be complete, as per
     28 * the specification mentioned above.
     29 * If you discover missing features, or bugs, please note them below.
     30 *
     31 * TODO:
     32 *      -- CCS_BOTTOM (default)
     33 *      -- CCS_LEFT
     34 *      -- CCS_NODEVIDER
     35 *      -- CCS_NOMOVEX
     36 *      -- CCS_NOMOVEY
     37 *      -- CCS_NOPARENTALIGN
     38 *      -- CCS_RIGHT
     39 *      -- CCS_TOP
     40 *      -- CCS_VERT (defaults to RIGHT)
    2541 */
    2642
     43#include <stdarg.h>
    2744#include <string.h>
    2845
     46#include "windef.h"
    2947#include "winbase.h"
    3048#include "wine/unicode.h"
     49#include "wingdi.h"
     50#include "winuser.h"
     51#include "winnls.h"
    3152#include "commctrl.h"
     53#include "comctl32.h"
    3254#include "wine/debug.h"
    3355
     
    4668{
    4769    HWND              Self;
     70    HWND              Notify;
    4871    WORD              numParts;
    4972    UINT              height;
     
    87110    INT i;
    88111
    89     TRACE("draw size grip %d,%d - %d,%d\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
     112    TRACE("draw size grip %ld,%ld - %ld,%ld\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
    90113
    91114    pt.x = lpRect->right - 1;
     
    125148
    126149
    127 static void 
     150static void
    128151STATUSBAR_DrawPart (HDC hdc, const STATUSWINDOWPART *part, const STATUSWINDOWINFO *infoPtr, int itemID)
    129152{
     
    131154    UINT border = BDR_SUNKENOUTER;
    132155
    133     TRACE("part bound %d,%d - %d,%d\n", r.left, r.top, r.right, r.bottom);
     156    TRACE("part bound %ld,%ld - %ld,%ld\n", r.left, r.top, r.right, r.bottom);
    134157    if (part->style & SBT_POPOUT)
    135158        border = BDR_RAISEDOUTER;
     
    138161
    139162    DrawEdge(hdc, &r, border, BF_RECT|BF_ADJUST);
    140        
     163
    141164    if (part->style & SBT_OWNERDRAW)
    142165        {
     
    149172            dis.rcItem = r;
    150173            dis.itemData = (INT)part->text;
    151             SendMessageW (GetParent (infoPtr->Self), WM_DRAWITEM,
    152                     (WPARAM)dis.CtlID, (LPARAM)&dis);
    153     }
     174            SendMessageW (infoPtr->Notify, WM_DRAWITEM, (WPARAM)dis.CtlID, (LPARAM)&dis);
     175    }
    154176    else
    155177        {
     
    158180                INT cy = r.bottom - r.top;
    159181
    160                 r.left += 2; 
     182                r.left += 2;
    161183                DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL);
    162184                r.left += cy;
     
    257279    /* get our window size */
    258280    GetClientRect (infoPtr->Self, &rect);
    259     TRACE("client wnd size is %d,%d - %d,%d\n", rect.left, rect.top, rect.right, rect.bottom);
     281    TRACE("client wnd size is %ld,%ld - %ld,%ld\n", rect.left, rect.top, rect.right, rect.bottom);
    260282
    261283    rect.top += VERT_BORDER;
     
    540562        RECT parent_rect;
    541563
    542         GetClientRect (GetParent (infoPtr->Self), &parent_rect);
     564        GetClientRect (infoPtr->Notify, &parent_rect);
    543565        infoPtr->height = height + VERT_BORDER;
    544566        width = parent_rect.right - parent_rect.left;
     
    568590        for (i = infoPtr->numParts ; i < oldNumParts; i++) {
    569591            if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW))
    570                 COMCTL32_Free (infoPtr->parts[i].text);
     592                Free (infoPtr->parts[i].text);
    571593        }
    572594    } else if (oldNumParts < infoPtr->numParts) {
    573         tmp = COMCTL32_Alloc (sizeof(STATUSWINDOWPART) * infoPtr->numParts);
     595        tmp = Alloc (sizeof(STATUSWINDOWPART) * infoPtr->numParts);
    574596        if (!tmp) return FALSE;
    575597        for (i = 0; i < oldNumParts; i++) {
     
    577599        }
    578600        if (infoPtr->parts)
    579             COMCTL32_Free (infoPtr->parts);
     601            Free (infoPtr->parts);
    580602        infoPtr->parts = tmp;
    581603    }
     
    587609            return TRUE;
    588610    }
    589    
     611
    590612    for (i = 0; i < infoPtr->numParts; i++)
    591613        infoPtr->parts[i].x = parts[i];
     
    626648
    627649static BOOL
    628 STATUSBAR_SetTextT (STATUSWINDOWINFO *infoPtr, INT nPart, WORD style, 
     650STATUSBAR_SetTextT (STATUSWINDOWINFO *infoPtr, INT nPart, WORD style,
    629651                    LPCWSTR text, BOOL isW)
    630652{
     
    632654    BOOL changed = FALSE;
    633655
    634     if (style & SBT_OWNERDRAW) {   
    635          TRACE("part %d, text %x\n",nPart,text);
     656    if (style & SBT_OWNERDRAW) {
     657         TRACE("part %d, text %p\n",nPart,text);
    636658    }
    637659    else TRACE("part %d, text %s\n", nPart, debugstr_t(text, isW));
     
    663685            LPCSTR atxt = (LPCSTR)text;
    664686            DWORD len = MultiByteToWideChar( CP_ACP, 0, atxt, -1, NULL, 0 );
    665             ntext = COMCTL32_Alloc( (len + 1)*sizeof(WCHAR) );
     687            ntext = Alloc( (len + 1)*sizeof(WCHAR) );
    666688            if (!ntext) return FALSE;
    667689            MultiByteToWideChar( CP_ACP, 0, atxt, -1, ntext, len );
    668690        } else if (text) {
    669             ntext = COMCTL32_Alloc( (strlenW(text) + 1)*sizeof(WCHAR) );
     691            ntext = Alloc( (strlenW(text) + 1)*sizeof(WCHAR) );
    670692            if (!ntext) return FALSE;
    671693            strcpyW (ntext, text);
     
    675697        if (text) {
    676698            if (!changed && part->text && !lstrcmpW(ntext, part->text)) {
    677                 if (!isW) COMCTL32_Free(ntext);
     699                if (!isW) Free(ntext);
    678700                return TRUE;
    679701            }
    680702        } else {
    681             if (!changed && !part->text) 
     703            if (!changed && !part->text)
    682704                return TRUE;
    683705        }
    684706
    685707        if (part->text)
    686             COMCTL32_Free (part->text);
     708            Free (part->text);
    687709        part->text = ntext;
    688710    }
     
    758780    nmhdr.idFrom = GetWindowLongW (infoPtr->Self, GWL_ID);
    759781    nmhdr.code = SBN_SIMPLEMODECHANGE;
    760     SendMessageW (GetParent (infoPtr->Self), WM_NOTIFY, 0, (LPARAM)&nmhdr);
     782    SendMessageW (infoPtr->Notify, WM_NOTIFY, 0, (LPARAM)&nmhdr);
    761783    InvalidateRect(infoPtr->Self, NULL, FALSE);
    762784    return TRUE;
     
    772794    for (i = 0; i < infoPtr->numParts; i++) {
    773795        if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW))
    774             COMCTL32_Free (infoPtr->parts[i].text);
     796            Free (infoPtr->parts[i].text);
    775797    }
    776798    if (infoPtr->part0.text && !(infoPtr->part0.style & SBT_OWNERDRAW))
    777         COMCTL32_Free (infoPtr->part0.text);
    778     COMCTL32_Free (infoPtr->parts);
     799        Free (infoPtr->part0.text);
     800    Free (infoPtr->parts);
    779801
    780802    /* delete default font */
     
    786808        DestroyWindow (infoPtr->hwndToolTip);
    787809
    788     COMCTL32_Free (infoPtr);
    789810    SetWindowLongW(infoPtr->Self, 0, 0);
     811    Free (infoPtr);
    790812    return 0;
    791813}
     
    803825
    804826    TRACE("\n");
    805     infoPtr = (STATUSWINDOWINFO*)COMCTL32_Alloc (sizeof(STATUSWINDOWINFO));
     827    infoPtr = (STATUSWINDOWINFO*)Alloc (sizeof(STATUSWINDOWINFO));
    806828    if (!infoPtr) goto create_fail;
    807829    SetWindowLongW (hwnd, 0, (DWORD)infoPtr);
    808830
    809831    infoPtr->Self = hwnd;
     832    infoPtr->Notify = lpCreate->hwndParent;
    810833    infoPtr->numParts = 1;
    811834    infoPtr->parts = 0;
     
    814837    infoPtr->hFont = 0;
    815838
    816     i = SendMessageW(GetParent (hwnd), WM_NOTIFYFORMAT, hwnd, NF_QUERY);
     839    i = SendMessageW(infoPtr->Notify, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
    817840    infoPtr->NtfUnicode = (i == NFR_UNICODE);
    818841
     
    834857
    835858    /* initialize first part */
    836     infoPtr->parts = COMCTL32_Alloc (sizeof(STATUSWINDOWPART));
     859    infoPtr->parts = Alloc (sizeof(STATUSWINDOWPART));
    837860    if (!infoPtr->parts) goto create_fail;
    838861    infoPtr->parts[0].bound = rect;
     
    846869        if (lpCreate->lpszName &&
    847870            (len = strlenW ((LPCWSTR)lpCreate->lpszName))) {
    848             infoPtr->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     871            infoPtr->parts[0].text = Alloc ((len + 1)*sizeof(WCHAR));
    849872            if (!infoPtr->parts[0].text) goto create_fail;
    850873            strcpyW (infoPtr->parts[0].text, (LPCWSTR)lpCreate->lpszName);
     
    855878            (len = strlen((LPCSTR)lpCreate->lpszName))) {
    856879            DWORD lenW = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1, NULL, 0 );
    857             infoPtr->parts[0].text = COMCTL32_Alloc (lenW*sizeof(WCHAR));
     880            infoPtr->parts[0].text = Alloc (lenW*sizeof(WCHAR));
    858881            if (!infoPtr->parts[0].text) goto create_fail;
    859882            MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1,
     
    871894#endif
    872895
    873     if ((hdc = GetDC (0))) {
     896    if ((hdc = GetDC (hwnd))) {
    874897        TEXTMETRICW tm;
    875898        HFONT hOldFont;
     
    879902        textHeight = tm.tmHeight;
    880903        SelectObject (hdc, hOldFont);
    881         ReleaseDC (0, hdc);
     904        ReleaseDC (hwnd, hdc);
    882905    }
    883906    TRACE("    textHeight=%d\n", textHeight);
     
    886909        infoPtr->hwndToolTip =
    887910            CreateWindowExW (0, TOOLTIPS_CLASSW, NULL, 0,
    888                                CW_USEDEFAULT, CW_USEDEFAULT,
    889                                CW_USEDEFAULT, CW_USEDEFAULT,
    890                              hwnd, 0,
    891                              GetWindowLongW (hwnd, GWL_HINSTANCE), NULL);
     911                             CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
     912                             CW_USEDEFAULT, hwnd, 0,
     913                             (HINSTANCE)GetWindowLongW(hwnd, GWL_HINSTANCE), NULL);
    892914
    893915        if (infoPtr->hwndToolTip) {
     
    901923            SendMessageW (lpCreate->hwndParent, WM_NOTIFY,
    902924                            (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
    903         } 
     925        }
    904926    }
    905927
    906928    if (!(dwStyle & CCS_NORESIZE)) { /* don't resize wnd if it doesn't want it ! */
    907         GetClientRect (GetParent (hwnd), &rect);
     929        GetClientRect (infoPtr->Notify, &rect);
    908930        width = rect.right - rect.left;
    909931        infoPtr->height = textHeight + 4 + VERT_BORDER;
     
    914936
    915937    return 0;
    916    
     938
    917939create_fail:
    918940    TRACE("    failed!\n");
     
    9931015{
    9941016    infoPtr->hFont = font;
    995     TRACE("%04x\n", infoPtr->hFont);
     1017    TRACE("%p\n", infoPtr->hFont);
    9961018    if (redraw)
    9971019        InvalidateRect(infoPtr->Self, NULL, FALSE);
     
    10141036    /* duplicate string */
    10151037    if (part->text)
    1016         COMCTL32_Free (part->text);
     1038        Free (part->text);
    10171039    part->text = 0;
    10181040    if (infoPtr->bUnicode) {
    10191041        if (text && (len = strlenW((LPCWSTR)text))) {
    1020             part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1042            part->text = Alloc ((len+1)*sizeof(WCHAR));
    10211043            if (!part->text) return FALSE;
    10221044            strcpyW (part->text, (LPCWSTR)text);
     
    10261048        if (text && (len = lstrlenA(text))) {
    10271049            DWORD lenW = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 );
    1028             part->text = COMCTL32_Alloc (lenW*sizeof(WCHAR));
     1050            part->text = Alloc (lenW*sizeof(WCHAR));
    10291051            if (!part->text) return FALSE;
    10301052            MultiByteToWideChar( CP_ACP, 0, text, -1, part->text, lenW );
     
    10391061
    10401062static BOOL
     1063#ifdef __WIN32OS2__
     1064STATUSBAR_WMSize (STATUSWINDOWINFO *infoPtr, WORD flags, LPARAM lParam)
     1065#else
    10411066STATUSBAR_WMSize (STATUSWINDOWINFO *infoPtr, WORD flags)
     1067#endif
    10421068{
    10431069    INT  width, x, y;
     
    10471073    TRACE("flags %04x\n", flags);
    10481074
    1049     if (flags != SIZE_RESTORED) {
    1050         WARN("flags MUST be SIZE_RESTORED\n");
     1075    if (flags != SIZE_RESTORED && flags != SIZE_MAXIMIZED)
     1076    {
     1077        WARN("flags MUST be SIZE_RESTORED or SIZE_MAXIMIZED\n");
    10511078        return FALSE;
    10521079    }
     1080
    10531081#ifdef __WIN32OS2__
    10541082    if (GetWindowLongW(infoPtr->Self, GWL_STYLE) & CCS_NORESIZE) {
     
    10571085        return FALSE;
    10581086    }
     1087
     1088    /* Invalidate the window if we need to draw a size grip */
     1089    /* TODO: The size grip area would be sufficient though */
     1090    if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP)
     1091    {
     1092        RECT rcWin;
     1093
     1094        GetClientRect(infoPtr->Self, &rcWin);
     1095        if(HIWORD(lParam) != (rcWin.bottom - rcWin.top) ||
     1096           LOWORD(lParam) != (rcWin.right  - rcWin.left))
     1097        {
     1098            TRACE("SBARS_SIZEGRIP && height/width changed -> invalidate window");
     1099            InvalidateRect(infoPtr->Self,NULL,TRUE);
     1100        }
     1101    }
    10591102#else
    10601103    if (GetWindowLongW(infoPtr->Self, GWL_STYLE) & CCS_NORESIZE) return FALSE;
     
    10621105
    10631106    /* width and height don't apply */
    1064     GetClientRect (GetParent(infoPtr->Self), &parent_rect);
     1107    GetClientRect (infoPtr->Notify, &parent_rect);
    10651108    width = parent_rect.right - parent_rect.left;
    10661109    x = parent_rect.left;
    10671110    y = parent_rect.bottom - infoPtr->height;
    1068     MoveWindow (infoPtr->Self, parent_rect.left, 
     1111    MoveWindow (infoPtr->Self, parent_rect.left,
    10691112                parent_rect.bottom - infoPtr->height,
    10701113                width, infoPtr->height, TRUE);
     
    10741117
    10751118
    1076 static LRESULT 
     1119static LRESULT
    10771120STATUSBAR_NotifyFormat (STATUSWINDOWINFO *infoPtr, HWND from, INT cmd)
    10781121{
    10791122    if (cmd == NF_REQUERY) {
    1080         INT i = SendMessageW(from, WM_NOTIFYFORMAT, infoPtr->Self, NF_QUERY);
     1123        INT i = SendMessageW(from, WM_NOTIFYFORMAT, (WPARAM)infoPtr->Self, NF_QUERY);
    10811124        infoPtr->NtfUnicode = (i == NFR_UNICODE);
    10821125    }
     
    10881131STATUSBAR_SendNotify (HWND hwnd, UINT code)
    10891132{
     1133    STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr(hwnd);
    10901134    NMHDR  nmhdr;
    10911135
     
    10941138    nmhdr.idFrom = GetWindowLongW (hwnd, GWL_ID);
    10951139    nmhdr.code = code;
    1096     SendMessageW (GetParent (hwnd), WM_NOTIFY, 0, (LPARAM)&nmhdr);
     1140    SendMessageW (infoPtr->Notify, WM_NOTIFY, 0, (LPARAM)&nmhdr);
    10971141    return 0;
    10981142}
     
    11071151    LRESULT res;
    11081152
    1109     TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, msg, wParam, lParam);
     1153    TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hwnd, msg, wParam, lParam);
    11101154    if (!infoPtr && msg != WM_CREATE)
    11111155        return DefWindowProcW (hwnd, msg, wParam, lParam);
     
    11161160
    11171161        case SB_GETICON:
    1118             return STATUSBAR_GetIcon (infoPtr, nPart);
     1162            return (LRESULT)STATUSBAR_GetIcon (infoPtr, nPart);
    11191163
    11201164        case SB_GETPARTS:
     
    11551199            return STATUSBAR_SetMinHeight (infoPtr, (INT)wParam);
    11561200
    1157         case SB_SETPARTS:       
     1201        case SB_SETPARTS:
    11581202            return STATUSBAR_SetParts (infoPtr, (INT)wParam, (LPINT)lParam);
    11591203
     
    11831227
    11841228        case WM_GETFONT:
    1185             return infoPtr->hFont? infoPtr->hFont : infoPtr->hDefaultFont;
     1229            return (LRESULT)(infoPtr->hFont? infoPtr->hFont : infoPtr->hDefaultFont);
    11861230
    11871231        case WM_GETTEXT:
     
    12081252        case WM_NCLBUTTONUP:
    12091253        case WM_NCLBUTTONDOWN:
    1210             PostMessageW (GetParent (hwnd), msg, wParam, lParam);
     1254            PostMessageW (infoPtr->Notify, msg, wParam, lParam);
    12111255            return 0;
    12121256
    12131257        case WM_NOTIFYFORMAT:
    12141258            return STATUSBAR_NotifyFormat(infoPtr, (HWND)wParam, (INT)lParam);
    1215            
     1259
    12161260        case WM_PAINT:
    12171261            return STATUSBAR_WMPaint (infoPtr, (HDC)wParam);
     
    12301274
    12311275        case WM_SIZE:
     1276#ifdef __WIN32OS2__
     1277            if (STATUSBAR_WMSize (infoPtr, (WORD)wParam, lParam)) return 0;
     1278#else
    12321279            if (STATUSBAR_WMSize (infoPtr, (WORD)wParam)) return 0;
     1280#endif
    12331281            return DefWindowProcW (hwnd, msg, wParam, lParam);
    12341282
    12351283        default:
    1236             if (msg >= WM_USER)
     1284            if ((msg >= WM_USER) && (msg < WM_APP))
    12371285                ERR("unknown msg %04x wp=%04x lp=%08lx\n",
    12381286                     msg, wParam, lParam);
     
    12591307    wndClass.cbClsExtra    = 0;
    12601308    wndClass.cbWndExtra    = sizeof(STATUSWINDOWINFO *);
    1261     wndClass.hCursor       = LoadCursorW (0, IDC_ARROWW);
     1309    wndClass.hCursor       = LoadCursorW (0, (LPWSTR)IDC_ARROWW);
    12621310    wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
    12631311    wndClass.lpszClassName = STATUSCLASSNAMEW;
    1264  
     1312
    12651313    RegisterClassW (&wndClass);
    12661314}
     
    12761324STATUS_Unregister (void)
    12771325{
    1278     UnregisterClassW (STATUSCLASSNAMEW, (HINSTANCE)NULL);
    1279 }
    1280 
     1326    UnregisterClassW (STATUSCLASSNAMEW, NULL);
     1327}
  • trunk/src/comctl32/toolbar.c

    r10098 r10535  
    1919 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2020 *
     21 * NOTES
     22 *
    2123 *  Differences between MSDN and actual native control operation:
    2224 *   1. MSDN says: "TBSTYLE_LIST: Creates a flat toolbar with button text
     
    2830 *      *not* imply TBSTYLE_FLAT as documented.  (GA 8/2001)
    2931 *
    30  *
     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 *
    3139 * TODO:
    3240 *   - Button wrapping (under construction).
    33  *   - Messages.
    34  *   - Notifications (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
    3562 *   - Fix TB_SETROWS.
    36  *   - Tooltip support (almost complete).
    37  *   - Unicode suppport (under construction).
    3863 *   - Fix TOOLBAR_SetButtonInfo32A/W.
    39  *   - TBSTYLE_AUTOSIZE for toolbar and buttons.
    40  *   - I_IMAGECALLBACK support.
    41  *   - iString of -1 is undocumented
     64 *   - iListGap custom draw support.
    4265 *   - Customization dialog:
    43  *      - Add flat look.
    4466 *      - Minor buglet in 'available buttons' list:
    45  *        Buttons are not listed in M$-like order. M$ seems to use a single
     67 *        Buttons are not listed in MS-like order. MS seems to use a single
    4668 *        internal list to store the button information of both listboxes.
    4769 *      - Drag list support.
    48  *      - Help and Reset button support.
    4970 *
    5071 * Testing:
     
    5980 */
    6081
     82#include <stdarg.h>
    6183#include <string.h>
    6284
     85#include "windef.h"
    6386#include "winbase.h"
    64 #include "windef.h"
    6587#include "wingdi.h"
    6688#include "winuser.h"
    6789#include "wine/unicode.h"
     90#include "winnls.h"
    6891#include "commctrl.h"
    6992#include "imagelist.h"
     
    105128    INT      nHeight;        /* height of the toolbar */
    106129    INT      nWidth;         /* width of the toolbar */
     130    RECT     client_rect;
    107131    INT      nButtonHeight;
    108132    INT      nButtonWidth;
     
    127151    DWORD    dwItemCDFlag;    /* TBCDRF_ flags from last ITEMPREPAINT    */
    128152    SIZE     szPadding;       /* padding values around button */
     153    INT      iListGap;        /* default gap between text and image for toolbar with list style */
    129154    HFONT    hDefaultFont;
    130155    HFONT    hFont;           /* text font */
     
    153178    RECT     rcBound;         /* bounding rectangle */
    154179    INT      iVersion;
    155 
     180    LPWSTR   pszTooltipText;    /* temporary store for a string > 80 characters
     181                                 * for TTN_GETDISPINFOW notification */
    156182    TBUTTON_INFO *buttons;      /* pointer to button array */
    157183    LPWSTR       *strings;      /* pointer to string array */
     
    175201} CUSTOMBUTTON, *PCUSTOMBUTTON;
    176202
     203typedef enum
     204{
     205    IMAGE_LIST_DEFAULT,
     206    IMAGE_LIST_HOT,
     207    IMAGE_LIST_DISABLED
     208} IMAGE_LIST_TYPE;
    177209
    178210#define SEPARATOR_WIDTH    8
     
    180212#define BOTTOM_BORDER      2
    181213#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
    182221
    183222#define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
    184223#define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
    185224#define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
     225
     226#ifdef __WIN32OS2__
     227static inline const char *wine_dbgstr_rect( const RECT *rect )
     228{
     229    return "rect (null)";
     230}
     231#endif
     232
     233static inline int TOOLBAR_GetListTextOffset(TOOLBAR_INFO *infoPtr, INT iListGap)
     234{
     235    return GetSystemMetrics(SM_CXEDGE) + iListGap - infoPtr->szPadding.cx/2;
     236}
    186237
    187238/* Used to find undocumented extended styles */
     
    355406
    356407/***********************************************************************
    357 *               TOOLBAR_DrawImageList
     408*               TOOLBAR_GetImageListForDrawing
    358409*
    359410* This function validates the bitmap index (including I_IMAGECALLBACK
    360 * functionality). It then draws the image via the ImageList_Draw
    361 * function. It returns TRUE if the image was drawn, FALSE otherwise.
     411* functionality) and returns the corresponding image list.
     412*/
     413static HIMAGELIST
     414TOOLBAR_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.
    362461*/
    363462static BOOL
    364 TOOLBAR_DrawImageList (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl,
    365                         HDC hdc, UINT left, UINT top, UINT draw_flags)
     463TOOLBAR_TestImageExist (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl)
    366464{
    367465    INT index;
     
    383481        return FALSE;
    384482    }
    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 */
    399 static BOOL
    400 TOOLBAR_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     }
    420483    return TRUE;
    421484}
     
    453516*               TOOLBAR_DrawDDFlatSeparator
    454517*
    455 * This function draws the separator that was flaged as TBSTYLE_DROPDOWN.
     518* This function draws the separator that was flagged as BTNS_DROPDOWN.
    456519* In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
    457520* followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
     
    495558
    496559static void
    497 TOOLBAR_DrawArrow (HDC hdc, INT left, INT top, INT colorRef)
     560TOOLBAR_DrawArrow (HDC hdc, INT left, INT top, COLORREF clr)
    498561{
    499562    INT x, y;
    500563    HPEN hPen, hOldPen;
    501564
    502     if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
     565    if (!(hPen = CreatePen( PS_SOLID, 1, clr))) return;
    503566    hOldPen = SelectObject ( hdc, hPen );
    504567    x = left + 2;
    505     y = top + 8;
     568    y = top;
    506569    MoveToEx (hdc, x, y, NULL);
    507570    LineTo (hdc, x+5, y++); x++;
     
    521584 */
    522585static void
    523 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
    524                     HDC hdc, INT nState, DWORD dwStyle,
    525                     RECT *rcText, LPWSTR lpText, NMTBCUSTOMDRAW *tbcd)
    526 {
     586TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, RECT *rcText, LPWSTR lpText,
     587                    NMTBCUSTOMDRAW *tbcd)
     588{
     589    HDC hdc = tbcd->nmcd.hdc;
    527590    HFONT  hOldFont = 0;
    528591    COLORREF clrOld = 0;
     592    COLORREF clrOldBk = 0;
     593    int oldBkMode = 0;
     594    UINT state = tbcd->nmcd.uItemState;
    529595
    530596    /* draw text */
    531597    if (lpText) {
    532         TRACE("string rect=(%ld,%ld)-(%ld,%ld)\n",
     598        TRACE("string=%s rect=(%ld,%ld)-(%ld,%ld)\n", debugstr_w(lpText),
    533599              rcText->left, rcText->top, rcText->right, rcText->bottom);
    534600
    535601        hOldFont = SelectObject (hdc, infoPtr->hFont);
    536         if (!(nState & TBSTATE_ENABLED)) {
     602        if ((state & CDIS_HOT) && (infoPtr->dwItemCDFlag & TBCDRF_HILITEHOTTRACK )) {
     603            clrOld = SetTextColor (hdc, tbcd->clrTextHighlight);
     604        }
     605        else if (state & CDIS_DISABLED) {
    537606            clrOld = SetTextColor (hdc, tbcd->clrBtnHighlight);
    538607            OffsetRect (rcText, 1, 1);
     
    541610            OffsetRect (rcText, -1, -1);
    542611        }
    543         else if (nState & TBSTATE_INDETERMINATE) {
     612        else if (state & CDIS_INDETERMINATE) {
    544613            clrOld = SetTextColor (hdc, comctl32_color.clr3dShadow);
    545614        }
    546         else if (btnPtr->bHot && (infoPtr->dwItemCDFlag & TBCDRF_HILITEHOTTRACK )) {
     615        else if ((state & CDIS_MARKED) && !(infoPtr->dwItemCDFlag & TBCDRF_NOMARK)) {
    547616            clrOld = SetTextColor (hdc, tbcd->clrTextHighlight);
     617            clrOldBk = SetBkColor (hdc, tbcd->clrMark);
     618            oldBkMode = SetBkMode (hdc, OPAQUE); /* FIXME: should this be in the NMTBCUSTOMDRAW structure? */
    548619        }
    549620        else {
     
    553624        DrawTextW (hdc, lpText, -1, rcText, infoPtr->dwDTFlags);
    554625        SetTextColor (hdc, clrOld);
     626        if ((state & CDIS_MARKED) && !(infoPtr->dwItemCDFlag & TBCDRF_NOMARK))
     627        {
     628            SetBkColor (hdc, clrOldBk);
     629            SetBkMode (hdc, oldBkMode);
     630        }
    555631        SelectObject (hdc, hOldFont);
    556632    }
     
    559635
    560636static void
    561 TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
    562 {
    563     HBRUSH hbr = SelectObject (hdc, COMCTL32_hPattern55AABrush);
     637TOOLBAR_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;
    564643    INT cx = lpRect->right - lpRect->left;
    565644    INT cy = lpRect->bottom - lpRect->top;
    566     PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
     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);
    567650    SelectObject (hdc, hbr);
    568651}
    569652
    570653
    571 static void
    572 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
    573                     HDC hdc, INT x, INT y)
     654static void TOOLBAR_DrawMasked(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
     655                               HDC hdc, INT x, INT y)
    574656{
    575657    HIMAGELIST himl = GETDEFIMAGELIST(infoPtr, 0);
    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);
     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    }
    604699}
    605700
     
    621716}
    622717
    623 
     718/* draws the image on a toolbar button */
     719static void
     720TOOLBAR_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 */
     763static void
     764TOOLBAR_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
     797static void
     798TOOLBAR_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 */
    624834static void
    625835TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
     
    627837    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    628838    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    629     BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) &&
    630                             (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
    631     RECT rc, rcArrow, rcBitmap, rcText, rcFill;
     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;
    632845    LPWSTR lpText = NULL;
    633846    NMTBCUSTOMDRAW tbcd;
    634847    DWORD ntfret;
    635848    INT offset;
    636     HIMAGELIST himlDef;
    637 
    638     if (btnPtr->fsState & TBSTATE_HIDDEN)
    639         return;
    640849
    641850    rc = btnPtr->rect;
    642     CopyRect (&rcFill, &rc);
    643851    CopyRect (&rcArrow, &rc);
    644852    CopyRect(&rcBitmap, &rc);
    645     CopyRect(&rcText, &rc);
    646853
    647854    /* get a pointer to the text */
     
    650857    if (hasDropDownArrow)
    651858    {
    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     }
     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);
    658876
    659877    /* Center the bitmap horizontally and vertically */
    660878    if (dwStyle & TBSTYLE_LIST)
    661         rcBitmap.left += 3;
     879        rcBitmap.left += GetSystemMetrics(SM_CXEDGE) + OFFSET_X;
    662880    else
    663         rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2;
     881        rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2;
    664882
    665883    if(lpText)
    666         rcBitmap.top+=2; /* this looks to be the correct value from vmware comparison - cmm */
     884        rcBitmap.top+= GetSystemMetrics(SM_CYEDGE) + OFFSET_Y;
    667885    else
    668886        rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2;
    669887
    670888    TRACE("iBitmap: %d, start=(%ld,%ld) w=%d, h=%d\n",
    671           btnPtr->iBitmap, rcBitmap.left, rcBitmap.top,
    672           infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
     889      btnPtr->iBitmap, rcBitmap.left, rcBitmap.top,
     890      infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
    673891    TRACE ("iString: %x\n", btnPtr->iString);
    674892    TRACE ("Stringtext: %s\n", debugstr_w(lpText));
     
    676894    /* draw text */
    677895    if (lpText) {
    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 */
     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 */
    712917    ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
    713918    tbcd.clrText = comctl32_color.clrBtnText;
     
    719924    tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
    720925    tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
    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.                      */
     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. */
    726931    tbcd.rcText.left = 0;
    727932    tbcd.rcText.top = 0;
    728933    tbcd.rcText.right = rcText.right - rc.left;
    729934    tbcd.rcText.bottom = rcText.bottom - rc.top;
    730 
    731     /* FIXME: what should these be set to ????? */
    732     tbcd.hbrMonoDither = 0;
     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? */
    733941    tbcd.hbrLines = 0;
    734942    tbcd.hpenLines = 0;
     
    740948    {
    741949        tbcd.nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
    742         tbcd.nmcd.hdc = hdc;
    743         tbcd.nmcd.rc = rc;
    744950        tbcd.nmcd.dwItemSpec = btnPtr->idCommand;
    745         tbcd.nmcd.uItemState = TOOLBAR_TranslateState(btnPtr);
    746951        tbcd.nmcd.lItemlParam = btnPtr->dwData;
    747952        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
    748957        infoPtr->dwItemCustDraw = ntfret & 0xffff;
    749958        infoPtr->dwItemCDFlag = ntfret & 0xffff0000;
     
    755964    }
    756965
    757     if (!infoPtr->bBtnTranspnt)
    758         FillRect( hdc, &rcFill, GetSysColorBrush(COLOR_BTNFACE));
    759 
    760966    /* separator */
    761     if (btnPtr->fsStyle & TBSTYLE_SEP) {
     967    if (btnPtr->fsStyle & BTNS_SEP) {
    762968        /* with the FLAT style, iBitmap is the width and has already */
    763969        /* been taken into consideration in calculating the width    */
     
    766972        /* when drawing the vertical bar...      */
    767973        if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) {
    768             if (btnPtr->fsStyle & TBSTYLE_DROPDOWN)
     974            if (btnPtr->fsStyle & BTNS_DROPDOWN)
    769975                TOOLBAR_DrawDDFlatSeparator (&rc, hdc, btnPtr, infoPtr);
    770976            else
    771977                TOOLBAR_DrawFlatSeparator (&rc, hdc, infoPtr);
    772978        }
    773         else if (btnPtr->fsStyle != TBSTYLE_SEP) {
     979        else if (btnPtr->fsStyle != BTNS_SEP) {
    774980            FIXME("Draw some kind of separator: fsStyle=%x\n",
    775981                  btnPtr->fsStyle);
     
    778984    }
    779985
    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);
     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))
     991    {
     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);
    790998            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)
     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)
    8771015    {
    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));
    907             if (hasDropDownArrow)
    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
    933     {
    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:
     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
     1030FINALNOTIFY:
    9541031    if (infoPtr->dwItemCustDraw & CDRF_NOTIFYPOSTPAINT)
    9551032    {
     
    9751052    TBUTTON_INFO *btnPtr;
    9761053    INT i, oldBKmode = 0;
    977     RECT rcTemp;
     1054    RECT rcTemp, rcClient;
    9781055    NMTBCUSTOMDRAW tbcd;
    9791056    DWORD ntfret;
     1057
     1058    /* the app has told us not to redraw the toolbar */
     1059    if (!infoPtr->bDoRedraw)
     1060        return;
    9801061
    9811062    /* if imagelist belongs to the app, it can be changed
     
    10011082        oldBKmode = SetBkMode (hdc, TRANSPARENT);
    10021083
     1084    GetClientRect(hwnd, &rcClient);
     1085
    10031086    /* redraw necessary buttons */
    10041087    btnPtr = infoPtr->buttons;
    10051088    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
    10061089    {
    1007         if(IntersectRect(&rcTemp, &(ps->rcPaint), &(btnPtr->rect)))
     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)
    10081101            TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
    10091102    }
     
    10321125* indicates where the underline goes, except for the string "&&" which
    10331126* is reduced to a single "&". GetTextExtentPoint does not process these
    1034 * only DrawText does. Note that the TBSTYLE_NOPREFIX is handled here.
     1127* only DrawText does. Note that the BTNS_NOPREFIX is handled here.
    10351128*/
    10361129static void
     
    10431136    lpSize->cy = 0;
    10441137
    1045     if (!(btnPtr->fsState & TBSTATE_HIDDEN) )
     1138    if (infoPtr->nMaxTextRows > 0 &&
     1139        !(btnPtr->fsState & TBSTATE_HIDDEN) &&
     1140        (!(infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) ||
     1141        (btnPtr->fsStyle & BTNS_SHOWTEXT)) )
    10461142    {
    10471143        LPWSTR lpText = TOOLBAR_GetText(infoPtr, btnPtr);
     
    10581154            /* Use DrawText to get true size as drawn (less pesky "&") */
    10591155            DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE |
    1060                    DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ?
     1156                   DT_CALCRECT | ((btnPtr->fsStyle & BTNS_NOPREFIX) ?
    10611157                                  DT_NOPREFIX : 0));
    10621158
     
    10881184    lpSize->cx = 0;
    10891185    lpSize->cy = 0;
     1186
     1187    if(infoPtr->nMaxTextRows == 0)
     1188        return;
    10901189
    10911190    hdc = GetDC (hwnd);
     
    11131212*               TOOLBAR_WrapToolbar
    11141213*
    1115 * This function walks through the buttons and seperators in the
     1214* This function walks through the buttons and separators in the
    11161215* toolbar, and sets the TBSTATE_WRAP flag only on those items where
    11171216* wrapping should occur based on the width of the toolbar window.
     
    11671266        /* custom controls in toolbars.                              */
    11681267        /*                                                           */
    1169         /* TBSTYLE_DROPDOWN separators are treated as buttons for    */
     1268        /* BTNS_DROPDOWN separators are treated as buttons for    */
    11701269        /* width.  - GA 8/01                                         */
    1171         if ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
    1172             !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN))
     1270        if ((btnPtr[i].fsStyle & BTNS_SEP) &&
     1271            !(btnPtr[i].fsStyle & BTNS_DROPDOWN))
    11731272            cx = (btnPtr[i].iBitmap > 0) ?
    11741273                        btnPtr[i].iBitmap : SEPARATOR_WIDTH;
     
    11801279        /* next row if the previous wrapping is on a button.         */
    11811280        if( bButtonWrap &&
    1182                 (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
     1281                (btnPtr[i].fsStyle & BTNS_SEP) &&
    11831282                (i + 1 < infoPtr->nNumButtons ) &&
    1184                 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
     1283                (btnPtr[i + 1].fsStyle & BTNS_SEP) )
    11851284        {
    11861285            TRACE("wrap point 1 btn %d style %02x\n", i, btnPtr[i].fsStyle);
     
    12041303            /*  go to the next until it reaches a non separator.      */
    12051304            /*  Wrap the last separator if it is before a button.     */
    1206             while( ( ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
    1207                       !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN)) ||
     1305            while( ( ((btnPtr[i].fsStyle & BTNS_SEP) &&
     1306                      !(btnPtr[i].fsStyle & BTNS_DROPDOWN)) ||
    12081307                     (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
    12091308                        i < infoPtr->nNumButtons )
     
    12301329            for ( j = i - 1; j >= 0  &&  !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
    12311330            {
    1232                 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
     1331                if ((btnPtr[j].fsStyle & BTNS_SEP) &&
    12331332                        !(btnPtr[j].fsState & TBSTATE_HIDDEN))
    12341333                {
     
    12731372                bFound = TRUE;
    12741373                x = infoPtr->nIndent;
    1275                 if (btnPtr[i].fsStyle & TBSTYLE_SEP )
     1374                if (btnPtr[i].fsStyle & BTNS_SEP )
    12761375                    bButtonWrap = FALSE;
    12771376                else
     
    13141413    TOOLBAR_CalcStrings (hwnd, &sizeString);
    13151414
     1415    TOOLBAR_DumpToolbar (infoPtr, __LINE__);
     1416
    13161417    for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
    13171418    {
     
    13241425                                     0, sizeString.cy) + infoPtr->szPadding.cy;
    13251426        infoPtr->nButtonWidth = ((usesBitmaps) ? infoPtr->nBitmapWidth :
    1326                                  0) + sizeString.cx + 6;
     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;
    13271430        TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n",
    13281431              infoPtr->nButtonWidth, infoPtr->nButtonHeight, usesBitmaps,
    13291432              infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
    1330         TOOLBAR_DumpToolbar (infoPtr, __LINE__);
    13311433    }
    13321434    else {
     
    13351437            if (usesBitmaps)
    13361438                infoPtr->nButtonHeight = sizeString.cy +
    1337                     2 + /* this is the space to separate text from bitmap */
    1338                   infoPtr->nBitmapHeight + 6;
     1439                    infoPtr->szPadding.cy/2 + /* this is the space to separate text from bitmap */
     1440                  infoPtr->nBitmapHeight + infoPtr->szPadding.cy;
    13391441            else
    1340                 infoPtr->nButtonHeight = sizeString.cy + 6;
     1442                infoPtr->nButtonHeight = sizeString.cy + infoPtr->szPadding.cy;
    13411443        }
    1342         else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
    1343             infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
     1444        else
     1445            infoPtr->nButtonHeight = infoPtr->nBitmapHeight + infoPtr->szPadding.cy;
    13441446
    13451447        if (sizeString.cx > infoPtr->nBitmapWidth)
    1346             infoPtr->nButtonWidth = sizeString.cx + 6;
    1347         else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
    1348             infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
     1448            infoPtr->nButtonWidth = sizeString.cx + infoPtr->szPadding.cx;
     1449        else
     1450            infoPtr->nButtonWidth = infoPtr->nBitmapWidth + infoPtr->szPadding.cx;
    13491451    }
    13501452
     
    13591461    y  = 0;
    13601462
    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 
    13721463    /* from above, minimum is a button, and possible text */
    13731464    cx = infoPtr->nButtonWidth;
     
    13871478
    13881479    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; */
    13951480
    13961481    TRACE("cy=%d\n", cy);
     
    14101495        /* it is the actual width of the separator. This is used for */
    14111496        /* custom controls in toolbars.                              */
    1412         if (btnPtr->fsStyle & TBSTYLE_SEP) {
    1413             if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) {
     1497        if (btnPtr->fsStyle & BTNS_SEP) {
     1498            if (btnPtr->fsStyle & BTNS_DROPDOWN) {
    14141499                cy = (btnPtr->iBitmap > 0) ?
    14151500                     btnPtr->iBitmap : SEPARATOR_WIDTH;
     
    14221507        else
    14231508        {
    1424             if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE)
     1509            if ((infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) ||
     1510                (btnPtr->fsStyle & BTNS_AUTOSIZE))
    14251511            {
    14261512              SIZE sz;
     
    14361522              ReleaseDC (hwnd, hdc);
    14371523
    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;
     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;
    14441540            }
    14451541            else
    14461542              cx = infoPtr->nButtonWidth;
    14471543
    1448             if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN))
     1544            if ((hasDropDownArrows && (btnPtr->fsStyle & BTNS_DROPDOWN)) || (btnPtr->fsStyle & BTNS_WHOLEDROPDOWN))
    14491545              cx += DDARROW_WIDTH;
    14501546        }
     
    14621558
    14631559        /* Set the toolTip only for non-hidden, non-separator button */
    1464         if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
     1560        if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & BTNS_SEP ))
    14651561        {
    14661562            TTTOOLINFOA ti;
     
    14851581        if( bWrap )
    14861582        {
    1487             if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
     1583            if ( !(btnPtr->fsStyle & BTNS_SEP) )
    14881584                y += cy;
    14891585            else
     
    14921588                /* it is the actual width of the separator. This is used for */
    14931589                /* custom controls in toolbars.                              */
    1494                 if ( !(btnPtr->fsStyle & TBSTYLE_DROPDOWN))
     1590                if ( !(btnPtr->fsStyle & BTNS_DROPDOWN))
    14951591                    y += cy + ( (btnPtr->iBitmap > 0 ) ?
    14961592                                btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
     
    15521648            continue;
    15531649
    1554         if (btnPtr->fsStyle & TBSTYLE_SEP) {
     1650        if (btnPtr->fsStyle & BTNS_SEP) {
    15551651            if (PtInRect (&btnPtr->rect, *lpPt)) {
    15561652                TRACE(" ON SEPARATOR %d!\n", i);
     
    16051701    /* check index button */
    16061702    btnPtr = &infoPtr->buttons[nIndex];
    1607     if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
     1703    if ((btnPtr->fsStyle & BTNS_CHECKGROUP) == BTNS_CHECKGROUP) {
    16081704        if (btnPtr->fsState & TBSTATE_CHECKED)
    16091705            return nIndex;
     
    16141710    while (nRunIndex >= 0) {
    16151711        btnPtr = &infoPtr->buttons[nRunIndex];
    1616         if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
     1712        if ((btnPtr->fsStyle & BTNS_CHECKGROUP) == BTNS_CHECKGROUP) {
    16171713            if (btnPtr->fsState & TBSTATE_CHECKED)
    16181714                return nRunIndex;
     
    16271723    while (nRunIndex < infoPtr->nNumButtons) {
    16281724        btnPtr = &infoPtr->buttons[nRunIndex];
    1629         if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
     1725        if ((btnPtr->fsStyle & BTNS_CHECKGROUP) == BTNS_CHECKGROUP) {
    16301726            if (btnPtr->fsState & TBSTATE_CHECKED)
    16311727                return nRunIndex;
     
    16901786                    return FALSE;
    16911787
     1788                /* UNDOCUMENTED: dialog hwnd immediately follows NMHDR */
     1789                nmtb.iItem = (int)hwnd;
    16921790                /* Send TBN_INITCUSTOMIZE notification */
    16931791                if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_INITCUSTOMIZE) ==
    1694                     TBNRF_HIDEHELP)
     1792                    TBNRF_HIDEHELP)
    16951793                {
    1696                     FIXME("TBNRF_HIDEHELP not supported\n");
     1794                    TRACE("TBNRF_HIDEHELP requested\n");
     1795                    ShowWindow(GetDlgItem(hwnd, IDC_HELP_BTN), SW_HIDE);
    16971796                }
    16981797
     
    17001799                for (i = 0; i < custInfo->tbInfo->nNumButtons; i++)
    17011800                {
    1702                     btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
     1801                    btnInfo = (PCUSTOMBUTTON)Alloc(sizeof(CUSTOMBUTTON));
    17031802                    memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
    1704                     btnInfo->btn.fsStyle = TBSTYLE_SEP;
     1803                    btnInfo->btn.fsStyle = BTNS_SEP;
    17051804                    btnInfo->bVirtual = FALSE;
    17061805                    LoadStringW (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
     
    17141813
    17151814                /* insert separator button into 'available buttons' list */
    1716                 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
     1815                btnInfo = (PCUSTOMBUTTON)Alloc(sizeof(CUSTOMBUTTON));
    17171816                memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
    1718                 btnInfo->btn.fsStyle = TBSTYLE_SEP;
     1817                btnInfo->btn.fsStyle = BTNS_SEP;
    17191818                btnInfo->bVirtual = FALSE;
    17201819                btnInfo->bRemovable = TRUE;
     
    17491848                    if (index == -1)
    17501849                    {
    1751                         btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
     1850                        btnInfo = (PCUSTOMBUTTON)Alloc(sizeof(CUSTOMBUTTON));
    17521851                        btnInfo->bVirtual = FALSE;
    17531852                        btnInfo->bRemovable = TRUE;
     
    17641863
    17651864                    memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
    1766                     if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
     1865                    if (!(nmtb.tbButton.fsStyle & BTNS_SEP))
    17671866                    {
    17681867                        if (lstrlenW(nmtb.pszText))
     
    17811880
    17821881                /* append 'virtual' separator button to the 'toolbar buttons' list */
    1783                 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
     1882                btnInfo = (PCUSTOMBUTTON)Alloc(sizeof(CUSTOMBUTTON));
    17841883                memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
    1785                 btnInfo->btn.fsStyle = TBSTYLE_SEP;
     1884                btnInfo->btn.fsStyle = BTNS_SEP;
    17861885                btnInfo->bVirtual = TRUE;
    17871886                btnInfo->bRemovable = FALSE;
     
    19532052
    19542053                            /* insert into 'available button' list */
    1955                             if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP))
     2054                            if (!(btnInfo->btn.fsStyle & BTNS_SEP))
    19562055                            {
    19572056                                index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
     
    19592058                            }
    19602059                            else
    1961                                 COMCTL32_Free (btnInfo);
     2060                                Free (btnInfo);
    19622061                        }
    19632062                    }
    19642063                    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;
    19652070
    19662071                case IDOK: /* Add button */
     
    19942099
    19952100                                /* duplicate 'separator' button */
    1996                                 btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON));
     2101                                btnNew = (PCUSTOMBUTTON)Alloc (sizeof(CUSTOMBUTTON));
    19972102                                memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON));
    19982103                                btnInfo = btnNew;
     
    20252130                {
    20262131                    btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0);
    2027                     COMCTL32_Free(btnInfo);
     2132                    Free(btnInfo);
    20282133                    SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0);
    20292134                }
     
    20362141                {
    20372142                    btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0);
    2038                     COMCTL32_Free(btnInfo);
     2143                    Free(btnInfo);
    20392144                    SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0);
    20402145                }
     
    20942199
    20952200                /* draw image and text */
    2096                 if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0) {
     2201                if ((btnInfo->btn.fsStyle & BTNS_SEP) == 0) {
    20972202                        HIMAGELIST himl = GETDEFIMAGELIST(infoPtr, GETHIMLID(infoPtr,
    20982203                                btnInfo->btn.iBitmap));
     
    21992304        TRACE ("creating default image list!\n");
    22002305
    2201     himlDef = ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
    2202                 ILC_COLOR | ILC_MASK, nButtons, 2);
     2306        himlDef = ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
     2307                                    ILC_COLORDDB | ILC_MASK, nButtons, 2);
    22032308        TOOLBAR_InsertImageList(&infoPtr->himlDef, &infoPtr->cimlDef, himlDef, 0);
    2204     infoPtr->himlInt = himlDef;
     2309        infoPtr->himlInt = himlDef;
    22052310    }
    22062311    else {
     
    22442349       DeleteDC (hdcBitmap);
    22452350
    2246        nIndex = ImageList_AddMasked (himlDef, hbmLoad, CLR_DEFAULT);
     2351       nIndex = ImageList_AddMasked (himlDef, hbmLoad, comctl32_color.clrBtnFace);
    22472352       DeleteObject (hbmLoad);
    22482353    }
     
    22562361                                       MAKEINTRESOURCEA(IDB_STD_SMALL));
    22572362                nIndex = ImageList_AddMasked (himlDef,
    2258                                               hbmLoad, CLR_DEFAULT);
     2363                                              hbmLoad, comctl32_color.clrBtnFace);
    22592364                DeleteObject (hbmLoad);
    22602365                break;
     
    22642369                                       MAKEINTRESOURCEA(IDB_STD_LARGE));
    22652370                nIndex = ImageList_AddMasked (himlDef,
    2266                                               hbmLoad, CLR_DEFAULT);
     2371                                              hbmLoad, comctl32_color.clrBtnFace);
    22672372                DeleteObject (hbmLoad);
    22682373                break;
     
    22722377                                       MAKEINTRESOURCEA(IDB_VIEW_SMALL));
    22732378                nIndex = ImageList_AddMasked (himlDef,
    2274                                               hbmLoad, CLR_DEFAULT);
     2379                                              hbmLoad, comctl32_color.clrBtnFace);
    22752380                DeleteObject (hbmLoad);
    22762381                break;
     
    22802385                                       MAKEINTRESOURCEA(IDB_VIEW_LARGE));
    22812386                nIndex = ImageList_AddMasked (himlDef,
    2282                                               hbmLoad, CLR_DEFAULT);
     2387                                              hbmLoad, comctl32_color.clrBtnFace);
    22832388                DeleteObject (hbmLoad);
    22842389                break;
     
    22882393                                       MAKEINTRESOURCEA(IDB_HIST_SMALL));
    22892394                nIndex = ImageList_AddMasked (himlDef,
    2290                                               hbmLoad, CLR_DEFAULT);
     2395                                              hbmLoad, comctl32_color.clrBtnFace);
    22912396                DeleteObject (hbmLoad);
    22922397                break;
     
    22962401                                       MAKEINTRESOURCEA(IDB_HIST_LARGE));
    22972402                nIndex = ImageList_AddMasked (himlDef,
    2298                                               hbmLoad, CLR_DEFAULT);
     2403                                              hbmLoad, comctl32_color.clrBtnFace);
    22992404                DeleteObject (hbmLoad);
    23002405                break;
     
    23092414    {
    23102415        hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
    2311         nIndex = ImageList_AddMasked (himlDef, hbmLoad, CLR_DEFAULT);
     2416        nIndex = ImageList_AddMasked (himlDef, hbmLoad, comctl32_color.clrBtnFace);
    23122417        DeleteObject (hbmLoad);
    23132418    }
     
    23172422    if (infoPtr->nNumBitmapInfos == 0)
    23182423    {
    2319         infoPtr->bitmaps = COMCTL32_Alloc(sizeof(TBITMAP_INFO));
     2424        infoPtr->bitmaps = Alloc(sizeof(TBITMAP_INFO));
    23202425    }
    23212426    else
    23222427    {
    23232428        TBITMAP_INFO *oldBitmaps = infoPtr->bitmaps;
    2324         infoPtr->bitmaps = COMCTL32_Alloc((infoPtr->nNumBitmapInfos + 1) * sizeof(TBITMAP_INFO));
     2429        infoPtr->bitmaps = Alloc((infoPtr->nNumBitmapInfos + 1) * sizeof(TBITMAP_INFO));
    23252430        memcpy(&infoPtr->bitmaps[0], &oldBitmaps[0], infoPtr->nNumBitmapInfos);
    23262431    }
     
    23492454    }
    23502455
    2351     InvalidateRect(hwnd, NULL, FALSE);
     2456    InvalidateRect(hwnd, NULL, TRUE);
    23522457
    23532458    return nIndex;
     
    23702475    if (infoPtr->nNumButtons == 0) {
    23712476        infoPtr->buttons =
    2372             COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     2477            Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    23732478    }
    23742479    else {
    23752480        TBUTTON_INFO *oldButtons = infoPtr->buttons;
    23762481        infoPtr->buttons =
    2377             COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     2482            Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    23782483        memcpy (&infoPtr->buttons[0], &oldButtons[0],
    23792484                nOldButtons * sizeof(TBUTTON_INFO));
    2380         COMCTL32_Free (oldButtons);
     2485        Free (oldButtons);
    23812486    }
    23822487
     
    23912496        btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
    23922497        btnPtr->dwData    = lpTbb[nCount].dwData;
    2393         btnPtr->iString   = lpTbb[nCount].iString;
     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;
    23942502        btnPtr->bHot      = FALSE;
    23952503
    2396         if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
     2504        if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & BTNS_SEP)) {
    23972505            TTTOOLINFOA ti;
    23982506
     
    24132521    TOOLBAR_DumpToolbar (infoPtr, __LINE__);
    24142522
    2415     InvalidateRect(hwnd, NULL, FALSE);
     2523    InvalidateRect(hwnd, NULL, TRUE);
    24162524
    24172525    return TRUE;
     
    24342542    if (infoPtr->nNumButtons == 0) {
    24352543        infoPtr->buttons =
    2436             COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     2544            Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    24372545    }
    24382546    else {
    24392547        TBUTTON_INFO *oldButtons = infoPtr->buttons;
    24402548        infoPtr->buttons =
    2441             COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     2549            Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    24422550        memcpy (&infoPtr->buttons[0], &oldButtons[0],
    24432551                nOldButtons * sizeof(TBUTTON_INFO));
    2444         COMCTL32_Free (oldButtons);
     2552        Free (oldButtons);
    24452553    }
    24462554
     
    24552563        btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
    24562564        btnPtr->dwData    = lpTbb[nCount].dwData;
    2457         btnPtr->iString   = lpTbb[nCount].iString;
     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;
    24582569        btnPtr->bHot      = FALSE;
    24592570
    2460         if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
     2571        if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & BTNS_SEP)) {
    24612572            TTTOOLINFOW ti;
    24622573
     
    24782589    TOOLBAR_DumpToolbar (infoPtr, __LINE__);
    24792590
    2480     InvalidateRect(hwnd, NULL, FALSE);
     2591    InvalidateRect(hwnd, NULL, TRUE);
    24812592
    24822593    return TRUE;
     
    25022613        if (infoPtr->nNumStrings == 0) {
    25032614            infoPtr->strings =
    2504                 COMCTL32_Alloc (sizeof(LPWSTR));
     2615                Alloc (sizeof(LPWSTR));
    25052616        }
    25062617        else {
    25072618            LPWSTR *oldStrings = infoPtr->strings;
    25082619            infoPtr->strings =
    2509                 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     2620                Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    25102621            memcpy (&infoPtr->strings[0], &oldStrings[0],
    25112622                    sizeof(LPWSTR) * infoPtr->nNumStrings);
    2512             COMCTL32_Free (oldStrings);
     2623            Free (oldStrings);
    25132624        }
    25142625
    2515         /*COMCTL32_Alloc zeros out the allocated memory*/
     2626        /*Alloc zeros out the allocated memory*/
    25162627        Str_SetPtrAtoW (&infoPtr->strings[infoPtr->nNumStrings], szString );
    25172628        infoPtr->nNumStrings++;
     
    25322643            if (infoPtr->nNumStrings == 0) {
    25332644                infoPtr->strings =
    2534                     COMCTL32_Alloc (sizeof(LPWSTR));
     2645                    Alloc (sizeof(LPWSTR));
    25352646            }
    25362647            else {
    25372648                LPWSTR *oldStrings = infoPtr->strings;
    25382649                infoPtr->strings =
    2539                     COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     2650                    Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    25402651                memcpy (&infoPtr->strings[0], &oldStrings[0],
    25412652                        sizeof(LPWSTR) * infoPtr->nNumStrings);
    2542                 COMCTL32_Free (oldStrings);
     2653                Free (oldStrings);
    25432654            }
    25442655
     
    25802691
    25812692                if (infoPtr->nNumStrings == 0) {
    2582                     infoPtr->strings = COMCTL32_Alloc (sizeof(LPWSTR));
     2693                    infoPtr->strings = Alloc (sizeof(LPWSTR));
    25832694                }
    25842695                else
    25852696                {
    25862697                    LPWSTR *oldStrings = infoPtr->strings;
    2587                     infoPtr->strings = COMCTL32_Alloc(sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     2698                    infoPtr->strings = Alloc(sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    25882699                    memcpy(&infoPtr->strings[0], &oldStrings[0],
    25892700                           sizeof(LPWSTR) * infoPtr->nNumStrings);
    2590                     COMCTL32_Free(oldStrings);
     2701                    Free(oldStrings);
    25912702                }
    25922703
    2593                 np=COMCTL32_StrChrW (p, L'|');
     2704                np=strchrW (p, '|');
    25942705                if (np!=NULL) {
    25952706                    len = np - p;
     
    26012712                TRACE("len=%d %s\n", len, debugstr_w(p));
    26022713                infoPtr->strings[infoPtr->nNumStrings] =
    2603                     COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
     2714                    Alloc (sizeof(WCHAR)*(len+1));
    26042715                lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len+1);
    26052716                infoPtr->nNumStrings++;
     
    26132724            if (infoPtr->nNumStrings == 0) {
    26142725                infoPtr->strings =
    2615                     COMCTL32_Alloc (sizeof(LPWSTR));
     2726                    Alloc (sizeof(LPWSTR));
    26162727            }
    26172728            else {
    26182729                LPWSTR *oldStrings = infoPtr->strings;
    26192730                infoPtr->strings =
    2620                     COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     2731                    Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    26212732                memcpy (&infoPtr->strings[0], &oldStrings[0],
    26222733                        sizeof(LPWSTR) * infoPtr->nNumStrings);
    2623                 COMCTL32_Free (oldStrings);
     2734                Free (oldStrings);
    26242735            }
    26252736
     
    26422753            if (infoPtr->nNumStrings == 0) {
    26432754                infoPtr->strings =
    2644                     COMCTL32_Alloc (sizeof(LPWSTR));
     2755                    Alloc (sizeof(LPWSTR));
    26452756            }
    26462757            else {
    26472758                LPWSTR *oldStrings = infoPtr->strings;
    26482759                infoPtr->strings =
    2649                     COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     2760                    Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    26502761                memcpy (&infoPtr->strings[0], &oldStrings[0],
    26512762                        sizeof(LPWSTR) * infoPtr->nNumStrings);
    2652                 COMCTL32_Free (oldStrings);
     2763                Free (oldStrings);
    26532764            }
    26542765
     
    27002811        cx = infoPtr->nWidth;
    27012812
    2702         if (dwStyle & CCS_NOMOVEY) {
     2813        if ((dwStyle & CCS_BOTTOM) == CCS_NOMOVEY) {
    27032814                GetWindowRect(hwnd, &window_rect);
    27042815                ScreenToClient(parent, (LPPOINT)&window_rect.left);
    27052816                y = window_rect.top;
    27062817        }
     2818        if ((dwStyle & CCS_BOTTOM) == CCS_BOTTOM) {
     2819            GetWindowRect(hwnd, &window_rect);
     2820            y = parent_rect.bottom - ( window_rect.bottom - window_rect.top);
     2821        }
    27072822    }
    27082823
     
    27212836
    27222837    infoPtr->bAutoSize = TRUE;
    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 */
     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 */
    27272841    infoPtr->bAutoSize = FALSE;
    27282842
     
    27642878    INT nIndex;
    27652879
     2880    TRACE("button %d, iBitmap now %d\n", wParam, LOWORD(lParam));
     2881
    27662882    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    27672883    if (nIndex == -1)
     
    27892905
    27902906    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
     2907
     2908    TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd, nIndex, lParam);
     2909
    27912910    if (nIndex == -1)
    27922911        return FALSE;
    27932912
    27942913    btnPtr = &infoPtr->buttons[nIndex];
    2795 
    2796     if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
    2797         return FALSE;
    27982914
    27992915    bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE;
     
    28022918        btnPtr->fsState &= ~TBSTATE_CHECKED;
    28032919    else {
    2804         if (btnPtr->fsStyle & TBSTYLE_GROUP) {
     2920        if (btnPtr->fsStyle & BTNS_GROUP) {
    28052921            nOldIndex =
    28062922                TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
     
    28152931    if( bChecked != LOWORD(lParam) )
    28162932    {
    2817         if (nOldIndex != -1)
    2818         {
    2819             InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
    2820                 TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
    2821         }
     2933        if (nOldIndex != -1)
     2934            InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect, TRUE);
    28222935        InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    28232936    }
     
    28572970    if (!(hRes = FindResourceA (COMCTL32_hModule,
    28582971                                MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
    2859                                 RT_DIALOGA)))
     2972                                (LPSTR)RT_DIALOGA)))
    28602973        return FALSE;
    28612974
     
    28873000
    28883001    if ((infoPtr->hwndToolTip) &&
    2889         !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
     3002        !(infoPtr->buttons[nIndex].fsStyle & BTNS_SEP)) {
    28903003        TTTOOLINFOA ti;
    28913004
     
    29003013    if (infoPtr->nNumButtons == 1) {
    29013014        TRACE(" simple delete!\n");
    2902         COMCTL32_Free (infoPtr->buttons);
     3015        Free (infoPtr->buttons);
    29033016        infoPtr->buttons = NULL;
    29043017        infoPtr->nNumButtons = 0;
     
    29093022
    29103023        infoPtr->nNumButtons--;
    2911         infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
     3024        infoPtr->buttons = Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
    29123025        if (nIndex > 0) {
    29133026            memcpy (&infoPtr->buttons[0], &oldButtons[0],
     
    29203033        }
    29213034
    2922         COMCTL32_Free (oldButtons);
     3035        Free (oldButtons);
    29233036    }
    29243037
     
    29403053
    29413054    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
     3055
     3056    TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd, wParam, lParam);
     3057
    29423058    if (nIndex == -1)
    29433059        return FALSE;
     
    29563072    /* redraw the button only if the state of the button changed */
    29573073    if(bState != (btnPtr->fsState & TBSTATE_ENABLED))
    2958     {
    2959         InvalidateRect(hwnd, &btnPtr->rect,
    2960             TOOLBAR_HasText(infoPtr, btnPtr));
    2961     }
     3074        InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    29623075
    29633076    return TRUE;
     
    30473160
    30483161    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 
    3070 static LRESULT
    3071 TOOLBAR_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;
    30943162
    30953163    if (lpTbInfo->dwMask & TBIF_COMMAND)
     
    31063174        lpTbInfo->fsStyle = btnPtr->fsStyle;
    31073175    if (lpTbInfo->dwMask & TBIF_TEXT) {
    3108         LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
    3109         Str_GetPtrW (lpText,lpTbInfo->pszText,lpTbInfo->cchText);
     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
     3189static LRESULT
     3190TOOLBAR_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';
    31103235    }
    31113236
     
    31733298TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
    31743299{
    3175     return (LRESULT)GETDISIMAGELIST(TOOLBAR_GetInfoPtr (hwnd), 0);
     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);
    31763303}
    31773304
     
    31823309    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    31833310
     3311    TRACE("\n");
     3312
    31843313    return infoPtr->dwExStyle;
    31853314}
     
    31893318TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
    31903319{
    3191     return (LRESULT)GETHOTIMAGELIST(TOOLBAR_GetInfoPtr (hwnd), 0);
     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);
    31923323}
    31933324
     
    32113342TOOLBAR_GetDefImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
    32123343{
    3213     return (LRESULT) GETDEFIMAGELIST(TOOLBAR_GetInfoPtr(hwnd), 0);
     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);
    32143347}
    32153348
     
    34323565    TBUTTON_INFO *btnPtr;
    34333566    INT nIndex;
     3567    DWORD oldState;
    34343568
    34353569    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
     
    34383572
    34393573    btnPtr = &infoPtr->buttons[nIndex];
     3574    oldState = btnPtr->fsState;
    34403575    if (LOWORD(lParam) == FALSE)
    34413576        btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
     
    34433578        btnPtr->fsState |= TBSTATE_INDETERMINATE;
    34443579
    3445     InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
     3580    if(oldState != btnPtr->fsState)
     3581        InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    34463582
    34473583    return TRUE;
     
    34843620              debugstr_a((LPSTR)lpTbb->iString));
    34853621        len = strlen((LPSTR)lpTbb->iString) + 2;
    3486         ptr = COMCTL32_Alloc(len);
     3622        ptr = Alloc(len);
    34873623        strcpy(ptr, (LPSTR)lpTbb->iString);
    34883624        ptr[len - 1] = 0; /* ended by two '\0' */
    34893625        lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr);
    3490         COMCTL32_Free(ptr);
     3626        Free(ptr);
    34913627    }
    34923628
     
    34993635    oldButtons = infoPtr->buttons;
    35003636    infoPtr->nNumButtons++;
    3501     infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
     3637    infoPtr->buttons = Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
    35023638    /* pre insert copy */
    35033639    if (nIndex > 0) {
     
    35193655        infoPtr->buttons[nIndex].iString   = lpTbb->iString;
    35203656
    3521     if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
     3657    if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & BTNS_SEP)) {
    35223658        TTTOOLINFOA ti;
    35233659
     
    35393675    }
    35403676
    3541     COMCTL32_Free (oldButtons);
     3677    Free (oldButtons);
    35423678
    35433679    TOOLBAR_CalcToolbar (hwnd);
     
    35843720              debugstr_w((LPWSTR)lpTbb->iString));
    35853721        len = strlenW((LPWSTR)lpTbb->iString) + 2;
    3586         ptr = COMCTL32_Alloc(len*sizeof(WCHAR));
     3722        ptr = Alloc(len*sizeof(WCHAR));
    35873723        strcpyW(ptr, (LPWSTR)lpTbb->iString);
    35883724        ptr[len - 1] = 0; /* ended by two '\0' */
    35893725        lpTbb->iString = TOOLBAR_AddStringW(hwnd, 0, (LPARAM)ptr);
    3590         COMCTL32_Free(ptr);
     3726        Free(ptr);
    35913727    }
    35923728
     
    35993735    oldButtons = infoPtr->buttons;
    36003736    infoPtr->nNumButtons++;
    3601     infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
     3737    infoPtr->buttons = Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
    36023738    /* pre insert copy */
    36033739    if (nIndex > 0) {
     
    36193755        infoPtr->buttons[nIndex].iString   = lpTbb->iString;
    36203756
    3621     if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
     3757    if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & BTNS_SEP)) {
    36223758        TTTOOLINFOW ti;
    36233759
     
    36393775    }
    36403776
    3641     COMCTL32_Free (oldButtons);
     3777    Free (oldButtons);
    36423778
    36433779    TOOLBAR_CalcToolbar (hwnd);
     
    37363872
    37373873
    3738 /* << TOOLBAR_LoadImages >> */
    3739 /* << TOOLBAR_MapAccelerator >> */
    3740 /* << TOOLBAR_MarkButton >> */
     3874static LRESULT
     3875TOOLBAR_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
     3887static LRESULT
     3888TOOLBAR_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
     3931static LRESULT
     3932TOOLBAR_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
    37413951/* << TOOLBAR_MoveButton >> */
    37423952
     
    37483958    TBUTTON_INFO *btnPtr;
    37493959    INT nIndex;
     3960    DWORD oldState;
    37503961
    37513962    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
     
    37543965
    37553966    btnPtr = &infoPtr->buttons[nIndex];
     3967    oldState = btnPtr->fsState;
    37563968    if (LOWORD(lParam) == FALSE)
    37573969        btnPtr->fsState &= ~TBSTATE_PRESSED;
     
    37593971        btnPtr->fsState |= TBSTATE_PRESSED;
    37603972
    3761     InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
     3973    if(oldState != btnPtr->fsState)
     3974        InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    37623975
    37633976    return TRUE;
    37643977}
    37653978
    3766 
     3979/* FIXME: there might still be some confusion her between number of buttons
     3980 * and number of bitmaps */
    37673981static LRESULT
    37683982TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    37723986    HBITMAP hBitmap;
    37733987    int i = 0, nOldButtons = 0, pos = 0;
     3988    int nOldBitmaps, nNewBitmaps;
    37743989    HIMAGELIST himlDef = 0;
    37753990
     
    38154030        return FALSE;
    38164031    }
    3817 
    3818     infoPtr->nNumBitmaps = infoPtr->nNumBitmaps - nOldButtons + lpReplace->nButtons;
     4032   
     4033    himlDef = GETDEFIMAGELIST(infoPtr, 0); /* fixme: correct? */
     4034    nOldBitmaps = ImageList_GetImageCount(himlDef);
    38194035
    38204036    /* ImageList_Replace(GETDEFIMAGELIST(), pos, hBitmap, NULL); */
    38214037
    3822 
    3823     himlDef = GETDEFIMAGELIST(infoPtr, 0);
    3824     for (i = pos + nOldButtons - 1; i >= pos; i--) {
     4038    for (i = pos + nOldBitmaps - 1; i >= pos; i--)
    38254039        ImageList_Remove(himlDef, i);
    3826     }
    38274040
    38284041    {
     
    38534066       DeleteDC (hdcBitmap);
    38544067
    3855        ImageList_AddMasked (himlDef, hbmLoad, CLR_DEFAULT);
     4068       ImageList_AddMasked (himlDef, hbmLoad, comctl32_color.clrBtnFace);
     4069       nNewBitmaps = ImageList_GetImageCount(himlDef);
    38564070       DeleteObject (hbmLoad);
    38574071    }
    38584072
    3859     InvalidateRect(hwnd, NULL, FALSE);
     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);
    38604079
    38614080    return TRUE;
     
    41744393}
    41754394
     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 */
    41764401static LRESULT
    41774402TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    41814406
    41824407    dwTemp = 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     }
     4408    infoPtr->dwExStyle &= ~wParam;
     4409    infoPtr->dwExStyle |= (DWORD)lParam;
     4410
     4411    TRACE("new style 0x%08lx\n", infoPtr->dwExStyle);
    41934412
    41944413    if (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL)
    41954414        FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
    41964415              (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL));
     4416
     4417    TOOLBAR_CalcToolbar (hwnd);
     4418
     4419    TOOLBAR_AutoSize(hwnd);
     4420
     4421    InvalidateRect(hwnd, NULL, TRUE);
    41974422
    41984423    return (LRESULT)dwTemp;
     
    42104435    if (infoPtr->iVersion >= 5)
    42114436        id = wParam;
     4437
     4438    TRACE("hwnd = %p, himl = %p, id = %d\n", hwnd, himl, id);
    42124439
    42134440    himlTemp = TOOLBAR_InsertImageList(&infoPtr->himlHot,
     
    42384465            btnPtr = &infoPtr->buttons[(INT)wParam];
    42394466            btnPtr->bHot = TRUE;
    4240                 InvalidateRect (hwnd, &btnPtr->rect,
    4241                     TOOLBAR_HasText(infoPtr, btnPtr));
     4467                InvalidateRect (hwnd, &btnPtr->rect, TRUE);
    42424468        }
    42434469        if (nOldHotItem>=0)
     
    42454471            btnPtr = &infoPtr->buttons[nOldHotItem];
    42464472            btnPtr->bHot = FALSE;
    4247                 InvalidateRect (hwnd, &btnPtr->rect,
    4248                     TOOLBAR_HasText(infoPtr, btnPtr));
     4473                InvalidateRect (hwnd, &btnPtr->rect, TRUE);
    42494474        }
    42504475    }
     
    42814506          infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
    42824507
    4283     /* FIXME: redraw ? */
    42844508    InvalidateRect(hwnd, NULL, TRUE);
    42854509
     
    43354559    infoPtr->nMaxTextRows = (INT)wParam;
    43364560
     4561    TOOLBAR_CalcToolbar(hwnd);
    43374562    return TRUE;
    43384563}
    43394564
    43404565
     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 */
    43414576static LRESULT
    43424577TOOLBAR_SetPadding (HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    43484583    infoPtr->szPadding.cx = LOWORD((DWORD)lParam);
    43494584    infoPtr->szPadding.cy = HIWORD((DWORD)lParam);
    4350     FIXME("stub - nothing done with values, cx=%ld, cy=%ld\n",
     4585    TRACE("cx=%ld, cy=%ld\n",
    43514586          infoPtr->szPadding.cx, infoPtr->szPadding.cy);
    43524587    return (LRESULT) oldPad;
     
    43914626
    43924627        /* repaint toolbar */
    4393         InvalidateRect(hwnd, NULL, FALSE);
     4628        InvalidateRect(hwnd, NULL, TRUE);
    43944629    }
    43954630
     
    44234658        btnPtr->fsState = LOWORD(lParam);
    44244659        TOOLBAR_CalcToolbar (hwnd);
    4425         InvalidateRect(hwnd, 0, TOOLBAR_HasText(infoPtr, btnPtr));
     4660        InvalidateRect(hwnd, 0, TRUE);
    44264661        return TRUE;
    44274662    }
     
    44314666    {
    44324667        btnPtr->fsState = LOWORD(lParam);
    4433         InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
    4434             btnPtr));
     4668        InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    44354669    }
    44364670
     
    44424676TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
    44434677{
    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     }
     4678    SetWindowLongW(hwnd, GWL_STYLE, lParam);
    44654679
    44664680    return TRUE;
     
    44724686{
    44734687    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     4688
     4689    TRACE("hwnd=%p, hwndTooltip=%p, lParam=0x%lx\n", hwnd, (HWND)wParam, lParam);
    44744690
    44754691    if (infoPtr == NULL)
     
    45214737    infoPtr->clrBtnHighlight = lParam->clrBtnHighlight;
    45224738    infoPtr->clrBtnShadow = lParam->clrBtnShadow;
    4523     InvalidateRect(hwnd, 0, 0);
     4739    InvalidateRect(hwnd, NULL, TRUE);
    45244740    return 0;
    45254741}
     
    45404756}
    45414757
     4758
     4759static LRESULT
     4760TOOLBAR_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
     4783static LRESULT
     4784TOOLBAR_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? */
     4811static 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}
    45424817
    45434818/*********************************************************************/
     
    45744849        btnPtr = &infoPtr->buttons[(INT)wParam];
    45754850        btnPtr->bHot = (no_hi) ? FALSE : TRUE;
    4576         InvalidateRect (hwnd, &btnPtr->rect,
    4577                         TOOLBAR_HasText(infoPtr, btnPtr));
     4851        InvalidateRect (hwnd, &btnPtr->rect, TRUE);
    45784852    }
    45794853    if (nOldHotItem>=0) {
    45804854        btnPtr = &infoPtr->buttons[nOldHotItem];
    45814855        btnPtr->bHot = FALSE;
    4582         InvalidateRect (hwnd, &btnPtr->rect,
    4583                         TOOLBAR_HasText(infoPtr, btnPtr));
     4856        InvalidateRect (hwnd, &btnPtr->rect, TRUE);
    45844857    }
    45854858    GetFocus();
     
    45934866}
    45944867
     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. */
     4871static 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. */
     4890static 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}
    45954898
    45964899static LRESULT
     
    46234926            HWND hwndParent = GetParent(hwnd);
    46244927
    4625             InvalidateRect(hwnd, 0, 1);
    46264928            GetWindowRect(hwnd, &rc);
    46274929            MapWindowPoints(0, hwndParent, (LPPOINT)&rc, 2);
     
    46494951}
    46504952
     4953static 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
    46514961
    46524962static LRESULT
     
    46564966    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    46574967    LOGFONTA logFont;
     4968
     4969    TRACE("hwnd = %p\n", hwnd);
    46584970
    46594971    /* initialize info structure */
     
    46644976
    46654977    infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
    4666     infoPtr->nRows = 1;
    46674978    infoPtr->nMaxTextRows = 1;
    46684979    infoPtr->cxMin = -1;
     
    46764987    infoPtr->nOldHit = -1;
    46774988    infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
    4678     infoPtr->hwndNotify = GetParent (hwnd);
     4989    infoPtr->hwndNotify = ((LPCREATESTRUCTW)lParam)->hwndParent;
    46794990    infoPtr->bTransparent = (dwStyle & TBSTYLE_TRANSPARENT);
    46804991    infoPtr->bBtnTranspnt = (dwStyle & (TBSTYLE_FLAT | TBSTYLE_LIST));
     
    46864997    infoPtr->clrBtnHighlight = CLR_DEFAULT;
    46874998    infoPtr->clrBtnShadow = CLR_DEFAULT;
    4688     infoPtr->szPadding.cx = 7;
    4689     infoPtr->szPadding.cy = 6;
     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);
    46905005    TOOLBAR_NotifyFormat(infoPtr, (WPARAM)hwnd, (LPARAM)NF_REQUERY);
    46915006
     
    47295044        DestroyWindow (infoPtr->hwndToolTip);
    47305045
     5046    /* delete temporary buffer for tooltip text */
     5047    if (infoPtr->pszTooltipText)
     5048        HeapFree(GetProcessHeap(), 0, infoPtr->pszTooltipText);
     5049
    47315050    /* delete button data */
    47325051    if (infoPtr->buttons)
    4733         COMCTL32_Free (infoPtr->buttons);
     5052        Free (infoPtr->buttons);
    47345053
    47355054    /* delete strings */
     
    47385057        for (i = 0; i < infoPtr->nNumStrings; i++)
    47395058            if (infoPtr->strings[i])
    4740                 COMCTL32_Free (infoPtr->strings[i]);
    4741 
    4742         COMCTL32_Free (infoPtr->strings);
     5059                Free (infoPtr->strings[i]);
     5060
     5061        Free (infoPtr->strings);
    47435062    }
    47445063
     
    47565075
    47575076    /* free toolbar info data */
    4758     COMCTL32_Free (infoPtr);
     5077    Free (infoPtr);
    47595078    SetWindowLongA (hwnd, 0, 0);
    47605079
     
    48645183        btnPtr->fsState |= TBSTATE_PRESSED;
    48655184
    4866         InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
    4867             btnPtr));
     5185        InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    48685186    }
    48695187    else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
     
    49005218
    49015219        /* for EX_DRAWDDARROWS style,  click must be in the drop-down arrow rect */
    4902         if ((btnPtr->fsState & TBSTATE_ENABLED) && (btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
    4903              ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
    4904               (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
     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))))))
    49055225        {
    49065226            LRESULT res;
     
    49165236            nmtb.cchText = 0;
    49175237            nmtb.pszText = 0;
    4918             memset(&nmtb.rcButton, 0, sizeof(RECT));
     5238            CopyRect(&nmtb.rcButton, &btnPtr->rect);
    49195239            res = TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
    49205240                                  TBN_DROPDOWN);
     
    49325252
    49335253        if (btnPtr->fsState & TBSTATE_ENABLED)
    4934             InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
     5254            InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    49355255        UpdateWindow(hwnd);
    49365256        SetCapture (hwnd);
     
    49795299        infoPtr->buttons[infoPtr->nHotItem].bHot = TRUE;
    49805300
     5301    if (0 <= infoPtr->nButtonDown) {
    49815302        btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
    49825303        btnPtr->fsState &= ~TBSTATE_PRESSED;
    49835304
    4984         if (btnPtr->fsStyle & TBSTYLE_CHECK) {
    4985                 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
     5305        if (btnPtr->fsStyle & BTNS_CHECK) {
     5306                if (btnPtr->fsStyle & BTNS_GROUP) {
    49865307                    nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
    49875308                        nHit);
     
    50015322        }
    50025323
    5003         if (nOldIndex != -1)
    5004         {
    5005             InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
    5006                 TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
    5007         }
     5324        if (nOldIndex != -1)
     5325            InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect, TRUE);
    50085326
    50095327        /*
     
    50485366            TOOLBAR_SendNotify ((NMHDR *) &nmmouse, infoPtr, NM_CLICK);
    50495367        }
     5368    }
    50505369    return 0;
    50515370}
     
    50675386
    50685387        if (btnPtr->fsState & TBSTATE_ENABLED)
    5069             InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
    5070               btnPtr));
     5388            InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    50715389    }
    50725390    return 0;
     
    50925410        rc1 = hotBtnPtr->rect;
    50935411        InflateRect (&rc1, 1, 1);
    5094         InvalidateRect (hwnd, &rc1, TOOLBAR_HasText(infoPtr,
    5095             hotBtnPtr));
     5412        InvalidateRect (hwnd, &rc1, TRUE);
    50965413    }
    50975414
     
    51545471    if (infoPtr->nOldHit != nHit)
    51555472    {
    5156         /* Remove the effect of an old hot button if the button was enabled and was
     5473        /* Remove the effect of an old hot button if the button was
    51575474           drawn with the hot button effect */
    5158         if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
    5159                 (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
     5475        if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem)
    51605476        {
    51615477            oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
     
    51705486            infoPtr->nHotItem = nHit;
    51715487
    5172             /* only enabled buttons show hot effect */
    5173             if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED)
    5174             {
    5175                 btnPtr->bHot = TRUE;
    5176             }
     5488            btnPtr->bHot = TRUE;
    51775489        }
    51785490
     
    51905502        /* now invalidate the old and new buttons so they will be painted */
    51915503        if (oldBtnPtr)
    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));
     5504            InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE);
     5505        if (btnPtr)
     5506            InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    51975507
    51985508        if (infoPtr->bCaptured) {
     
    52415551
    52425552    /* allocate memory for info structure */
    5243     infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
     5553    infoPtr = (TOOLBAR_INFO *)Alloc (sizeof(TOOLBAR_INFO));
    52445554    SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
    52455555
    52465556    /* paranoid!! */
    52475557    infoPtr->dwStructSize = sizeof(TBBUTTON);
     5558    infoPtr->nRows = 1;
    52485559
    52495560    /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
     
    53395650
    53405651
     5652/* handles requests from the tooltip control on what text to display */
     5653static 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
    53415783inline static LRESULT
    53425784TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    53455787    LPNMHDR lpnmh = (LPNMHDR)lParam;
    53465788
    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;
     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    }
    54015829}
    54025830
     
    54185846    INT i;
    54195847
     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
    54205853    if (lParam == NF_REQUERY) {
    5421         i = SendMessageA(GetParent(infoPtr->hwndSelf),
     5854        i = SendMessageA(infoPtr->hwndNotify,
    54225855                         WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
    54235856        if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
     
    54675900      *  *previous* status of the redraw flag (either 0 or 1)
    54685901      *  instead of the MSDN documented value of 0 if handled.
    5469       *  (For laughs see the "consistancy" with same function
     5902      *  (For laughs see the "consistency" with same function
    54705903      *   in rebar.)
    54715904      *
     
    55425975            cx = infoPtr->nWidth;
    55435976
    5544             if (dwStyle & CCS_NOMOVEY) {
     5977            if ((dwStyle & CCS_BOTTOM) == CCS_NOMOVEY) {
    55455978                GetWindowRect(hwnd, &window_rect);
    55465979                ScreenToClient(parent, (LPPOINT)&window_rect.left);
    5547                 y = window_rect.top;
     5980                y = window_rect.top;
    55485981            }
     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            }
    55495987        }
    55505988
     
    55656003        }
    55666004
    5567         SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
    5568                         cx, cy, uPosFlags | SWP_NOZORDER);
    5569     }
     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);
    55706049    return 0;
    55716050}
     
    55886067                                 (TBSTYLE_FLAT | TBSTYLE_LIST));
    55896068        TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew);
    5590     }
     6069
     6070        TRACE("new style 0x%08lx\n", lpStyle->styleNew);
     6071    }
     6072
     6073    TOOLBAR_CalcToolbar(hwnd);
    55916074
    55926075    TOOLBAR_AutoSize (hwnd);
    55936076
    5594     InvalidateRect(hwnd, NULL, FALSE);
     6077    InvalidateRect(hwnd, NULL, TRUE);
    55956078
    55966079    return 0;
     
    56116094ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    56126095{
     6096    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     6097
    56136098    TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
    56146099          hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
     
    57266211            return TOOLBAR_GetState (hwnd, wParam, lParam);
    57276212
     6213        case TB_GETSTRINGA:
     6214        return TOOLBAR_GetStringA (hwnd, wParam, lParam);
     6215
     6216        case TB_GETSTRINGW:
     6217            return TOOLBAR_GetStringW (hwnd, wParam, lParam);
     6218
    57286219        case TB_GETSTYLE:
    57296220            return TOOLBAR_GetStyle (hwnd, wParam, lParam);
     
    57736264            return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
    57746265
    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 */
     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
    57826276/*      case TB_MOVEBUTTON:                     */ /* 4.71 */
    57836277
     
    58656359            return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
    58666360
     6361        case TB_UNKWN45D:
     6362            return TOOLBAR_Unkwn45D(hwnd, wParam, lParam);
     6363
    58676364        case TB_UNKWN45E:
    58686365            return TOOLBAR_Unkwn45E (hwnd, wParam, lParam);
    58696366
     6367        case TB_UNKWN460:
     6368            return TOOLBAR_Unkwn460(hwnd, wParam, lParam);
     6369
     6370        case TB_UNKWN462:
     6371            return TOOLBAR_Unkwn462(hwnd, wParam, lParam);
     6372
    58706373        case TB_UNKWN463:
    58716374            return TOOLBAR_Unkwn463 (hwnd, wParam, lParam);
    58726375
     6376        case TB_UNKWN464:
     6377            return TOOLBAR_Unkwn464(hwnd, wParam, lParam);
    58736378
    58746379/* Common Control Messages */
     
    59406445
    59416446        case WM_NOTIFYFORMAT:
    5942             TOOLBAR_NotifyFormatFake (hwnd, wParam, lParam);
     6447            return TOOLBAR_NotifyFormatFake (hwnd, wParam, lParam);
    59436448
    59446449        case WM_PAINT:
     
    59646469        case WM_MEASUREITEM:
    59656470        case WM_VKEYTOITEM:
    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             }
     6471            return SendMessageA (infoPtr->hwndNotify, uMsg, wParam, lParam);
    59736472
    59746473        /* We see this in Outlook Express 5.x and just does DefWindowProc */
     
    59966495    wndClass.cbClsExtra    = 0;
    59976496    wndClass.cbWndExtra    = sizeof(TOOLBAR_INFO *);
    5998     wndClass.hCursor       = LoadCursorA (0, IDC_ARROWA);
     6497    wndClass.hCursor       = LoadCursorA (0, (LPSTR)IDC_ARROWA);
    59996498    wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
    60006499    wndClass.lpszClassName = TOOLBARCLASSNAMEA;
     
    60236522        PIMLENTRY *pnies;
    60246523
    6025         c = (PIMLENTRY) COMCTL32_Alloc(sizeof(IMLENTRY));
     6524        c = (PIMLENTRY) Alloc(sizeof(IMLENTRY));
    60266525        c->id = id;
    60276526
    6028         pnies = COMCTL32_Alloc((*cies + 1) * sizeof(PIMLENTRY));
     6527        pnies = Alloc((*cies + 1) * sizeof(PIMLENTRY));
    60296528        memcpy(pnies, *pies, ((*cies) * sizeof(PIMLENTRY)));
    60306529        pnies[*cies] = c;
    60316530        (*cies)++;
    60326531
    6033         COMCTL32_Free(*pies);
     6532        Free(*pies);
    60346533        *pies = pnies;
    60356534    }
     
    60476546
    60486547    for (i = 0; i < *cies; i++)
    6049         COMCTL32_Free((*pies)[i]);
    6050 
    6051     COMCTL32_Free(*pies);
     6548        Free((*pies)[i]);
     6549
     6550    Free(*pies);
    60526551
    60536552    *cies = 0;
Note: See TracChangeset for help on using the changeset viewer.