Changeset 6705 for trunk/src/comctl32


Ignore:
Timestamp:
Sep 15, 2001, 11:13:31 AM (24 years ago)
Author:
sandervl
Message:

update

Location:
trunk/src/comctl32
Files:
15 edited

Legend:

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

    r6644 r6705  
    11/* -*- tab-width: 8; c-basic-offset: 4 -*- */
    2 /* $Id: animate.c,v 1.14 2001-09-05 12:04:56 bird Exp $ */
    32/*
    43 * Animation control
  • trunk/src/comctl32/comboex.c

    r6644 r6705  
    1 /* $Id: comboex.c,v 1.12 2001-09-05 12:04:56 bird Exp $ */
    21/*
    32 * TODO   <-------------
  • trunk/src/comctl32/comctl32.c

    r6644 r6705  
    1 /* $Id: comctl32.c,v 1.18 2001-09-05 12:04:56 bird Exp $ */
    21/*
    32 * Common controls functions
  • trunk/src/comctl32/comctl32undoc.c

    r6644 r6705  
    1 /* $Id: comctl32undoc.c,v 1.22 2001-09-05 12:04:57 bird Exp $ */
    21/*
    32 * Undocumented functions from COMCTL32.DLL
  • trunk/src/comctl32/datetime.c

    r6644 r6705  
    1 /* $Id: datetime.c,v 1.18 2001-09-05 12:04:57 bird Exp $ */
    21/*
    32 * Date and time picker control
  • trunk/src/comctl32/flatsb.c

    r6644 r6705  
    1 /* $Id: flatsb.c,v 1.10 2001-09-05 12:04:58 bird Exp $ */
    21/*
    32 * Flat Scrollbar control
  • trunk/src/comctl32/imagelist.c

    r6644 r6705  
    1 /* $Id: imagelist.c,v 1.15 2001-09-05 12:04:58 bird Exp $ */
    21/*
    32 *  ImageList implementation
  • trunk/src/comctl32/listview.c

    r6644 r6705  
    1 /* $Id: listview.c,v 1.33 2001-09-05 12:04:59 bird Exp $ */
    21/*
    32 * Listview control
  • trunk/src/comctl32/monthcal.c

    r6644 r6705  
    1 /* $Id: monthcal.c,v 1.12 2001-09-05 12:05:00 bird Exp $ */
    21/* Month calendar control
    32 *
  • trunk/src/comctl32/pager.c

    r6644 r6705  
    1 /* $Id: pager.c,v 1.9 2001-09-05 12:05:01 bird Exp $ */
    21/*
    32 * Pager control
     
    2120#include "debugtools.h"
    2221
     22DEFAULT_DEBUG_CHANNEL(pager);
     23
    2324#ifdef __WIN32OS2__
    2425#include "ccbase.h"
     26#undef inline
    2527#define inline
    2628#endif
    27 
    28 DEFAULT_DEBUG_CHANNEL(pager);
    2929
    3030typedef struct
     
    4040    INT    nPos;       /* scroll position */
    4141    INT    nWidth;     /* from child wnd's response to PGN_CALCSIZE */
    42     INT    nHeight;    /* from child wnd's response to PGN_CALCSIZE */
     42    INT    nHeight;    /* from child wnd's response to PGN_CALCSIZE */ 
    4343    BOOL   bForward;   /* forward WM_MOUSEMOVE msgs to the contained wnd */
    4444    INT    TLbtnState; /* state of top or left btn */
     
    5858#define REPEAT_DELAY     50
    5959
    60 /* the horizontal arrows are:
     60/* the horizontal arrows are: 
    6161 *
    6262 * 01234    01234
     
    6767 * 5 **      **
    6868 * 6  *      *
    69  * 7
     69 * 7 
    7070 *
    7171 */
     
    7575    INT x, y, w, h;
    7676    HPEN hOldPen;
    77 
     77   
    7878    w = r.right - r.left + 1;
    7979    h = r.bottom - r.top + 1;
     
    108108}
    109109
    110 /* the vertical arrows are:
     110/* the vertical arrows are: 
    111111 *
    112112 * 01234567    01234567
    113  * 1******        **
     113 * 1******        ** 
    114114 * 2 ****        ****
    115115 * 3  **        ******
     
    122122    INT x, y, w, h;
    123123    HPEN hOldPen;
    124 
     124   
    125125    w = r.right - r.left + 1;
    126126    h = r.bottom - r.top + 1;
     
    166166
    167167    if ((rc.right - rc.left <= 0) || (rc.bottom - rc.top <= 0))
    168         return;
     168        return; 
    169169
    170170    hBrush = CreateSolidBrush(clrBk);
     
    173173    FillRect(hdc, &rc, hBrush);
    174174
    175     if (btnState == PGF_HOT)
     175    if (btnState == PGF_HOT) 
    176176    {
    177177       DrawEdge( hdc, &rc, BDR_RAISEDINNER, BF_RECT);
     
    181181           PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
    182182    }
    183     else if (btnState == PGF_NORMAL)
     183    else if (btnState == PGF_NORMAL) 
    184184    {
    185185       DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT);
     
    189189           PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
    190190    }
    191     else if (btnState == PGF_DEPRESSED)
     191    else if (btnState == PGF_DEPRESSED) 
    192192    {
    193193       DrawEdge( hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
     
    197197           PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
    198198    }
    199     else if (btnState == PGF_GRAYED)
     199    else if (btnState == PGF_GRAYED) 
    200200    {
    201201       DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT);
     
    234234PAGER_GetButtonState (HWND hwnd, WPARAM wParam, LPARAM lParam)
    235235{
    236     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     236    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
    237237    LRESULT btnState = PGF_INVISIBLE;
    238238    INT btn = (INT)lParam;
     
    251251PAGER_GetPos(HWND hwnd)
    252252{
    253     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     253    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
    254254    TRACE("[%04x] returns %d\n", hwnd, infoPtr->nPos);
    255255    return (LRESULT)infoPtr->nPos;
     
    259259PAGER_GetButtonSize(HWND hwnd)
    260260{
    261     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     261    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
    262262    TRACE("[%04x] returns %d\n", hwnd, infoPtr->nButtonSize);
    263263    return (LRESULT)infoPtr->nButtonSize;
     
    267267PAGER_GetBorder(HWND hwnd)
    268268{
    269     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     269    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
    270270    TRACE("[%04x] returns %d\n", hwnd, infoPtr->nBorder);
    271271    return (LRESULT)infoPtr->nBorder;
     
    275275PAGER_GetBkColor(HWND hwnd)
    276276{
    277     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     277    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
    278278    TRACE("[%04x] returns %06lx\n", hwnd, infoPtr->clrBk);
    279279    return (LRESULT)infoPtr->clrBk;
    280280}
    281281
    282 static void
    283 PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth)
     282static void 
     283PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth) 
    284284{
    285285    NMPGCALCSIZE nmpgcs;
     
    291291    nmpgcs.iWidth = getWidth ? *size : 0;
    292292    nmpgcs.iHeight = getWidth ? 0 : *size;
    293     SendMessageA (hwnd, WM_NOTIFY,
     293    SendMessageA (GetParent (hwnd), WM_NOTIFY,
    294294                  (WPARAM)nmpgcs.hdr.idFrom, (LPARAM)&nmpgcs);
    295295
     
    334334                infoPtr->nHeight = wndSize;
    335335
    336             TRACE("[%04x] SWP %dx%d at (%d,%d)\n", hwnd,
     336            TRACE("[%04x] SWP %dx%d at (%d,%d)\n", hwnd, 
    337337                         infoPtr->nWidth, infoPtr->nHeight,
    338338                         0, -nPos);
     
    380380}
    381381
    382 static void
     382static void 
    383383PAGER_GrayAndRestoreBtns(PAGER_INFO* infoPtr, INT scrollRange,
    384384                         BOOL* needsResize, BOOL* needsRepaint)
     
    417417
    418418
    419 static void
     419static void 
    420420PAGER_NormalizeBtns(PAGER_INFO* infoPtr, BOOL* needsRepaint)
    421421{
     
    433433}
    434434
    435 static void
     435static void 
    436436PAGER_HideGrayBtns(PAGER_INFO* infoPtr, BOOL* needsResize)
    437437{
     
    464464        PAGER_HideGrayBtns(infoPtr, &resizeClient);
    465465
    466     if (resizeClient) /* initiate NCCalcSize to resize client wnd */
    467         SetWindowPos(hwnd, 0,0,0,0,0,
     466    if (resizeClient) /* initiate NCCalcSize to resize client wnd */ {
     467        SetWindowPos(hwnd, 0,0,0,0,0, 
    468468                     SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
    469469                     SWP_NOZORDER | SWP_NOACTIVATE);
     470    }
    470471
    471472    if (repaintBtns)
    472         SendMessageA(hwnd, WM_NCPAINT, 0, 0);
    473 }
    474 
    475 static LRESULT
     473        SendMessageA(hwnd, WM_NCPAINT, 0, 0); 
     474}
     475
     476static LRESULT 
    476477PAGER_SetPos(HWND hwnd, INT newPos, BOOL fromBtnPress)
    477478{
     
    500501
    501502static LRESULT
    502 PAGER_HandleWindowPosChanging(HWND hwnd, WINDOWPOS *winpos)
     503PAGER_HandleWindowPosChanging(HWND hwnd, WPARAM wParam, WINDOWPOS *winpos)
    503504{
    504505    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     
    510511         * (i.e. height for a horizontal pager, or width for a vertical one) */
    511512
     513        /* except if the current dimension is 0 and app is setting for
     514         * first time, then save amount as dimension. - GA 8/01 */
     515
    512516        if (PAGER_IsHorizontal(hwnd))
    513             winpos->cy = infoPtr->nHeight;
     517            if (!infoPtr->nHeight && winpos->cy)
     518                infoPtr->nHeight = winpos->cy;
     519            else
     520                winpos->cy = infoPtr->nHeight;
    514521        else
    515             winpos->cx = infoPtr->nWidth;
    516     }
    517 
    518     return 0;
    519 }
    520 
    521 static void
     522            if (!infoPtr->nWidth && winpos->cx)
     523                infoPtr->nWidth = winpos->cx;
     524            else
     525                winpos->cx = infoPtr->nWidth;
     526        return 0;
     527    }
     528
     529    DefWindowProcA (hwnd, WM_WINDOWPOSCHANGING, wParam, (LPARAM)winpos);
     530
     531    return 1;
     532}
     533
     534static INT
    522535PAGER_SetFixedWidth(HWND hwnd, PAGER_INFO* infoPtr)
    523536{
     
    544557    h = wndRect.bottom - wndRect.top + infoPtr->nButtonSize;
    545558
    546     /* adjust non-scrollable dimension to fit the child */
    547     SetWindowPos(hwnd, 0, 0,0, infoPtr->nWidth, h,
    548                  SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER);
    549 
    550 
    551559    TRACE("[%04x] infoPtr->nWidth set to %d\n",
    552            hwnd, infoPtr->nWidth);
    553 }
    554 
    555 static void
     560               hwnd, infoPtr->nWidth);
     561
     562    return h;
     563}
     564
     565static INT
    556566PAGER_SetFixedHeight(HWND hwnd, PAGER_INFO* infoPtr)
    557567{
     
    578588    w = wndRect.right - wndRect.left + infoPtr->nButtonSize;
    579589
    580     /* adjust non-scrollable dimension to fit the child */
    581     SetWindowPos(hwnd, 0, 0,0, w, infoPtr->nHeight,
    582                  SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER);
    583 
    584590    TRACE("[%04x] infoPtr->nHeight set to %d\n",
    585            hwnd, infoPtr->nHeight);
     591               hwnd, infoPtr->nHeight);
     592
     593    return w;
    586594}
    587595
     
    602610            PAGER_SetPos(hwnd, 0, FALSE);
    603611        }
    604         else
     612        else 
    605613        {
    606614            PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, TRUE);
     
    663671{
    664672    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     673    INT hw;
    665674
    666675    infoPtr->hwndChild = IsWindow ((HWND)lParam) ? (HWND)lParam : 0;
     
    670679        TRACE("[%04x] hwndChild=%04x\n", hwnd, infoPtr->hwndChild);
    671680
    672         if (PAGER_IsHorizontal(hwnd))
    673             PAGER_SetFixedHeight(hwnd, infoPtr);
    674         else
    675             PAGER_SetFixedWidth(hwnd, infoPtr);
     681        if (PAGER_IsHorizontal(hwnd)) {
     682            hw = PAGER_SetFixedHeight(hwnd, infoPtr);
     683            /* adjust non-scrollable dimension to fit the child */
     684            SetWindowPos(hwnd, 0, 0,0, hw, infoPtr->nHeight,
     685                         SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER |
     686                         SWP_NOSIZE | SWP_NOACTIVATE);
     687        }
     688        else {
     689            hw = PAGER_SetFixedWidth(hwnd, infoPtr);
     690            /* adjust non-scrollable dimension to fit the child */
     691            SetWindowPos(hwnd, 0, 0,0, infoPtr->nWidth, hw,
     692                         SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER |
     693                         SWP_NOSIZE | SWP_NOACTIVATE);
     694        }
    676695
    677696        /* position child within the page scroller */
    678697        SetWindowPos(infoPtr->hwndChild, HWND_TOP,
    679698                     0,0,0,0,
    680                      SWP_SHOWWINDOW | SWP_NOSIZE);
     699                     SWP_SHOWWINDOW | SWP_NOSIZE);  /* native is 0 */
    681700
    682701        infoPtr->nPos = -1;
     
    701720        nmpgScroll.hdr.code = PGN_SCROLL;
    702721
    703         GetWindowRect(hwnd, &rcWnd);
    704         GetClientRect(hwnd, &nmpgScroll.rcParent);
     722        GetWindowRect(hwnd, &rcWnd); 
     723        GetClientRect(hwnd, &nmpgScroll.rcParent); 
    705724        nmpgScroll.iXpos = nmpgScroll.iYpos = 0;
    706725        nmpgScroll.iDir = dir;
     
    717736        }
    718737        nmpgScroll.iScroll -= 2*infoPtr->nButtonSize;
    719 
     738 
    720739        SendMessageA (hwnd, WM_NOTIFY,
    721740                    (WPARAM)nmpgScroll.hdr.idFrom, (LPARAM)&nmpgScroll);
    722 
     741 
    723742        TRACE("[%04x] PGN_SCROLL returns iScroll=%d\n", hwnd, nmpgScroll.iScroll);
    724743
     
    770789        FIXME("[%04x] Drag and Drop style is not implemented yet.\n", hwnd);
    771790    /*
    772     * If neither horizontal nor vertical style specified, default to vertical.
    773     * This is probably not necessary, since the style may be set later on as
    774     * the control is initialized, but just in case it isn't, set it here.
    775     */
     791        * If neither horizontal nor vertical style specified, default to vertical.
     792        * This is probably not necessary, since the style may be set later on as
     793        * the control is initialized, but just in case it isn't, set it here.
     794        */
    776795    if (!(dwStyle & PGS_HORZ) && !(dwStyle & PGS_VERT))
    777796    {
     
    799818    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    800819    LPRECT lpRect = (LPRECT)lParam;
     820    RECT rcChildw, rcmyw, wnrc, lbrc, rbrc;
     821    POINT cursor;
     822
    801823    /*
    802824     * lParam points to a RECT struct.  On entry, the struct
    803      * contains the proposed wnd rectangle for the window.
     825     * contains the proposed wnd rectangle for the window. 
    804826     * On exit, the struct should contain the screen
    805827     * coordinates of the corresponding window's client area.
    806828     */
     829       
     830    DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
    807831
    808832    if (PAGER_IsHorizontal(hwnd))
    809833    {
    810         if (infoPtr->TLbtnState) /* != PGF_INVISIBLE */
    811             lpRect->left += infoPtr->nButtonSize;
    812         if (infoPtr->BRbtnState)
    813             lpRect->right -= infoPtr->nButtonSize;
     834        infoPtr->nWidth = lpRect->right - lpRect->left;
     835        PAGER_CalcSize (hwnd, &infoPtr->nWidth, TRUE);
     836        GetWindowRect (infoPtr->hwndChild, &rcChildw);
     837        MapWindowPoints (0, hwnd, (LPPOINT)&rcChildw, 2);
     838        GetCursorPos (&cursor);
     839        GetWindowRect (hwnd, &rcmyw);
     840        if (PtInRect (&rcmyw, cursor)) {
     841            GetWindowRect (hwnd, &wnrc);
     842            lbrc = wnrc;
     843            lbrc.right = lbrc.left + infoPtr->nButtonSize;
     844            rbrc = wnrc;
     845            rbrc.left = rbrc.right - infoPtr->nButtonSize;
     846            TRACE("horz lb rect=(%d,%d)-(%d,%d), rb rect=(%d,%d)-(%d,%d)\n",
     847                  lbrc.left, lbrc.top, lbrc.right, lbrc.bottom,
     848                  rbrc.left, rbrc.top, rbrc.right, rbrc.bottom);
     849            if (PtInRect (&lbrc, cursor) && infoPtr->TLbtnState)
     850                RedrawWindow (hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE);
     851            if (PtInRect (&rbrc, cursor) && infoPtr->BRbtnState)
     852                RedrawWindow (hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE);
     853        }
     854        if (infoPtr->TLbtnState) /* != PGF_INVISIBLE */
     855            lpRect->left += infoPtr->nButtonSize;
     856        if (infoPtr->BRbtnState)
     857            lpRect->right -= infoPtr->nButtonSize;
    814858    }
    815859    else
    816860    {
    817         if (infoPtr->TLbtnState)
    818             lpRect->top += infoPtr->nButtonSize;
    819         if (infoPtr->BRbtnState)
    820             lpRect->bottom -= infoPtr->nButtonSize;
     861        /* native does: (from trace of IE4 opening "Favorites" frame)
     862         *        DefWindowProc
     863         *        WM_NOITFY  PGN_CALCSIZE w/ dwFlag=2
     864         *        GetWindowRect (child, &rc)
     865         *        MapWindowPoints (0, syspager, &rc, 2)
     866         *        GetCursorPos( &cur )
     867         *        GetWindowRect (syspager, &rc2)
     868         *        PtInRect (&rc2, cur.x, cur.y) rtns 0
     869         *        returns with rect empty
     870         */
     871        infoPtr->nHeight = lpRect->bottom - lpRect->top;
     872        PAGER_CalcSize (hwnd, &infoPtr->nHeight, FALSE);
     873        GetWindowRect (infoPtr->hwndChild, &rcChildw);
     874        MapWindowPoints (0, hwnd, (LPPOINT)&rcChildw, 2);
     875        GetCursorPos (&cursor);
     876        GetWindowRect (hwnd, &rcmyw);
     877        if (PtInRect (&rcmyw, cursor)) {
     878
     879            /* native does:
     880             *    GetWindowRect(pager, &rc)
     881             *    PtInRect(btn-left????, cur.x, cur.y)
     882             *    if true -> ???
     883             *    PtInRect(btn-right????, cur.x, cur.y)
     884             *    if true
     885             *      RedrawWindow(pager, 0, 0, 5)
     886             *      return TRUE
     887             */
     888
     889            GetWindowRect (hwnd, &wnrc);
     890            lbrc = wnrc;
     891            lbrc.right = lbrc.left + infoPtr->nButtonSize;
     892            rbrc = wnrc;
     893            rbrc.left = rbrc.right - infoPtr->nButtonSize;
     894            TRACE("vert lb rect=(%d,%d)-(%d,%d), rb rect=(%d,%d)-(%d,%d)\n",
     895                  lbrc.left, lbrc.top, lbrc.right, lbrc.bottom,
     896                  rbrc.left, rbrc.top, rbrc.right, rbrc.bottom);
     897            if (PtInRect (&lbrc, cursor) && infoPtr->TLbtnState)
     898                RedrawWindow (hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE);
     899            if (PtInRect (&rbrc, cursor) && infoPtr->BRbtnState)
     900                RedrawWindow (hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE);
     901        }
     902        if (infoPtr->TLbtnState)
     903            lpRect->top += infoPtr->nButtonSize;
     904        if (infoPtr->BRbtnState)
     905            lpRect->bottom -= infoPtr->nButtonSize;
     906        /* ???? */
     907        if ((lpRect->bottom < 0) || (lpRect->bottom > infoPtr->nHeight))
     908            lpRect->bottom = infoPtr->nHeight;
    821909    }
    822910
     
    864952                     bHorizontal, TRUE, infoPtr->TLbtnState);
    865953    PAGER_DrawButton(hdc, infoPtr->clrBk, rcBottomRight,
    866                      bHorizontal, FALSE, infoPtr->BRbtnState);
     954                     bHorizontal, FALSE, infoPtr->BRbtnState); 
    867955
    868956    ReleaseDC( hwnd, hdc );
     
    870958}
    871959
    872 static INT
     960static INT 
    873961PAGER_HitTest (HWND hwnd, LPPOINT pt)
    874962{
     
    9771065        if(!(trackinfo.dwFlags & TME_LEAVE)) {
    9781066            trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
    979 
     1067 
    9801068           /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
    9811069           /* and can properly deactivate the hot button */
     
    9831071        }
    9841072
    985         SendMessageA(hwnd, WM_NCPAINT, 0, 0);
     1073        SendMessageA(hwnd, WM_NCPAINT, 0, 0); 
    9861074    }
    9871075
     
    10261114
    10271115    TRACE("[%04x]\n", hwnd);
    1028 
     1116       
    10291117    hit = PAGER_HitTest(hwnd, &pt);
    10301118
     
    10341122        repaintBtns = infoPtr->TLbtnState != PGF_DEPRESSED;
    10351123        infoPtr->TLbtnState = PGF_DEPRESSED;
    1036         SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0);
     1124        SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 
    10371125    }
    10381126    else if (hit == HTRIGHT || hit == HTBOTTOM)
     
    10401128        repaintBtns = infoPtr->BRbtnState != PGF_DEPRESSED;
    10411129        infoPtr->BRbtnState = PGF_DEPRESSED;
    1042         SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0);
     1130        SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 
    10431131    }
    10441132
    10451133    if (repaintBtns)
    1046         SendMessageA(hwnd, WM_NCPAINT, 0, 0);
     1134        SendMessageA(hwnd, WM_NCPAINT, 0, 0); 
    10471135
    10481136    switch(hit)
     
    10891177PAGER_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
    10901178{
     1179    POINT pt, ptorig;
     1180    HDC hdc = (HDC)wParam;
     1181    HWND parent;
     1182
     1183    /* native does:
     1184     *   parent = GetParent(pager)
     1185     *   pt.x=0; pt.y=0; ?????
     1186     *   MapWindowPoints(pager, parent, &pt, 1)
     1187     *   OffsetWindowOrgEx(hdc, pt.x, pt.y, &ptorg)
     1188     *   SendMessageA(parent, WM_ERASEBKGND, hdc, 0)
     1189     *   SetWindowOrgEx(hdc, 0, 0, 0)
     1190     */
     1191
     1192    pt.x = 0;
     1193    pt.y = 0;
     1194    parent = GetParent(hwnd);
     1195    MapWindowPoints(hwnd, parent, &pt, 1);
     1196    OffsetWindowOrgEx (hdc, pt.x, pt.y, &ptorig);
     1197    SendMessageA (parent, WM_ERASEBKGND, wParam, lParam);
     1198    SetWindowOrgEx (hdc, ptorig.x, ptorig.y, 0);
     1199
     1200
     1201#if 0
    10911202    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    10921203    HBRUSH hBrush = CreateSolidBrush(infoPtr->clrBk);
     
    11041215
    11051216    DeleteObject (hBrush);
     1217#endif
     1218
    11061219    return TRUE;
    11071220}
     
    11311244
    11321245    if (!infoPtr && (uMsg != WM_CREATE))
    1133     return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     1246        return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    11341247
    11351248    switch (uMsg)
     
    11571270        case PGM_RECALCSIZE:
    11581271            return PAGER_RecalcSize(hwnd);
    1159 
     1272   
    11601273        case PGM_SETBKCOLOR:
    11611274            return PAGER_SetBkColor (hwnd, wParam, lParam);
     
    11861299
    11871300        case WM_WINDOWPOSCHANGING:
    1188             return PAGER_HandleWindowPosChanging (hwnd, (WINDOWPOS*)lParam);
     1301            return PAGER_HandleWindowPosChanging (hwnd, wParam, (WINDOWPOS*)lParam);
    11891302
    11901303        case WM_NCCALCSIZE:
     
    12051318            if (infoPtr->bForward && infoPtr->hwndChild)
    12061319                PostMessageA(infoPtr->hwndChild, WM_MOUSEMOVE, wParam, lParam);
    1207             return TRUE;
     1320            return TRUE;                       
    12081321
    12091322        case WM_MOUSELEAVE:
    1210             return PAGER_MouseLeave (hwnd, wParam, lParam);
     1323            return PAGER_MouseLeave (hwnd, wParam, lParam);     
    12111324
    12121325        case WM_LBUTTONDOWN:
     
    12201333/*
    12211334        case WM_PAINT:
    1222             return PAGER_Paint (hwnd, wParam);
     1335            return PAGER_Paint (hwnd, wParam); 
    12231336*/
    12241337        case WM_TIMER:
     
    12341347            {
    12351348                PAGER_Scroll(hwnd, infoPtr->direction);
    1236                 SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0);
     1349                SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0);         
    12371350            }
    12381351            break;
     
    12671380    wndClass.hbrBackground = 0;
    12681381    wndClass.lpszClassName = WC_PAGESCROLLERA;
    1269 
     1382 
    12701383    RegisterClassA (&wndClass);
    12711384}
  • trunk/src/comctl32/rebar.c

    r6644 r6705  
    1 /* $Id: rebar.c,v 1.16 2001-09-05 12:05:01 bird Exp $ */
     1/*
     2 * Testing: set to 1 to make background brush *always* green
     3 */
     4#define GLATESTING 0
     5
    26/*
    37 *
     
    1014
    1115/*
    12  * Rebar control    rev 7f
     16 * 3. REBAR_MoveChildWindows should have a loop because more than
     17 *    one pass is made (together with the RBN_CHILDSIZEs) is made on
     18 *    at least RB_INSERTBAND
     19 */
     20
     21
     22/*
     23 * Rebar control    rev 8a
    1324 *
    1425 * Copyright 1998, 1999 Eric Kohl
     
    2233 *   - vertical placement
    2334 *   - ComboBox and ComboBoxEx placement
    24  *   - center image
     35 *   - center image 
    2536 *   - Layout code.
    2637 *   - Display code.
     
    3142 *  rev 2,3,4
    3243 *   - Implement initial version of row grouping, row separators,
    33  *     text and background colors. Support additional messages.
     44 *     text and background colors. Support additional messages. 
    3445 *     Support RBBS_BREAK. Implement ERASEBKGND and improve painting.
    3546 *  rev 5
    3647 *   - implement support for dragging Gripper left or right in a row. Supports
    37  *     WM_LBUTTONDOWN, WM_LBUTTONUP, and WM_MOUSEMOVE. Also support
     48 *     WM_LBUTTONDOWN, WM_LBUTTONUP, and WM_MOUSEMOVE. Also support 
    3849 *     RBS_BANDBORDERS.
    3950 *  rev 6
     
    4354 *
    4455 * rev 7
    45  *  1. Redesign _Layout to better emulate native.
    46  *     a. Flag rebar when a band needs to be (and all bands) need to
    47  *        go through rest of _Layout
    48  *  2. Fix RBN_ENDDRAG contents.
    49  *  3. REBAR_ForceResize changed to handle shrink of client.
    50  * rev 7b
    51  *  4. Support RBBS_HIDDEN in _Layout (phase 2 & 3), _InternalEraseBkgnd,
    52  *     and _InternalHitTest
    53  *  5. Support RBS_VARHEIGHT.
    54  *  6. Rewrite _AdjustBands with new algorithm.
    55  * rev 7c
    56  *  7. Format mask and style with labels.
    57  *  8. Move calls to _ForceResize and _MoveChildWindows into _Layout to
    58  *     centralize processing.
    59  *  9. Pass "infoPtr" to all routines instead of "hwnd" to eliminate extra
    60  *     calls to GetWindowLongA.
    61  * 10. Use _MoveChildWindows in _HandleLRDrag.
    62  * 11. Another rewrite of _AdjustBands with new algorithm.
    63  * 12. Correct drawing of rebar borders and handling of RBS_BORDERS.
    64  * rev 7d
    65  * 13. Support WM_NOTIFYFORMAT (both incoming and outgoing) and do
    66  *     WM_NOTIFY correctly based on results.
    67  * 14. Implement WM_SETREDRAW.
    68  * 15. Native WM_ERASEBKGND draws horz and vert separators between bands and
    69  *     rows, and fills in the background color for each band. The gripper,
    70  *     image, and text for each band is drawn by the WM_PAINT process. Change
    71  *     this code to match.
    72  * rev 7e
    73  * 16. RBBS_FIXEDSIZE should not affect _AdjustBands. (Found by Mike McCormack
    74  *     in WinZip - Thanks!)
    75  * 17. Implement WM_NCCREATE to set necessary additional styles and move most
    76  *     of creation stuff to it like native control.
    77  * 18. WM_SETFONT should redraw only if LOWORD is TRUE.
    78  * 19. Implement WM_NCHITTEST to send notify to parent of NM_NCHITTEST.
    79  * 20. Cleaned up dead and/or testing code.
    80  * 21. Support RB_MOVEBAND.
    81  * 22. Support WM_STYLECHANGED and remove all (or most) of the GetWindowLong
    82  *     for GWL_STYLE.
    83  * 23. Support RB_MINIMIZEBAND.
    84  * 24. RBBS_HIDDEN (and the CCS_VERT+RBBS_NOVERT case) should be supported
    85  *     by all routines now.
    86  * rev 7f
    87  * 25. Fix handling of text color.
    88  * 26. Correct implementation of WM_SETREDRAW to be closer to native.
    89  *     See REBAR_SetRedraw for doc changes of actual vs. MSDN
    90  * 27. Do more implementation of RBS_AUTOSIZE in the WM_SIZE processor.
    91  * 28. Implement RBBS_VARIABLEHEIGHT. Used by IE4.
    92  * 29. Do more testing in WM_SIZE to handle strange cases like native.
     56 *   - Fix algorithm for _Layout and _AdjustBand.
     57 *   - Fix or implement RBN_ENDDRAG, RB_MOVEBAND, WM_SETREDRAW,
     58 *     WM_STYLECHANGED, RB_MINIMIZEBAND, RBBS_VARIABLEHEIGHT, RBS_VARHEIGHT,
     59 *     RBBS_HIDDEN, WM_NOTIFYFORMAT, NM_NCHITTEST, WM_SETREDRAW, RBS_AUTOSIZE,
     60 *     WM_SETFONT, RBS_BORDERS
     61 *   - Create structures in WM_NCCREATE
     62 *   - Additional performance enhancements.
     63 *
     64 * rev 8
     65 *  1. Create array of start and end band indexes by row and use.
     66 *  2. Fix problem with REBAR_Layout Phase 2b to process only if only
     67 *     band in row.
     68 *  3. Set the Caption Font (Regular) as default font for text.
     69 *  4. Delete font handle on control distruction.
     70 *  5. Add UpdateWindow call in _MoveChildWindows to match repainting done
     71 *     by native control
     72 *  6. Improve some traces.
     73 *  7. Invalidate window rectangles after SetBandInfo, InsertBand, ShowBand
     74 *     so that repainting is correct.
     75 *  8. Implement RB_MAXIMIZEBAND for the "ideal=TRUE" case.
     76 *  9. Implement item custom draw notifications partially. Only done for
     77 *     ITEMPREPAINT and ITEMPOSTPAINT. (Used by IE4 for "Favorites" frame
     78 *     to draw the word "Favorites").
     79 * rev 8a
     80 * 10. Handle CCS_NODIVIDER and fix WS_BORDER code.
     81 * 11. Fix logic error in _AdjustBands where flag was set to valid band
     82 *     number (0) to indicate *no* band.
     83 * 12. Fix CCS_VERT errors in _ForceResize, _NCCalcSize, and _NCPaint.
     84 * 13. Support some special cases of CCS_TOP (and therefore CCS_LEFT),
     85 *     CCS_BOTTOM (and therefore CCS_RIGHT) and CCS_NOPARENTALIGN. Not
     86 *     at all sure whether this is all cases.
     87 * 14. Handle returned value for the RBN_CHILDSIZE notify.
     88 * 15. Implement RBBS_CHILDEDGE, and set each bands "offChild" at _Layout
     89 *     time.
     90 * 16. Fix REBARSPACE. It should depend on CCS_NODIVIDER.
    9391 *
    9492 *
    9593 *    Still to do:
    96  *  2. Following still not handled: RBBS_FIXEDBMP, RBBS_CHILDEDGE,
    97  *            RBBS_USECHEVRON
    98  *  3. Following are only partially handled:
     94 *  2. Following still not handled: RBBS_FIXEDBMP,
     95 *            RBBS_USECHEVRON, CCS_NORESIZE,
     96 *            CCS_NOMOVEX, CCS_NOMOVEY
     97 *  3. Following are only partially handled:
    9998 *            RBS_AUTOSIZE, RBBS_VARIABLEHEIGHT
    10099 *  5. Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
    101  *     to set the size of the separator width (the value SEP_WIDTH_SIZE
     100 *     to set the size of the separator width (the value SEP_WIDTH_SIZE 
    102101 *     in here). Should be fixed!!
    103102 *  6. The following messages are not implemented:
     
    117116#include <string.h>
    118117
    119 #include "win.h"
    120118#include "winbase.h"
    121119#include "wingdi.h"
     
    134132typedef struct
    135133{
    136 #ifdef __WIN32OS2__
    137     COMCTL32_HEADER header;
    138 #endif
    139134    UINT    fStyle;
    140135    UINT    fMask;
     
    167162    UINT    fStatus;        /* status flags, reset only by _Validate */
    168163    UINT    fDraw;          /* drawing flags, reset only by _Layout */
     164    UINT    uCDret;         /* last return from NM_CUSTOMDRAW */
    169165    RECT    rcoldBand;      /* previous calculated band rectangle */
    170166    RECT    rcBand;         /* calculated band rectangle */
     
    191187#define NTF_INVALIDATE  0x01000000
    192188
    193 
    194189typedef struct
    195190{
     191    INT      istartband;  /* index of first band in row */
     192    INT      iendband;    /* index of last band in row */
     193} REBAR_ROW;
     194
     195
     196typedef struct
     197{
     198#ifdef __WIN32OS2__
     199    COMCTL32_HEADER header;
     200#endif
    196201    COLORREF   clrBk;       /* background color */
    197202    COLORREF   clrText;     /* text color */
     
    199204    COLORREF   clrBtnFace;  /* system color for BTNFACE */
    200205    HIMAGELIST himl;        /* handle to imagelist */
    201     UINT     uNumBands;   /* # of bands in rebar (first=0, last=uNumRows-1 */
     206    UINT     uNumBands;   /* # of bands in rebar (first=0, last=uNumBands-1 */
    202207    UINT     uNumRows;    /* # of rows of bands (first=1, last=uNumRows */
    203208    HWND     hwndSelf;    /* handle of REBAR window itself */
     
    212217    BOOL     NtfUnicode;  /* TRUE if parent wants notify in W format */
    213218    BOOL     DoRedraw;    /* TRUE to acutally draw bands */
    214     UINT     fStatus;     /* Status flags (see below)  */
     219    UINT     fStatus;     /* Status flags (see below)  */ 
    215220    HCURSOR  hcurArrow;   /* handle to the arrow cursor */
    216221    HCURSOR  hcurHorz;    /* handle to the EW cursor */
     
    223228    INT      ihitoffset;  /* offset of hotspot from gripper.left */
    224229
     230    REBAR_ROW  *rows;       /* pointer to row indexes              */
    225231    REBAR_BAND *bands;      /* pointer to the array of rebar bands */
    226232} REBAR_INFO;
     
    263269#define GRIPPER_WIDTH  3
    264270
    265 /* This is the increment that is used over the band height */
    266 /* Determined by experiment.                               */
    267 #define REBARSPACE      4
     271/* Height of divider for Rebar if not disabled (CCS_NODIVIDER)     */
     272/* either top or bottom                                            */
     273#define REBAR_DIVIDER  2
     274
     275/* This is the increment that is used over the band height         */
     276#define REBARSPACE(a)     ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
    268277
    269278/* ----   End of REBAR layout constants.                      ---- */
     
    275284#define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
    276285#define rcBw(b)  ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \
    277           (b->rcBand.right - b->rcBand.left))
     286                  (b->rcBand.right - b->rcBand.left))
    278287#define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
    279288#define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
    280289#define ircBw(b)  ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \
    281           (b->rcBand.bottom - b->rcBand.top))
     290                  (b->rcBand.bottom - b->rcBand.top))
    282291
    283292/*  The following define determines if a given band is hidden      */
     
    339348    *line = 0;
    340349    while (band_stylename[i]) {
    341     if (style & (1<<i)) {
    342         if (*line != 0) strcat(line, " | ");
    343         strcat(line, band_stylename[i]);
    344     }
    345     i++;
     350        if (style & (1<<i)) {
     351            if (*line != 0) strcat(line, " | ");
     352            strcat(line, band_stylename[i]);
     353        }
     354        i++;
    346355    }
    347356    return line;
     
    356365    *line = 0;
    357366    while (band_maskname[i]) {
    358     if (mask & (1<<i)) {
    359         if (*line != 0) strcat(line, " | ");
    360         strcat(line, band_maskname[i]);
    361     }
    362     i++;
     367        if (mask & (1<<i)) {
     368            if (*line != 0) strcat(line, " | ");
     369            strcat(line, band_maskname[i]);
     370        }
     371        i++;
    363372    }
    364373    return line;
     
    371380    if( !TRACE_ON(rebar) ) return;
    372381    TRACE("band info: ID=%u, size=%u, child=%04x, clrF=0x%06lx, clrB=0x%06lx\n",
    373       pB->wID, pB->cbSize, pB->hwndChild, pB->clrFore, pB->clrBack);
     382          pB->wID, pB->cbSize, pB->hwndChild, pB->clrFore, pB->clrBack);
    374383    TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask));
    375384    if (pB->fMask & RBBIM_STYLE)
    376     TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle));
     385        TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle));
    377386    if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_HEADERSIZE | RBBIM_LPARAM )) {
    378     TRACE("band info:");
    379     if (pB->fMask & RBBIM_SIZE)
    380         DPRINTF(" cx=%u", pB->cx);
    381     if (pB->fMask & RBBIM_IDEALSIZE)
    382         DPRINTF(" xIdeal=%u", pB->cxIdeal);
    383     if (pB->fMask & RBBIM_HEADERSIZE)
    384         DPRINTF(" xHeader=%u", pB->cxHeader);
    385     if (pB->fMask & RBBIM_LPARAM)
    386         DPRINTF(" lParam=0x%08lx", pB->lParam);
    387     DPRINTF("\n");
     387        TRACE("band info:");
     388        if (pB->fMask & RBBIM_SIZE)
     389            DPRINTF(" cx=%u", pB->cx);
     390        if (pB->fMask & RBBIM_IDEALSIZE)
     391            DPRINTF(" xIdeal=%u", pB->cxIdeal);
     392        if (pB->fMask & RBBIM_HEADERSIZE)
     393            DPRINTF(" xHeader=%u", pB->cxHeader);
     394        if (pB->fMask & RBBIM_LPARAM)
     395            DPRINTF(" lParam=0x%08lx", pB->lParam);
     396        DPRINTF("\n");
    388397    }
    389398    if (pB->fMask & RBBIM_CHILDSIZE)
    390     TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
    391           pB->cxMinChild,
    392           pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
     399        TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
     400              pB->cxMinChild,
     401              pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
    393402}
    394403
     
    401410    if(! TRACE_ON(rebar) ) return;
    402411
    403     TRACE("hwnd=%04x: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
    404       iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
    405       iP->calcSize.cx, iP->calcSize.cy);
     412    TRACE("hwnd=%04x: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n", 
     413          iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
     414          iP->calcSize.cx, iP->calcSize.cy);
    406415    TRACE("hwnd=%04x: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, ihitBand=%d\n",
    407       iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
    408       iP->dragNow.x, iP->dragNow.y,
    409       iP->ihitBand);
     416          iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
     417          iP->dragNow.x, iP->dragNow.y,
     418          iP->ihitBand);
    410419    TRACE("hwnd=%04x: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
    411       iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
    412       (iP->NtfUnicode)?"TRUE":"FALSE", (iP->DoRedraw)?"TRUE":"FALSE");
     420          iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
     421          (iP->NtfUnicode)?"TRUE":"FALSE", (iP->DoRedraw)?"TRUE":"FALSE");
    413422    for (i = 0; i < iP->uNumBands; i++) {
    414     pB = &iP->bands[i];
    415     TRACE("band # %u: ID=%u, child=%04x, row=%u, clrF=0x%06lx, clrB=0x%06lx\n",
    416           i, pB->wID, pB->hwndChild, pB->iRow, pB->clrFore, pB->clrBack);
    417     TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
    418     if (pB->fMask & RBBIM_STYLE)
    419         TRACE("band # %u: style=0x%08x (%s)\n",
    420           i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
    421     TRACE("band # %u: uMinH=%u xHeader=%u",
    422           i, pB->uMinHeight, pB->cxHeader);
    423     if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
    424         if (pB->fMask & RBBIM_SIZE)
    425         DPRINTF(" cx=%u", pB->cx);
    426         if (pB->fMask & RBBIM_IDEALSIZE)
    427         DPRINTF(" xIdeal=%u", pB->cxIdeal);
    428         if (pB->fMask & RBBIM_LPARAM)
    429         DPRINTF(" lParam=0x%08lx", pB->lParam);
    430     }
    431     DPRINTF("\n");
    432     if (RBBIM_CHILDSIZE)
    433         TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
    434           i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
    435     TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
    436           i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy);
    437     TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n",
    438           i, pB->fStatus, pB->fDraw,
    439           pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom,
    440           pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom);
    441     TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n",
    442           i,
    443           pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom,
    444           pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom,
    445           pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom);
     423        pB = &iP->bands[i];
     424        TRACE("band # %u: ID=%u, child=%04x, row=%u, clrF=0x%06lx, clrB=0x%06lx\n",
     425              i, pB->wID, pB->hwndChild, pB->iRow, pB->clrFore, pB->clrBack);
     426        TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
     427        if (pB->fMask & RBBIM_STYLE)
     428            TRACE("band # %u: style=0x%08x (%s)\n",
     429                  i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
     430        TRACE("band # %u: uMinH=%u xHeader=%u",
     431              i, pB->uMinHeight, pB->cxHeader);
     432        if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
     433            if (pB->fMask & RBBIM_SIZE)
     434                DPRINTF(" cx=%u", pB->cx);
     435            if (pB->fMask & RBBIM_IDEALSIZE)
     436                DPRINTF(" xIdeal=%u", pB->cxIdeal);
     437            if (pB->fMask & RBBIM_LPARAM)
     438                DPRINTF(" lParam=0x%08lx", pB->lParam);
     439        }
     440        DPRINTF("\n");
     441        if (RBBIM_CHILDSIZE)
     442            TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
     443                  i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
     444        if (pB->fMask & RBBIM_TEXT)
     445            TRACE("band # %u: text=%s\n",
     446                  i, (pB->lpText) ? debugstr_w(pB->lpText) : "(null)");
     447        TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
     448              i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy);
     449        TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n",
     450              i, pB->fStatus, pB->fDraw,
     451              pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom,
     452              pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom);
     453        TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n",
     454              i,
     455              pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom,
     456              pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom,
     457              pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom);
    446458    }
    447459
     
    457469    if (!parent) {
    458470        parent = GetParent (infoPtr->hwndSelf);
    459     owner = GetWindow (infoPtr->hwndSelf, GW_OWNER);
    460     if (owner) parent = owner;
     471        owner = GetWindow (infoPtr->hwndSelf, GW_OWNER);
     472        if (owner) parent = owner;
    461473    }
    462474    return parent;
     
    475487
    476488    TRACE("window %04x, code=%08x, %s\n", parent, code,
    477       (infoPtr->NtfUnicode) ? "via Unicode" : "via ANSI");
     489          (infoPtr->NtfUnicode) ? "via Unicode" : "via ANSI");
    478490
    479491    if (infoPtr->NtfUnicode)
    480     return SendMessageW (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
    481                  (LPARAM)nmhdr);
     492        return SendMessageW (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
     493                             (LPARAM)nmhdr);
    482494    else
    483     return SendMessageA (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
    484                  (LPARAM)nmhdr);
     495        return SendMessageA (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
     496                             (LPARAM)nmhdr);
    485497}
    486498
     
    493505    notify_rebar.dwMask = 0;
    494506    if (uBand!=-1) {
    495     lpBand = &infoPtr->bands[uBand];
    496     if (lpBand->fMask & RBBIM_ID) {
    497         notify_rebar.dwMask |= RBNM_ID;
    498         notify_rebar.wID = lpBand->wID;
    499     }
    500     if (lpBand->fMask & RBBIM_LPARAM) {
    501         notify_rebar.dwMask |= RBNM_LPARAM;
    502         notify_rebar.lParam = lpBand->lParam;
    503     }
    504     if (lpBand->fMask & RBBIM_STYLE) {
    505         notify_rebar.dwMask |= RBNM_STYLE;
    506         notify_rebar.fStyle = lpBand->fStyle;
    507     }
     507        lpBand = &infoPtr->bands[uBand];
     508        if (lpBand->fMask & RBBIM_ID) {
     509            notify_rebar.dwMask |= RBNM_ID;
     510            notify_rebar.wID = lpBand->wID;
     511        }
     512        if (lpBand->fMask & RBBIM_LPARAM) {
     513            notify_rebar.dwMask |= RBNM_LPARAM;
     514            notify_rebar.lParam = lpBand->lParam;
     515        }
     516        if (lpBand->fMask & RBBIM_STYLE) {
     517            notify_rebar.dwMask |= RBNM_STYLE;
     518            notify_rebar.fStyle = lpBand->fStyle;
     519        }
    508520    }
    509521    notify_rebar.uBand = uBand;
     
    514526REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
    515527{
    516 
     528    HFONT hOldFont = 0;
     529    INT oldBkMode = 0;
     530    NMCUSTOMDRAW nmcd;
     531
     532    if (lpBand->fDraw & DRAW_TEXT) {
     533        hOldFont = SelectObject (hdc, infoPtr->hFont);
     534        oldBkMode = SetBkMode (hdc, TRANSPARENT);
     535    }
     536
     537    /* should test for CDRF_NOTIFYITEMDRAW here */
     538    nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
     539    nmcd.hdc = hdc;
     540    nmcd.rc = lpBand->rcBand;
     541    nmcd.rc.right = lpBand->rcCapText.right;
     542    nmcd.rc.bottom = lpBand->rcCapText.bottom;
     543    nmcd.dwItemSpec = lpBand->wID;
     544    nmcd.uItemState = 0;
     545    nmcd.lItemlParam = lpBand->lParam;
     546    lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
     547    if (lpBand->uCDret == CDRF_SKIPDEFAULT) {
     548        if (oldBkMode != TRANSPARENT)
     549            SetBkMode (hdc, oldBkMode);
     550        SelectObject (hdc, hOldFont);
     551        return;
     552    }
    517553
    518554    /* draw gripper */
     
    522558    /* draw caption image */
    523559    if (lpBand->fDraw & DRAW_IMAGE) {
    524     POINT pt;
    525 
    526     /* center image */
    527     pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
    528     pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
    529 
    530     ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
    531             pt.x, pt.y,
    532             ILD_TRANSPARENT);
     560        POINT pt;
     561
     562        /* center image */
     563        pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
     564        pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
     565
     566        ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
     567                        pt.x, pt.y,
     568                        ILD_TRANSPARENT);
    533569    }
    534570
    535571    /* draw caption text */
    536572    if (lpBand->fDraw & DRAW_TEXT) {
    537     HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
    538     INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
    539     COLORREF oldcolor = CLR_NONE;
    540     oldcolor = SetTextColor (hdc, (lpBand->clrFore != CLR_NONE) ?
    541                  lpBand->clrFore : infoPtr->clrBtnText);
    542     DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
    543            DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    544     if (oldBkMode != TRANSPARENT)
    545         SetBkMode (hdc, oldBkMode);
    546     SetTextColor (hdc, oldcolor);
    547     SelectObject (hdc, hOldFont);
     573        /* need to handle CDRF_NEWFONT here */
     574        INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
     575        COLORREF oldcolor = CLR_NONE;
     576        oldcolor = SetTextColor (hdc, (lpBand->clrFore != CLR_NONE) ?
     577                                 lpBand->clrFore : infoPtr->clrBtnText);
     578        DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
     579                   DT_CENTER | DT_VCENTER | DT_SINGLELINE);
     580        if (oldBkMode != TRANSPARENT)
     581            SetBkMode (hdc, oldBkMode);
     582        SetTextColor (hdc, oldcolor);
     583        SelectObject (hdc, hOldFont);
     584    }
     585
     586    if (lpBand->uCDret == (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW)) {
     587        nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT;
     588        nmcd.hdc = hdc;
     589        nmcd.rc = lpBand->rcBand;
     590        nmcd.rc.right = lpBand->rcCapText.right;
     591        nmcd.rc.bottom = lpBand->rcCapText.bottom;
     592        nmcd.dwItemSpec = lpBand->wID;
     593        nmcd.uItemState = 0;
     594        nmcd.lItemlParam = lpBand->lParam;
     595        lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
    548596    }
    549597}
     
    560608    oldrow = infoPtr->bands[0].iRow;
    561609    for (i = 0; i < infoPtr->uNumBands; i++) {
    562     lpBand = &infoPtr->bands[i];
    563 
    564     if (HIDDENBAND(lpBand)) continue;
    565 
    566     /* now draw the band */
    567     REBAR_DrawBand (hdc, infoPtr, lpBand);
     610        lpBand = &infoPtr->bands[i];
     611
     612        if (HIDDENBAND(lpBand)) continue;
     613
     614        /* now draw the band */
     615        TRACE("[%04x] drawing band %i, flags=%08x\n",
     616              infoPtr->hwndSelf, i, lpBand->fDraw);
     617        REBAR_DrawBand (hdc, infoPtr, lpBand);
    568618
    569619    }
     
    573623static void
    574624REBAR_FixVert (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
    575            INT mcy)
    576      /* Function:                                                    */
     625                   INT mcy)
     626     /* Function:                                                    */ 
    577627     /*   Cycle through bands in row and fix height of each band.    */
    578628     /*   Also determine whether each band has changed.              */
     
    586636    for (i = (INT)rowstart; i<=(INT)rowend; i++) {
    587637        lpBand = &infoPtr->bands[i];
    588     if (HIDDENBAND(lpBand)) continue;
    589 
    590     /* adjust height of bands in row to "mcy" value */
    591     if (infoPtr->dwStyle & CCS_VERT) {
    592         if (lpBand->rcBand.right != lpBand->rcBand.left + mcy)
    593             lpBand->rcBand.right = lpBand->rcBand.left + mcy;
    594     }
    595     else {
    596         if (lpBand->rcBand.bottom != lpBand->rcBand.top + mcy)
    597             lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
    598 
    599     }
    600 
    601     /* mark whether we need to invalidate this band and trace */
    602     if ((lpBand->rcoldBand.left !=lpBand->rcBand.left) ||
    603         (lpBand->rcoldBand.top !=lpBand->rcBand.top) ||
    604         (lpBand->rcoldBand.right !=lpBand->rcBand.right) ||
    605         (lpBand->rcoldBand.bottom !=lpBand->rcBand.bottom)) {
    606         lpBand->fDraw |= NTF_INVALIDATE;
    607         TRACE("band %d row=%d: changed to (%d,%d)-(%d,%d) from (%d,%d)-(%d,%d)\n",
    608           i, lpBand->iRow,
    609           lpBand->rcBand.left, lpBand->rcBand.top,
    610           lpBand->rcBand.right, lpBand->rcBand.bottom,
    611           lpBand->rcoldBand.left, lpBand->rcoldBand.top,
    612           lpBand->rcoldBand.right, lpBand->rcoldBand.bottom);
    613     }
    614     else
    615         TRACE("band %d row=%d: unchanged (%d,%d)-(%d,%d)\n",
    616           i, lpBand->iRow,
    617           lpBand->rcBand.left, lpBand->rcBand.top,
    618           lpBand->rcBand.right, lpBand->rcBand.bottom);
     638        if (HIDDENBAND(lpBand)) continue;
     639
     640        /* adjust height of bands in row to "mcy" value */
     641        if (infoPtr->dwStyle & CCS_VERT) {
     642            if (lpBand->rcBand.right != lpBand->rcBand.left + mcy)
     643                lpBand->rcBand.right = lpBand->rcBand.left + mcy;
     644        }
     645        else {
     646            if (lpBand->rcBand.bottom != lpBand->rcBand.top + mcy)
     647                lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
     648
     649        }
     650
     651        /* mark whether we need to invalidate this band and trace */
     652        if ((lpBand->rcoldBand.left !=lpBand->rcBand.left) ||
     653            (lpBand->rcoldBand.top !=lpBand->rcBand.top) ||
     654            (lpBand->rcoldBand.right !=lpBand->rcBand.right) ||
     655            (lpBand->rcoldBand.bottom !=lpBand->rcBand.bottom)) {
     656            lpBand->fDraw |= NTF_INVALIDATE;
     657            TRACE("band %d row=%d: changed to (%d,%d)-(%d,%d) from (%d,%d)-(%d,%d)\n",
     658                  i, lpBand->iRow,
     659                  lpBand->rcBand.left, lpBand->rcBand.top,
     660                  lpBand->rcBand.right, lpBand->rcBand.bottom,
     661                  lpBand->rcoldBand.left, lpBand->rcoldBand.top,
     662                  lpBand->rcoldBand.right, lpBand->rcoldBand.bottom);
     663        }
     664        else
     665            TRACE("band %d row=%d: unchanged (%d,%d)-(%d,%d)\n",
     666                  i, lpBand->iRow,
     667                  lpBand->rcBand.left, lpBand->rcBand.top,
     668                  lpBand->rcBand.right, lpBand->rcBand.bottom);
    619669    }
    620670}
     
    623673static void
    624674REBAR_AdjustBands (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
    625            INT maxx, INT mcy)
     675                   INT maxx, INT mcy)
    626676     /* Function: This routine distributes the extra space in a row. */
    627677     /*  See algorithm below.                                        */
     
    635685
    636686    TRACE("start=%u, end=%u, max x=%d, max y=%d\n",
    637       rowstart, rowend, maxx, mcy);
     687          rowstart, rowend, maxx, mcy);
    638688
    639689    /* *******************  Phase 1  ************************ */
     
    643693    /*         or band's ->ccx reached.                       */
    644694    /*  If any band modified, add any space left to last band */
    645     /*  adjusted.                                             */
     695    /*  adjusted.                                             */ 
    646696    /*                                                        */
    647697    /* ****************************************************** */
     
    649699    extra = maxx - rcBrb(lpBand);
    650700    x = 0;
    651     last_adjusted = 0;
     701    last_adjusted = -1;
    652702    for (i=(INT)rowstart; i<=(INT)rowend; i++) {
    653     lpBand = &infoPtr->bands[i];
    654     if (HIDDENBAND(lpBand)) continue;
    655     xsep = (x == 0) ? 0 : SEP_WIDTH;
    656     curwidth = rcBw(lpBand);
    657 
    658     /* set new left/top point */
    659     if (infoPtr->dwStyle & CCS_VERT)
    660         lpBand->rcBand.top = x + xsep;
    661     else
    662         lpBand->rcBand.left = x + xsep;
    663 
    664     /* compute new width */
    665     if (lpBand->hwndChild && extra) {
    666         /* set to the "current" band size less the header */
    667         fudge = lpBand->ccx;
    668         last_adjusted = i;
    669         if ((lpBand->fMask & RBBIM_SIZE) && (lpBand->cx > 0) &&
    670         (fudge > curwidth)) {
    671         TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
    672               i, fudge-curwidth, fudge, curwidth, extra);
    673         if ((fudge - curwidth) > extra)
    674             fudge = curwidth + extra;
    675         extra -= (fudge - curwidth);
    676         curwidth = fudge;
    677         }
    678         else {
    679         TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
    680               i, extra, fudge, curwidth);
    681         curwidth += extra;
    682         extra = 0;
    683         }
    684     }
    685 
    686     /* set new right/bottom point */
    687     if (infoPtr->dwStyle & CCS_VERT)
    688         lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
    689     else
    690         lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
    691     TRACE("Phase 1 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
    692           i, lpBand->rcBand.left, lpBand->rcBand.top,
    693           lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
    694     x = rcBrb(lpBand);
    695     }
    696     if ((x >= maxx) || last_adjusted) {
    697     if (x > maxx) {
    698         ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
    699         x, maxx,  rowstart, rowend);
    700     }
    701     /* done, so spread extra space */
    702     if (x < maxx) {
    703         fudge = maxx - x;
    704         TRACE("Need to spread %d on last adjusted band %d\n",
    705         fudge, last_adjusted);
    706         for (i=(INT)last_adjusted; i<=(INT)rowend; i++) {
    707         lpBand = &infoPtr->bands[i];
    708         if (HIDDENBAND(lpBand)) continue;
    709 
    710         /* set right/bottom point */
    711         if (i != last_adjusted) {
    712             if (infoPtr->dwStyle & CCS_VERT)
    713             lpBand->rcBand.top += fudge;
    714             else
    715             lpBand->rcBand.left += fudge;
    716         }
    717 
    718         /* set left/bottom point */
    719         if (infoPtr->dwStyle & CCS_VERT)
    720             lpBand->rcBand.bottom += fudge;
    721         else
    722             lpBand->rcBand.right += fudge;
    723         }
    724     }
    725     TRACE("Phase 1 succeeded, used x=%d\n", x);
    726     REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
    727     return;
     703        lpBand = &infoPtr->bands[i];
     704        if (HIDDENBAND(lpBand)) continue;
     705        xsep = (x == 0) ? 0 : SEP_WIDTH;
     706        curwidth = rcBw(lpBand);
     707
     708        /* set new left/top point */
     709        if (infoPtr->dwStyle & CCS_VERT)
     710            lpBand->rcBand.top = x + xsep;
     711        else
     712            lpBand->rcBand.left = x + xsep;
     713
     714        /* compute new width */
     715        if (lpBand->hwndChild && extra) {
     716            /* set to the "current" band size less the header */
     717            fudge = lpBand->ccx;
     718            last_adjusted = i;
     719            if ((lpBand->fMask & RBBIM_SIZE) && (lpBand->cx > 0) &&
     720                (fudge > curwidth)) {
     721                TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
     722                      i, fudge-curwidth, fudge, curwidth, extra);
     723                if ((fudge - curwidth) > extra)
     724                    fudge = curwidth + extra;
     725                extra -= (fudge - curwidth);
     726                curwidth = fudge;
     727            }
     728            else {
     729                TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
     730                      i, extra, fudge, curwidth);
     731                curwidth += extra;
     732                extra = 0;
     733            }
     734        }
     735
     736        /* set new right/bottom point */
     737        if (infoPtr->dwStyle & CCS_VERT)
     738            lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
     739        else
     740            lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
     741        TRACE("Phase 1 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
     742              i, lpBand->rcBand.left, lpBand->rcBand.top,
     743              lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
     744        x = rcBrb(lpBand);
     745    }
     746    if ((x >= maxx) || (last_adjusted != -1)) {
     747        if (x > maxx) {
     748            ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
     749                x, maxx,  rowstart, rowend);
     750        }
     751        /* done, so spread extra space */
     752        if (x < maxx) {
     753            fudge = maxx - x;
     754            TRACE("Need to spread %d on last adjusted band %d\n",
     755                fudge, last_adjusted);
     756            for (i=(INT)last_adjusted; i<=(INT)rowend; i++) {
     757                lpBand = &infoPtr->bands[i];
     758                if (HIDDENBAND(lpBand)) continue;
     759
     760                /* set right/bottom point */
     761                if (i != last_adjusted) {
     762                    if (infoPtr->dwStyle & CCS_VERT)
     763                        lpBand->rcBand.top += fudge;
     764                    else
     765                        lpBand->rcBand.left += fudge;
     766                }
     767
     768                /* set left/bottom point */
     769                if (infoPtr->dwStyle & CCS_VERT)
     770                    lpBand->rcBand.bottom += fudge;
     771                else
     772                    lpBand->rcBand.right += fudge;
     773            }
     774        }
     775        TRACE("Phase 1 succeeded, used x=%d\n", x);
     776        REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
     777        return;
    728778    }
    729779
     
    737787    x = 0;
    738788    for (i=(INT)rowstart; i<=(INT)rowend; i++) {
    739     lpBand = &infoPtr->bands[i];
    740     if (HIDDENBAND(lpBand)) continue;
    741     xsep = (x == 0) ? 0 : SEP_WIDTH;
    742     curwidth = rcBw(lpBand);
    743 
    744     /* set new left/top point */
    745     if (infoPtr->dwStyle & CCS_VERT)
    746         lpBand->rcBand.top = x + xsep;
    747     else
    748         lpBand->rcBand.left = x + xsep;
    749 
    750     /* compute new width */
    751     if (extra) {
    752         curwidth += extra;
    753         extra = 0;
    754     }
    755 
    756     /* set new right/bottom point */
    757     if (infoPtr->dwStyle & CCS_VERT)
    758         lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
    759     else
    760         lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
    761     TRACE("Phase 2 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
    762           i, lpBand->rcBand.left, lpBand->rcBand.top,
    763           lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
    764     x = rcBrb(lpBand);
     789        lpBand = &infoPtr->bands[i];
     790        if (HIDDENBAND(lpBand)) continue;
     791        xsep = (x == 0) ? 0 : SEP_WIDTH;
     792        curwidth = rcBw(lpBand);
     793
     794        /* set new left/top point */
     795        if (infoPtr->dwStyle & CCS_VERT)
     796            lpBand->rcBand.top = x + xsep;
     797        else
     798            lpBand->rcBand.left = x + xsep;
     799
     800        /* compute new width */
     801        if (extra) {
     802            curwidth += extra;
     803            extra = 0;
     804        }
     805
     806        /* set new right/bottom point */
     807        if (infoPtr->dwStyle & CCS_VERT)
     808            lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
     809        else
     810            lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
     811        TRACE("Phase 2 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
     812              i, lpBand->rcBand.left, lpBand->rcBand.top,
     813              lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
     814        x = rcBrb(lpBand);
    765815    }
    766816    if (x >= maxx) {
    767     if (x > maxx) {
    768         ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
    769         x, maxx,  rowstart, rowend);
    770     }
    771     /* done, so spread extra space */
    772     TRACE("Phase 2 succeeded, used x=%d\n", x);
    773     REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
    774     return;
     817        if (x > maxx) {
     818            ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
     819                x, maxx,  rowstart, rowend);
     820        }
     821        /* done, so spread extra space */
     822        TRACE("Phase 2 succeeded, used x=%d\n", x);
     823        REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
     824        return;
    775825    }
    776826
     
    782832    lpBand = &infoPtr->bands[rowstart];
    783833    ERR("Serious problem adjusting row %d, start band %d, end band %d\n",
    784     lpBand->iRow, rowstart, rowend);
     834        lpBand->iRow, rowstart, rowend);
    785835    REBAR_DumpBand (infoPtr);
    786836    return;
     
    806856      if (HIDDENBAND(lpBand)) {
    807857          SetRect (&lpBand->rcChild,
    808            lpBand->rcBand.right, lpBand->rcBand.top,
    809            lpBand->rcBand.right, lpBand->rcBand.bottom);
    810       continue;
     858                   lpBand->rcBand.right, lpBand->rcBand.top,
     859                   lpBand->rcBand.right, lpBand->rcBand.bottom);
     860          continue;
    811861      }
    812862
     
    815865      /* set initial gripper rectangle */
    816866      SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
    817            lpBand->rcBand.left, lpBand->rcBand.bottom);
     867               lpBand->rcBand.left, lpBand->rcBand.bottom);
    818868
    819869      /* calculate gripper rectangle */
    820870      if ( lpBand->fStatus & HAS_GRIPPER) {
    821       lpBand->fDraw |= DRAW_GRIPPER;
    822       lpBand->rcGripper.left   += REBAR_PRE_GRIPPER;
    823       lpBand->rcGripper.right  = lpBand->rcGripper.left + GRIPPER_WIDTH;
    824       lpBand->rcGripper.top    += 2;
    825       lpBand->rcGripper.bottom -= 2;
    826 
    827       SetRect (&lpBand->rcCapImage,
    828            lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.top,
    829            lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.bottom);
     871          lpBand->fDraw |= DRAW_GRIPPER;
     872          lpBand->rcGripper.left   += REBAR_PRE_GRIPPER;
     873          lpBand->rcGripper.right  = lpBand->rcGripper.left + GRIPPER_WIDTH;
     874          lpBand->rcGripper.top    += 2;
     875          lpBand->rcGripper.bottom -= 2;
     876
     877          SetRect (&lpBand->rcCapImage,
     878                   lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.top,
     879                   lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.bottom);
    830880      }
    831881      else {  /* no gripper will be drawn */
    832       xoff = 0;
    833       if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
    834           /* if no gripper but either image or text, then leave space */
    835           xoff = REBAR_ALWAYS_SPACE;
    836       SetRect (&lpBand->rcCapImage,
    837            lpBand->rcBand.left+xoff, lpBand->rcBand.top,
    838            lpBand->rcBand.left+xoff, lpBand->rcBand.bottom);
     882          xoff = 0;
     883          if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
     884              /* if no gripper but either image or text, then leave space */
     885              xoff = REBAR_ALWAYS_SPACE;
     886          SetRect (&lpBand->rcCapImage,
     887                   lpBand->rcBand.left+xoff, lpBand->rcBand.top,
     888                   lpBand->rcBand.left+xoff, lpBand->rcBand.bottom);
    839889      }
    840890
    841891      /* image is visible */
    842892      if (lpBand->fStatus & HAS_IMAGE) {
    843       lpBand->fDraw |= DRAW_IMAGE;
    844       lpBand->rcCapImage.right  += infoPtr->imageSize.cx;
    845       lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
    846 
    847       /* set initial caption text rectangle */
    848       SetRect (&lpBand->rcCapText,
    849            lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1,
    850            lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
    851       /* update band height
    852       if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
    853           lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
    854           lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
    855       }  */
     893          lpBand->fDraw |= DRAW_IMAGE;
     894          lpBand->rcCapImage.right  += infoPtr->imageSize.cx;
     895          lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
     896
     897          /* set initial caption text rectangle */
     898          SetRect (&lpBand->rcCapText,
     899                   lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1,
     900                   lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
     901          /* update band height
     902          if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
     903              lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
     904              lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
     905          }  */
    856906      }
    857907      else {
    858       /* set initial caption text rectangle */
    859       SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1,
    860            lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
     908          /* set initial caption text rectangle */
     909          SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1,
     910                   lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
    861911      }
    862912
    863913      /* text is visible */
    864914      if (lpBand->fStatus & HAS_TEXT) {
    865       lpBand->fDraw |= DRAW_TEXT;
    866       lpBand->rcCapText.right = max(lpBand->rcCapText.left,
    867                     lpBand->rcCapText.right-REBAR_POST_TEXT);
     915          lpBand->fDraw |= DRAW_TEXT;
     916          lpBand->rcCapText.right = max(lpBand->rcCapText.left,
     917                                        lpBand->rcCapText.right-REBAR_POST_TEXT);
    868918      }
    869919
    870920      /* set initial child window rectangle if there is a child */
    871921      if (lpBand->fMask & RBBIM_CHILD) {
    872       xoff = lpBand->offChild.cx;
    873       yoff = lpBand->offChild.cy;
    874       SetRect (&lpBand->rcChild,
    875            lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top+yoff,
    876            lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
     922          xoff = lpBand->offChild.cx;
     923          yoff = lpBand->offChild.cy;
     924          SetRect (&lpBand->rcChild,
     925                   lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top+yoff,
     926                   lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
    877927      }
    878928      else {
    879929          SetRect (&lpBand->rcChild,
    880            lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top,
    881            lpBand->rcBand.right, lpBand->rcBand.bottom);
     930                   lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top,
     931                   lpBand->rcBand.right, lpBand->rcBand.bottom);
    882932      }
    883933
    884934      /* flag if notify required and invalidate rectangle */
    885       if (notify &&
    886       ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
    887        (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
    888       TRACE("Child rectangle changed for band %u\n", i);
    889       TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
    890         oldChild.left, oldChild.top,
    891             oldChild.right, oldChild.bottom,
    892         lpBand->rcChild.left, lpBand->rcChild.top,
    893             lpBand->rcChild.right, lpBand->rcChild.bottom);
     935      if (notify && 
     936          ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
     937           (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
     938          TRACE("Child rectangle changed for band %u\n", i);
     939          TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
     940                oldChild.left, oldChild.top,
     941                oldChild.right, oldChild.bottom,
     942                lpBand->rcChild.left, lpBand->rcChild.top,
     943                lpBand->rcChild.right, lpBand->rcChild.bottom);
    894944      }
    895945      if (lpBand->fDraw & NTF_INVALIDATE) {
    896       TRACE("invalidating (%d,%d)-(%d,%d)\n",
    897         lpBand->rcBand.left,
    898         lpBand->rcBand.top,
    899         lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0),
    900         lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0));
    901       lpBand->fDraw &= ~NTF_INVALIDATE;
    902       work = lpBand->rcBand;
    903       if (lpBand->fDraw & DRAW_RIGHTSEP) work.right += SEP_WIDTH_SIZE;
    904       if (lpBand->fDraw & DRAW_BOTTOMSEP) work.bottom += SEP_WIDTH_SIZE;
    905       InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
     946          TRACE("invalidating (%d,%d)-(%d,%d)\n",
     947                lpBand->rcBand.left,
     948                lpBand->rcBand.top,
     949                lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0),
     950                lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0));
     951          lpBand->fDraw &= ~NTF_INVALIDATE;
     952          work = lpBand->rcBand;
     953          if (lpBand->fDraw & DRAW_RIGHTSEP) work.right += SEP_WIDTH_SIZE;
     954          if (lpBand->fDraw & DRAW_BOTTOMSEP) work.bottom += SEP_WIDTH_SIZE;
     955          InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
    906956      }
    907957
     
    926976
    927977    for(i=rstart; i<rend; i++){
    928     lpBand = &infoPtr->bands[i];
    929     if (HIDDENBAND(lpBand)) continue;
    930     oldChild = lpBand->rcChild;
    931 
    932     /* set initial gripper rectangle */
    933     SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
    934         lpBand->rcBand.right, lpBand->rcBand.top);
    935 
    936     /* calculate gripper rectangle */
    937     if (lpBand->fStatus & HAS_GRIPPER) {
    938         lpBand->fDraw |= DRAW_GRIPPER;
    939 
    940         if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) {
    941         /*  vertical gripper  */
    942         lpBand->rcGripper.left   += 3;
    943         lpBand->rcGripper.right  = lpBand->rcGripper.left + GRIPPER_WIDTH;
    944         lpBand->rcGripper.top    += REBAR_PRE_GRIPPER;
    945         lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT;
    946 
    947         /* initialize Caption image rectangle  */
    948         SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
    949             lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
    950             lpBand->rcBand.right,
    951             lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
    952         }
    953         else {
    954         /*  horizontal gripper  */
    955         lpBand->rcGripper.left   += 3;
    956         lpBand->rcGripper.right  -= 3;
    957         lpBand->rcGripper.top    += REBAR_PRE_GRIPPER;
    958         lpBand->rcGripper.bottom  = lpBand->rcGripper.top + GRIPPER_WIDTH;
    959 
    960         /* initialize Caption image rectangle  */
    961         SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
    962             lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
    963             lpBand->rcBand.right,
    964             lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
    965         }
    966     }
    967     else {  /* no gripper will be drawn */
    968         xoff = 0;
    969         if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
    970         /* if no gripper but either image or text, then leave space */
    971         xoff = REBAR_ALWAYS_SPACE;
    972         /* initialize Caption image rectangle  */
    973         SetRect (&lpBand->rcCapImage,
    974              lpBand->rcBand.left, lpBand->rcBand.top+xoff,
    975              lpBand->rcBand.right, lpBand->rcBand.top+xoff);
    976     }
    977 
    978     /* image is visible */
    979     if (lpBand->fStatus & HAS_IMAGE) {
    980         lpBand->fDraw |= DRAW_IMAGE;
    981 
    982         lpBand->rcCapImage.right  = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
    983         lpBand->rcCapImage.bottom += infoPtr->imageSize.cy;
    984 
    985         /* set initial caption text rectangle */
    986         SetRect (&lpBand->rcCapText,
    987              lpBand->rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE,
    988              lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
    989         /* update band height *
    990            if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
    991            lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
    992            lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
    993            } */
    994     }
    995     else {
    996         /* set initial caption text rectangle */
    997         SetRect (&lpBand->rcCapText,
    998              lpBand->rcBand.left, lpBand->rcCapImage.bottom,
    999              lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
    1000     }
    1001 
    1002     /* text is visible */
    1003     if (lpBand->fStatus & HAS_TEXT) {
    1004         lpBand->fDraw |= DRAW_TEXT;
    1005         lpBand->rcCapText.bottom = max(lpBand->rcCapText.top,
    1006                        lpBand->rcCapText.bottom-REBAR_POST_TEXT);
    1007     }
    1008 
    1009     /* set initial child window rectangle if there is a child */
    1010     if (lpBand->fMask & RBBIM_CHILD) {
    1011         yoff = lpBand->offChild.cx;
    1012         xoff = lpBand->offChild.cy;
    1013         SetRect (&lpBand->rcChild,
    1014              lpBand->rcBand.left+xoff, lpBand->rcBand.top+lpBand->cxHeader,
    1015              lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
    1016     }
    1017     else {
    1018         SetRect (&lpBand->rcChild,
    1019              lpBand->rcBand.left, lpBand->rcBand.top+lpBand->cxHeader,
    1020              lpBand->rcBand.right, lpBand->rcBand.bottom);
    1021     }
    1022 
    1023     /* flag if notify required and invalidate rectangle */
    1024     if (notify &&
    1025         ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
    1026          (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
    1027         TRACE("Child rectangle changed for band %u\n", i);
    1028         TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
    1029           oldChild.left, oldChild.top,
    1030           oldChild.right, oldChild.bottom,
    1031           lpBand->rcChild.left, lpBand->rcChild.top,
    1032           lpBand->rcChild.right, lpBand->rcChild.bottom);
    1033     }
    1034     if (lpBand->fDraw & NTF_INVALIDATE) {
    1035         TRACE("invalidating (%d,%d)-(%d,%d)\n",
    1036           lpBand->rcBand.left,
    1037           lpBand->rcBand.top,
    1038           lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0),
    1039           lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0));
    1040         lpBand->fDraw &= ~NTF_INVALIDATE;
    1041         work = lpBand->rcBand;
    1042         if (lpBand->fDraw & DRAW_RIGHTSEP) work.bottom += SEP_WIDTH_SIZE;
    1043         if (lpBand->fDraw & DRAW_BOTTOMSEP) work.right += SEP_WIDTH_SIZE;
    1044         InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
    1045     }
     978        lpBand = &infoPtr->bands[i];
     979        if (HIDDENBAND(lpBand)) continue;
     980        oldChild = lpBand->rcChild;
     981
     982        /* set initial gripper rectangle */
     983        SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
     984                lpBand->rcBand.right, lpBand->rcBand.top);
     985
     986        /* calculate gripper rectangle */
     987        if (lpBand->fStatus & HAS_GRIPPER) {
     988            lpBand->fDraw |= DRAW_GRIPPER;
     989
     990            if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) {
     991                /*  vertical gripper  */
     992                lpBand->rcGripper.left   += 3;
     993                lpBand->rcGripper.right  = lpBand->rcGripper.left + GRIPPER_WIDTH;
     994                lpBand->rcGripper.top    += REBAR_PRE_GRIPPER;
     995                lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT;
     996
     997                /* initialize Caption image rectangle  */
     998                SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
     999                        lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
     1000                        lpBand->rcBand.right,
     1001                        lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
     1002            }
     1003            else {
     1004                /*  horizontal gripper  */
     1005                lpBand->rcGripper.left   += 2;
     1006                lpBand->rcGripper.right  -= 2;
     1007                lpBand->rcGripper.top    += REBAR_PRE_GRIPPER;
     1008                lpBand->rcGripper.bottom  = lpBand->rcGripper.top + GRIPPER_WIDTH;
     1009
     1010                /* initialize Caption image rectangle  */
     1011                SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
     1012                        lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
     1013                        lpBand->rcBand.right,
     1014                        lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
     1015            }
     1016        }
     1017        else {  /* no gripper will be drawn */
     1018            xoff = 0;
     1019            if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
     1020                /* if no gripper but either image or text, then leave space */
     1021                xoff = REBAR_ALWAYS_SPACE;
     1022            /* initialize Caption image rectangle  */
     1023            SetRect (&lpBand->rcCapImage,
     1024                     lpBand->rcBand.left, lpBand->rcBand.top+xoff,
     1025                     lpBand->rcBand.right, lpBand->rcBand.top+xoff);
     1026        }
     1027
     1028        /* image is visible */
     1029        if (lpBand->fStatus & HAS_IMAGE) {
     1030            lpBand->fDraw |= DRAW_IMAGE;
     1031
     1032            lpBand->rcCapImage.right  = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
     1033            lpBand->rcCapImage.bottom += infoPtr->imageSize.cy;
     1034
     1035            /* set initial caption text rectangle */
     1036            SetRect (&lpBand->rcCapText,
     1037                     lpBand->rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE,
     1038                     lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
     1039            /* update band height *
     1040               if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
     1041               lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
     1042               lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
     1043               } */
     1044        }
     1045        else {
     1046            /* set initial caption text rectangle */
     1047            SetRect (&lpBand->rcCapText,
     1048                     lpBand->rcBand.left, lpBand->rcCapImage.bottom,
     1049                     lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
     1050        }
     1051
     1052        /* text is visible */
     1053        if (lpBand->fStatus & HAS_TEXT) {
     1054            lpBand->fDraw |= DRAW_TEXT;
     1055            lpBand->rcCapText.bottom = max(lpBand->rcCapText.top,
     1056                                           lpBand->rcCapText.bottom);
     1057        }
     1058
     1059        /* set initial child window rectangle if there is a child */
     1060        if (lpBand->fMask & RBBIM_CHILD) {
     1061            yoff = lpBand->offChild.cx;
     1062            xoff = lpBand->offChild.cy;
     1063            SetRect (&lpBand->rcChild,
     1064                     lpBand->rcBand.left+xoff, lpBand->rcBand.top+lpBand->cxHeader,
     1065                     lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
     1066        }
     1067        else {
     1068            SetRect (&lpBand->rcChild,
     1069                     lpBand->rcBand.left, lpBand->rcBand.top+lpBand->cxHeader,
     1070                     lpBand->rcBand.right, lpBand->rcBand.bottom);
     1071        }
     1072
     1073        /* flag if notify required and invalidate rectangle */
     1074        if (notify &&
     1075            ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
     1076             (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
     1077            TRACE("Child rectangle changed for band %u\n", i);
     1078            TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
     1079                  oldChild.left, oldChild.top,
     1080                  oldChild.right, oldChild.bottom,
     1081                  lpBand->rcChild.left, lpBand->rcChild.top,
     1082                  lpBand->rcChild.right, lpBand->rcChild.bottom);
     1083        }
     1084        if (lpBand->fDraw & NTF_INVALIDATE) {
     1085            TRACE("invalidating (%d,%d)-(%d,%d)\n",
     1086                  lpBand->rcBand.left,
     1087                  lpBand->rcBand.top,
     1088                  lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0),
     1089                  lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0));
     1090            lpBand->fDraw &= ~NTF_INVALIDATE;
     1091            work = lpBand->rcBand;
     1092            if (lpBand->fDraw & DRAW_RIGHTSEP) work.bottom += SEP_WIDTH_SIZE;
     1093            if (lpBand->fDraw & DRAW_BOTTOMSEP) work.right += SEP_WIDTH_SIZE;
     1094            InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
     1095        }
    10461096
    10471097    }
     
    10551105{
    10561106    RECT rc;
     1107    INT x, y, width, height;
     1108    INT xedge = GetSystemMetrics(SM_CXEDGE);
     1109    INT yedge = GetSystemMetrics(SM_CYEDGE);
    10571110
    10581111    /* TEST TEST TEST */
     
    10641117
    10651118    TRACE( " old [%ld x %ld], new [%ld x %ld], client [%d x %d]\n",
    1066        infoPtr->oldSize.cx, infoPtr->oldSize.cy,
    1067        infoPtr->calcSize.cx, infoPtr->calcSize.cy,
    1068        rc.right, rc.bottom);
     1119           infoPtr->oldSize.cx, infoPtr->oldSize.cy,
     1120           infoPtr->calcSize.cx, infoPtr->calcSize.cy,
     1121           rc.right, rc.bottom);
    10691122
    10701123    /* If we need to shrink client, then skip size test */
    10711124    if ((infoPtr->calcSize.cy >= rc.bottom) &&
    1072     (infoPtr->calcSize.cx >= rc.right)) {
    1073 
    1074     /* if size did not change then skip process */
    1075     if ((infoPtr->oldSize.cx == infoPtr->calcSize.cx) &&
    1076         (infoPtr->oldSize.cy == infoPtr->calcSize.cy) &&
    1077         !(infoPtr->fStatus & RESIZE_ANYHOW))
    1078         {
    1079         TRACE("skipping reset\n");
    1080         return;
    1081         }
     1125        (infoPtr->calcSize.cx >= rc.right)) {
     1126
     1127        /* if size did not change then skip process */
     1128        if ((infoPtr->oldSize.cx == infoPtr->calcSize.cx) &&
     1129            (infoPtr->oldSize.cy == infoPtr->calcSize.cy) &&
     1130            !(infoPtr->fStatus & RESIZE_ANYHOW))
     1131            {
     1132                TRACE("skipping reset\n");
     1133                return;
     1134            }
    10821135    }
    10831136
     
    10861139    infoPtr->fStatus |= AUTO_RESIZE;
    10871140
    1088     rc.left = 0;
    1089     rc.top = 0;
    1090     rc.right  = infoPtr->calcSize.cx;
    1091     rc.bottom = infoPtr->calcSize.cy;
    1092 
    1093     InflateRect (&rc, 0, GetSystemMetrics(SM_CYEDGE));
    1094     /* see comments in _NCCalcSize for reason below is not done */
    1095 #if 0
    1096     if (GetWindowLongA (infoPtr->hwndSelf, GWL_STYLE) & WS_BORDER) {
    1097     InflateRect (&rc, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
    1098     }
    1099 #endif
    1100 
    1101     TRACE("setting to (0,0)-(%d,%d)\n",
    1102       rc.right - rc.left, rc.bottom - rc.top);
    1103     SetWindowPos (infoPtr->hwndSelf, 0, 0, 0,
    1104             rc.right - rc.left, rc.bottom - rc.top,
    1105             SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW);
     1141    width = 0;
     1142    height = 0;
     1143    x = 0;
     1144    y = 0;
     1145
     1146    if (infoPtr->dwStyle & WS_BORDER) {
     1147        width = 2 * xedge;
     1148        height = 2 * yedge;
     1149    }
     1150
     1151    if (!(infoPtr->dwStyle & CCS_NOPARENTALIGN)) {
     1152        INT mode = infoPtr->dwStyle & (CCS_VERT | CCS_TOP | CCS_BOTTOM);
     1153        RECT rcPcl;
     1154
     1155        GetClientRect(GetParent(infoPtr->hwndSelf), &rcPcl);
     1156        switch (mode) {
     1157        case CCS_TOP:
     1158            /* _TOP sets width to parents width */
     1159            width += (rcPcl.right - rcPcl.left);
     1160            height += infoPtr->calcSize.cy;
     1161            x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
     1162            y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
     1163            y += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
     1164            break;
     1165        case CCS_BOTTOM:
     1166            /* FIXME: wrong wrong wrong */
     1167            /* _BOTTOM sets width to parents width */
     1168            width += (rcPcl.right - rcPcl.left);
     1169            height += infoPtr->calcSize.cy;
     1170            x += -xedge;
     1171            y = rcPcl.bottom - height + 1;
     1172            break;
     1173        case CCS_LEFT:
     1174            /* _LEFT sets height to parents height */
     1175            width += infoPtr->calcSize.cx;
     1176            height += (rcPcl.bottom - rcPcl.top);
     1177            x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
     1178            x += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
     1179            y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
     1180            break;
     1181        case CCS_RIGHT:
     1182            /* FIXME: wrong wrong wrong */
     1183            /* _RIGHT sets height to parents height */
     1184            width += infoPtr->calcSize.cx;
     1185            height += (rcPcl.bottom - rcPcl.top);
     1186            x = rcPcl.right - width + 1;
     1187            y = -yedge;
     1188            break;
     1189        default:
     1190            width += infoPtr->calcSize.cx;
     1191            height += infoPtr->calcSize.cy;
     1192        }
     1193    }
     1194    else {
     1195        width += infoPtr->calcSize.cx;
     1196        height += infoPtr->calcSize.cy;
     1197    }
     1198
     1199    TRACE("hwnd %04x, style=%08lx, setting at (%d,%d) for (%d,%d)\n",
     1200        infoPtr->hwndSelf, infoPtr->dwStyle,
     1201        x, y, width, height);
     1202    SetWindowPos (infoPtr->hwndSelf, 0, x, y, width, height,
     1203                    SWP_NOZORDER);
    11061204}
    11071205
     
    11211219
    11221220    for (i = start; i < endplus; i++) {
    1123     lpBand = &infoPtr->bands[i];
    1124 
    1125     if (HIDDENBAND(lpBand)) continue;
    1126     if (lpBand->hwndChild) {
    1127         TRACE("hwndChild = %x\n", lpBand->hwndChild);
    1128 
    1129         /* Always geterate the RBN_CHILDSIZE even it child
    1130            did not change */
    1131         rbcz.uBand = i;
    1132         rbcz.wID = lpBand->wID;
    1133         rbcz.rcChild = lpBand->rcChild;
    1134         rbcz.rcBand = lpBand->rcBand;
    1135         rbcz.rcBand.left += lpBand->cxHeader;
    1136         REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
    1137         if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
    1138         TRACE("Child rect changed by NOTIFY for band %u\n", i);
    1139         TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
    1140               lpBand->rcChild.left, lpBand->rcChild.top,
    1141               lpBand->rcChild.right, lpBand->rcChild.bottom,
    1142               rbcz.rcChild.left, rbcz.rcChild.top,
    1143               rbcz.rcChild.right, rbcz.rcChild.bottom);
    1144         }
    1145 
    1146         GetClassNameA (lpBand->hwndChild, szClassName, 40);
    1147         if (!lstrcmpA (szClassName, "ComboBox") ||
    1148         !lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
    1149         INT nEditHeight, yPos;
    1150         RECT rc;
    1151 
    1152         /* special placement code for combo or comboex box */
    1153 
    1154 
    1155         /* get size of edit line */
    1156         GetWindowRect (lpBand->hwndChild, &rc);
    1157         nEditHeight = rc.bottom - rc.top;
    1158         yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
    1159 
    1160         /* center combo box inside child area */
    1161         TRACE("moving child (Combo(Ex)) %04x to (%d,%d) for (%d,%d)\n",
    1162               lpBand->hwndChild,
    1163               lpBand->rcChild.left, yPos,
    1164               lpBand->rcChild.right - lpBand->rcChild.left,
    1165               nEditHeight);
    1166         deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
    1167                        lpBand->rcChild.left,
    1168                        /*lpBand->rcChild.top*/ yPos,
    1169                        lpBand->rcChild.right - lpBand->rcChild.left,
    1170                        nEditHeight,
    1171                        SWP_NOZORDER);
    1172         if (!deferpos)
    1173             ERR("DeferWindowPos returned NULL\n");
    1174         }
    1175         else {
    1176         TRACE("moving child (Other) %04x to (%d,%d) for (%d,%d)\n",
    1177               lpBand->hwndChild,
    1178               lpBand->rcChild.left, lpBand->rcChild.top,
    1179               lpBand->rcChild.right - lpBand->rcChild.left,
    1180               lpBand->rcChild.bottom - lpBand->rcChild.top);
    1181         deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
    1182                        lpBand->rcChild.left,
    1183                        lpBand->rcChild.top,
    1184                        lpBand->rcChild.right - lpBand->rcChild.left,
    1185                        lpBand->rcChild.bottom - lpBand->rcChild.top,
    1186                        SWP_NOZORDER);
    1187         if (!deferpos)
    1188             ERR("DeferWindowPos returned NULL\n");
    1189         }
    1190     }
     1221        lpBand = &infoPtr->bands[i];
     1222
     1223        if (HIDDENBAND(lpBand)) continue;
     1224        if (lpBand->hwndChild) {
     1225            TRACE("hwndChild = %x\n", lpBand->hwndChild);
     1226
     1227            /* Always geterate the RBN_CHILDSIZE even it child
     1228                   did not change */
     1229            rbcz.uBand = i;
     1230            rbcz.wID = lpBand->wID;
     1231            rbcz.rcChild = lpBand->rcChild;
     1232            rbcz.rcBand = lpBand->rcBand;
     1233            rbcz.rcBand.left += lpBand->cxHeader;
     1234            REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
     1235            if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
     1236                TRACE("Child rect changed by NOTIFY for band %u\n", i);
     1237                TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
     1238                      lpBand->rcChild.left, lpBand->rcChild.top,
     1239                      lpBand->rcChild.right, lpBand->rcChild.bottom,
     1240                      rbcz.rcChild.left, rbcz.rcChild.top,
     1241                      rbcz.rcChild.right, rbcz.rcChild.bottom);
     1242                lpBand->rcChild = rbcz.rcChild;  /* *** ??? */
     1243            }
     1244
     1245            /* native (IE4 in "Favorites" frame **1) does:
     1246             *   SetRect (&rc, -1, -1, -1, -1)
     1247             *   EqualRect (&rc,band->rc???)
     1248             *   if ret==0
     1249             *     CopyRect (band->rc????, &rc)
     1250             *     set flag outside of loop
     1251             */
     1252
     1253            GetClassNameA (lpBand->hwndChild, szClassName, 40);
     1254            if (!lstrcmpA (szClassName, "ComboBox") ||
     1255                !lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
     1256                INT nEditHeight, yPos;
     1257                RECT rc;
     1258
     1259                /* special placement code for combo or comboex box */
     1260
     1261
     1262                /* get size of edit line */
     1263                GetWindowRect (lpBand->hwndChild, &rc);
     1264                nEditHeight = rc.bottom - rc.top;
     1265                yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
     1266
     1267                /* center combo box inside child area */
     1268                TRACE("moving child (Combo(Ex)) %04x to (%d,%d) for (%d,%d)\n",
     1269                      lpBand->hwndChild,
     1270                      lpBand->rcChild.left, yPos,
     1271                      lpBand->rcChild.right - lpBand->rcChild.left,
     1272                      nEditHeight);
     1273                deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
     1274                                           lpBand->rcChild.left,
     1275                                           /*lpBand->rcChild.top*/ yPos,
     1276                                           lpBand->rcChild.right - lpBand->rcChild.left,
     1277                                           nEditHeight,
     1278                                           SWP_NOZORDER);
     1279                if (!deferpos)
     1280                    ERR("DeferWindowPos returned NULL\n");
     1281            }
     1282            else {
     1283                TRACE("moving child (Other) %04x to (%d,%d) for (%d,%d)\n",
     1284                      lpBand->hwndChild,
     1285                      lpBand->rcChild.left, lpBand->rcChild.top,
     1286                      lpBand->rcChild.right - lpBand->rcChild.left,
     1287                      lpBand->rcChild.bottom - lpBand->rcChild.top);
     1288                deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
     1289                                           lpBand->rcChild.left,
     1290                                           lpBand->rcChild.top,
     1291                                           lpBand->rcChild.right - lpBand->rcChild.left,
     1292                                           lpBand->rcChild.bottom - lpBand->rcChild.top,
     1293                                           SWP_NOZORDER);
     1294                if (!deferpos)
     1295                    ERR("DeferWindowPos returned NULL\n");
     1296            }
     1297        }
    11911298    }
    11921299    if (!EndDeferWindowPos(deferpos))
    11931300        ERR("EndDeferWindowPos returned NULL\n");
     1301
     1302    UpdateWindow (infoPtr->hwndSelf);
     1303
    11941304    if (infoPtr->fStatus & NTF_HGHTCHG) {
    11951305        infoPtr->fStatus &= ~NTF_HGHTCHG;
    11961306        REBAR_Notify (&heightchange, infoPtr, RBN_HEIGHTCHANGE);
    11971307    }
     1308
     1309    /* native (from **1 above) does:
     1310     *      UpdateWindow(rebar)
     1311     *      REBAR_ForceResize
     1312     *      RBN_HEIGHTCHANGE if necessary
     1313     *      if ret from any EqualRect was 0
     1314     *         Goto "BeginDeferWindowPos"
     1315     */
     1316
    11981317}
    11991318
     
    12071326    REBAR_BAND *lpBand, *prevBand;
    12081327    RECT rcClient, rcAdj;
    1209     INT x, y, cx, cxsep, mmcy, mcy, clientcx, clientcy;
     1328    INT initx, inity, x, y, cx, cxsep, mmcy, mcy, clientcx, clientcy;
    12101329    INT adjcx, adjcy, row, rightx, bottomy, origheight;
    1211     UINT i, j, rowstart;
     1330    UINT i, j, rowstart, origrows;
    12121331    BOOL dobreak;
    12131332
    12141333    if (!(infoPtr->fStatus & BAND_NEEDS_LAYOUT)) {
    1215     TRACE("no layout done. No band changed.\n");
    1216     REBAR_DumpBand (infoPtr);
    1217     return;
     1334        TRACE("no layout done. No band changed.\n");
     1335        REBAR_DumpBand (infoPtr);
     1336        return;
    12181337    }
    12191338    infoPtr->fStatus &= ~BAND_NEEDS_LAYOUT;
     
    12221341    GetClientRect (infoPtr->hwndSelf, &rcClient);
    12231342    TRACE("Client is (%d,%d)-(%d,%d)\n",
    1224       rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
     1343          rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
    12251344
    12261345    if (lpRect) {
    1227     rcAdj = *lpRect;
    1228     TRACE("adjustment rect is (%d,%d)-(%d,%d)\n",
    1229           rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom);
     1346        rcAdj = *lpRect;
     1347        TRACE("adjustment rect is (%d,%d)-(%d,%d)\n",
     1348              rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom);
    12301349    }
    12311350    else {
     
    12441363
    12451364    if (!infoPtr->DoRedraw && (clientcx == 0) && (clientcy == 0)) {
    1246     ERR("no redraw and client is zero, skip layout\n");
    1247     infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
    1248     return;
     1365        ERR("no redraw and client is zero, skip layout\n");
     1366        infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
     1367        return;
    12491368    }
    12501369
    12511370    /* save height of original control */
    1252     if (infoPtr->dwStyle & CCS_VERT)
     1371    if (infoPtr->dwStyle & CCS_VERT) 
    12531372        origheight = infoPtr->calcSize.cx;
    12541373    else
    12551374        origheight = infoPtr->calcSize.cy;
    1256 
     1375    origrows = infoPtr->uNumRows;
     1376
     1377    initx = 0;
     1378    inity = 0;
    12571379
    12581380    /* ******* Start Phase 1 - all bands on row at minimum size ******* */
    12591381
    1260     TRACE("band loop constants, clientcx=%d, clientcy=%d\n",
    1261       clientcx, clientcy);
    1262     x = 0;
    1263     y = 0;
     1382    TRACE("band loop constants, clientcx=%d, clientcy=%d, adjcx=%d, adjcy=%d\n",
     1383          clientcx, clientcy, adjcx, adjcy);
     1384    x = initx;
     1385    y = inity;
    12641386    row = 1;
    12651387    cx = 0;
     
    12691391
    12701392    for (i = 0; i < infoPtr->uNumBands; i++) {
    1271     lpBand = &infoPtr->bands[i];
    1272     lpBand->fDraw = 0;
    1273     lpBand->iRow = row;
    1274 
    1275     if (HIDDENBAND(lpBand)) continue;
    1276 
    1277     lpBand->rcoldBand = lpBand->rcBand;
    1278 
    1279     /* separator from previous band */
    1280     cxsep = ( ((infoPtr->dwStyle & CCS_VERT) ? y : x)==0) ? 0 : SEP_WIDTH;
    1281 
    1282     /* Header: includes gripper, text, image */
    1283     cx = lpBand->cxHeader;
    1284     if (lpBand->fStyle & RBBS_FIXEDSIZE) cx = lpBand->lcx;
    1285 
    1286     if (infoPtr->dwStyle & CCS_VERT)
    1287         dobreak = (y + cx + cxsep > adjcy);
     1393        lpBand = &infoPtr->bands[i];
     1394        lpBand->fDraw = 0;
     1395        lpBand->iRow = row;
     1396
     1397        if (HIDDENBAND(lpBand)) continue;
     1398
     1399        lpBand->rcoldBand = lpBand->rcBand;
     1400
     1401        /* Set the offset of the child window */
     1402        if ((lpBand->fMask & RBBIM_CHILD) &&
     1403            !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
     1404            lpBand->offChild.cx = 4;   /* ??? */
     1405        }
     1406        lpBand->offChild.cy = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 2 : 0);
     1407
     1408        /* separator from previous band */
     1409        cxsep = ( ((infoPtr->dwStyle & CCS_VERT) ? y==inity : x==initx)) ?
     1410            0 : SEP_WIDTH; 
     1411
     1412        /* Header: includes gripper, text, image */
     1413        cx = lpBand->cxHeader;   
     1414        if (lpBand->fStyle & RBBS_FIXEDSIZE) cx = lpBand->lcx;
     1415
     1416        if (infoPtr->dwStyle & CCS_VERT)
     1417            dobreak = (y + cx + cxsep > adjcy);
    12881418        else
    1289         dobreak = (x + cx + cxsep > adjcx);
    1290 
    1291     /* This is the check for whether we need to start a new row */
    1292     if ( ( (lpBand->fStyle & RBBS_BREAK) && (i != 0) ) ||
    1293          ( ((infoPtr->dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && dobreak)) {
    1294 
    1295         for (j = rowstart; j < i; j++) {
    1296         REBAR_BAND *lpB;
    1297         lpB = &infoPtr->bands[j];
    1298         if (infoPtr->dwStyle & CCS_VERT) {
    1299             lpB->rcBand.right  = lpB->rcBand.left + mcy;
    1300         }
    1301         else {
    1302             lpB->rcBand.bottom = lpB->rcBand.top + mcy;
    1303         }
    1304         }
    1305 
    1306         TRACE("Spliting to new row %d on band %u\n", row+1, i);
    1307         if (infoPtr->dwStyle & CCS_VERT) {
    1308         y = 0;
    1309         x += (mcy + SEP_WIDTH);
    1310         }
    1311         else {
    1312         x = 0;
    1313         y += (mcy + SEP_WIDTH);
    1314         }
    1315 
    1316         mcy = 0;
    1317         cxsep = 0;
    1318         row++;
    1319         lpBand->iRow = row;
    1320         prevBand = NULL;
    1321         rowstart = i;
    1322     }
    1323 
    1324     if (mcy < lpBand->lcy + REBARSPACE) mcy = lpBand->lcy + REBARSPACE;
    1325 
    1326     /* if boundary rect specified then limit mcy */
    1327     if (lpRect) {
    1328         if (infoPtr->dwStyle & CCS_VERT) {
    1329             if (x+mcy > adjcx) {
    1330             mcy = adjcx - x;
    1331             TRACE("row %u limiting mcy=%d, adjcx=%d, x=%d\n",
    1332               i, mcy, adjcx, x);
    1333         }
    1334         }
    1335         else {
    1336             if (y+mcy > adjcy) {
    1337             mcy = adjcy - y;
    1338             TRACE("row %u limiting mcy=%d, adjcy=%d, y=%d\n",
    1339               i, mcy, adjcy, y);
    1340         }
    1341         }
    1342     }
    1343 
    1344     TRACE("band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
    1345           i, row,
    1346           x, y, cxsep, cx);
    1347     if (infoPtr->dwStyle & CCS_VERT) {
    1348         /* bound the bottom side if we have a bounding rectangle */
    1349         rightx = clientcx;
    1350         bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx;
    1351         lpBand->rcBand.left   = x;
    1352         lpBand->rcBand.right  = x + min(mcy, lpBand->lcy+REBARSPACE);
    1353         lpBand->rcBand.top    = min(bottomy, y + cxsep);
    1354         lpBand->rcBand.bottom = bottomy;
    1355         lpBand->uMinHeight = lpBand->lcy;
    1356         y = bottomy;
    1357     }
    1358     else {
    1359         /* bound the right side if we have a bounding rectangle */
    1360         rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx;
    1361         bottomy = clientcy;
    1362         lpBand->rcBand.left   = min(rightx, x + cxsep);
    1363         lpBand->rcBand.right  = rightx;
    1364         lpBand->rcBand.top    = y;
    1365         lpBand->rcBand.bottom = y + min(mcy, lpBand->lcy+REBARSPACE);
    1366         lpBand->uMinHeight = lpBand->lcy;
    1367         x = rightx;
    1368     }
    1369     TRACE("band %u, row %d, (%d,%d)-(%d,%d)\n",
    1370           i, row,
    1371           lpBand->rcBand.left, lpBand->rcBand.top,
    1372           lpBand->rcBand.right, lpBand->rcBand.bottom);
    1373     prevBand = lpBand;
     1419            dobreak = (x + cx + cxsep > adjcx);
     1420
     1421        /* This is the check for whether we need to start a new row */
     1422        if ( ( (lpBand->fStyle & RBBS_BREAK) && (i != 0) ) ||
     1423             ( ((infoPtr->dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && dobreak)) {
     1424
     1425            for (j = rowstart; j < i; j++) {
     1426                REBAR_BAND *lpB;
     1427                lpB = &infoPtr->bands[j];
     1428                if (infoPtr->dwStyle & CCS_VERT) {
     1429                    lpB->rcBand.right  = lpB->rcBand.left + mcy;
     1430                }
     1431                else {
     1432                    lpB->rcBand.bottom = lpB->rcBand.top + mcy;
     1433                }
     1434            }
     1435
     1436            TRACE("P1 Spliting to new row %d on band %u\n", row+1, i);
     1437            if (infoPtr->dwStyle & CCS_VERT) {
     1438                y = inity;
     1439                x += (mcy + SEP_WIDTH);
     1440            }
     1441            else {
     1442                x = initx;
     1443                y += (mcy + SEP_WIDTH);
     1444            }
     1445
     1446            mcy = 0;
     1447            cxsep = 0;
     1448            row++;
     1449            lpBand->iRow = row;
     1450            prevBand = NULL;
     1451            rowstart = i;
     1452        }
     1453
     1454        if (mcy < lpBand->lcy + REBARSPACE(lpBand))
     1455            mcy = lpBand->lcy + REBARSPACE(lpBand);
     1456
     1457        /* if boundary rect specified then limit mcy */
     1458        if (lpRect) {
     1459            if (infoPtr->dwStyle & CCS_VERT) {
     1460                if (x+mcy > adjcx) {
     1461                    mcy = adjcx - x;
     1462                    TRACE("P1 row %u limiting mcy=%d, adjcx=%d, x=%d\n",
     1463                          i, mcy, adjcx, x);
     1464                }
     1465            }
     1466            else {
     1467                if (y+mcy > adjcy) {
     1468                    mcy = adjcy - y;
     1469                    TRACE("P1 row %u limiting mcy=%d, adjcy=%d, y=%d\n",
     1470                          i, mcy, adjcy, y);
     1471                }
     1472            }
     1473        }
     1474
     1475        TRACE("P1 band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
     1476              i, row,
     1477              x, y, cxsep, cx);
     1478        if (infoPtr->dwStyle & CCS_VERT) {
     1479            /* bound the bottom side if we have a bounding rectangle */
     1480            rightx = clientcx;
     1481            bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx;
     1482            lpBand->rcBand.left   = x;
     1483            lpBand->rcBand.right  = x + min(mcy,
     1484                                            lpBand->lcy+REBARSPACE(lpBand));
     1485            lpBand->rcBand.top    = min(bottomy, y + cxsep);
     1486            lpBand->rcBand.bottom = bottomy;
     1487            lpBand->uMinHeight = lpBand->lcy;
     1488            y = bottomy;
     1489        }
     1490        else {
     1491            /* bound the right side if we have a bounding rectangle */
     1492            rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx;
     1493            bottomy = clientcy;
     1494            lpBand->rcBand.left   = min(rightx, x + cxsep);
     1495            lpBand->rcBand.right  = rightx;
     1496            lpBand->rcBand.top    = y;
     1497            lpBand->rcBand.bottom = y + min(mcy,
     1498                                            lpBand->lcy+REBARSPACE(lpBand));
     1499            lpBand->uMinHeight = lpBand->lcy;
     1500            x = rightx;
     1501        }
     1502        TRACE("P1 band %u, row %d, (%d,%d)-(%d,%d)\n",
     1503              i, row,
     1504              lpBand->rcBand.left, lpBand->rcBand.top,
     1505              lpBand->rcBand.right, lpBand->rcBand.bottom);
     1506        prevBand = lpBand;
    13741507
    13751508    } /* for (i = 0; i < infoPtr->uNumBands... */
     
    13811514
    13821515    for (j = rowstart; j < infoPtr->uNumBands; j++) {
    1383     lpBand = &infoPtr->bands[j];
    1384     if (infoPtr->dwStyle & CCS_VERT) {
    1385         lpBand->rcBand.right  = lpBand->rcBand.left + mcy;
    1386     }
    1387     else {
    1388         lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
    1389     }
     1516        lpBand = &infoPtr->bands[j];
     1517        if (infoPtr->dwStyle & CCS_VERT) {
     1518            lpBand->rcBand.right  = lpBand->rcBand.left + mcy;
     1519        }
     1520        else {
     1521            lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
     1522        }
    13901523    }
    13911524
     
    14001533    mmcy = 0;
    14011534    if (!(infoPtr->dwStyle & RBS_VARHEIGHT)) {
    1402     INT xy;
    1403 
    1404     /* get the max height of all bands */
    1405     for (i=0; i<infoPtr->uNumBands; i++) {
    1406         lpBand = &infoPtr->bands[i];
    1407         if (HIDDENBAND(lpBand)) continue;
    1408         if (infoPtr->dwStyle & CCS_VERT)
    1409         mmcy = max(mmcy, lpBand->rcBand.right - lpBand->rcBand.left);
    1410         else
    1411         mmcy = max(mmcy, lpBand->rcBand.bottom - lpBand->rcBand.top);
    1412     }
    1413 
    1414     /* now adjust all rectangles by using the height found above */
    1415     xy = 0;
    1416     row = 1;
    1417     for (i=0; i<infoPtr->uNumBands; i++) {
    1418         lpBand = &infoPtr->bands[i];
    1419         if (HIDDENBAND(lpBand)) continue;
    1420         if (lpBand->iRow != row)
    1421         xy += (mmcy + SEP_WIDTH);
    1422         if (infoPtr->dwStyle & CCS_VERT) {
    1423         lpBand->rcBand.left = xy;
    1424         lpBand->rcBand.right = xy + mmcy;
    1425         }
    1426         else {
    1427         lpBand->rcBand.top = xy;
    1428         lpBand->rcBand.bottom = xy + mmcy;
    1429         }
    1430     }
    1431 
    1432     /* set the x/y values to the correct maximum */
    1433     if (infoPtr->dwStyle & CCS_VERT)
    1434         x = xy + mmcy;
    1435     else
    1436         y = xy + mmcy;
     1535        INT xy;
     1536
     1537        /* get the max height of all bands */
     1538        for (i=0; i<infoPtr->uNumBands; i++) {
     1539            lpBand = &infoPtr->bands[i];
     1540            if (HIDDENBAND(lpBand)) continue;
     1541            if (infoPtr->dwStyle & CCS_VERT)
     1542                mmcy = max(mmcy, lpBand->rcBand.right - lpBand->rcBand.left);
     1543            else
     1544                mmcy = max(mmcy, lpBand->rcBand.bottom - lpBand->rcBand.top);
     1545        }
     1546
     1547        /* now adjust all rectangles by using the height found above */
     1548        xy = 0;
     1549        row = 1;
     1550        for (i=0; i<infoPtr->uNumBands; i++) {
     1551            lpBand = &infoPtr->bands[i];
     1552            if (HIDDENBAND(lpBand)) continue;
     1553            if (lpBand->iRow != row)
     1554                xy += (mmcy + SEP_WIDTH);
     1555            if (infoPtr->dwStyle & CCS_VERT) {
     1556                lpBand->rcBand.left = xy;
     1557                lpBand->rcBand.right = xy + mmcy;
     1558            }
     1559            else {
     1560                lpBand->rcBand.top = xy;
     1561                lpBand->rcBand.bottom = xy + mmcy;
     1562            }
     1563        }
     1564
     1565        /* set the x/y values to the correct maximum */
     1566        if (infoPtr->dwStyle & CCS_VERT)
     1567            x = xy + mmcy;
     1568        else
     1569            y = xy + mmcy;
    14371570    }
    14381571
     
    14461579    if (lpRect) {
    14471580        INT i, j, prev_rh, new_rh, adj_rh, prev_idx, current_idx;
    1448     REBAR_BAND *prev, *current, *walk;
     1581        REBAR_BAND *prev, *current, *walk;
    14491582
    14501583/* FIXME:  problem # 2 */
    1451     if (((infoPtr->dwStyle & CCS_VERT) ?
     1584        if (((infoPtr->dwStyle & CCS_VERT) ?
    14521585#if PROBLEM2
    1453          (x < adjcx) : (y < adjcy)
     1586             (x < adjcx) : (y < adjcy)
    14541587#else
    1455          (adjcx - x > 4) : (adjcy - y > 4)
     1588             (adjcx - x > 4) : (adjcy - y > 4)
    14561589#endif
    1457          ) &&
    1458         (infoPtr->uNumBands > 1)) {
    1459         for (i=(INT)infoPtr->uNumBands-2; i>=0; i--) {
    1460         TRACE("adjcx=%d, adjcy=%d, x=%d, y=%d\n",
    1461               adjcx, adjcy, x, y);
    1462 
    1463         /* find the current band (starts at i+1) */
    1464         current = &infoPtr->bands[i+1];
    1465         current_idx = i+1;
    1466         while (HIDDENBAND(current)) {
    1467             i--;
    1468             if (i < 0) break; /* out of bands */
    1469             current = &infoPtr->bands[i+1];
    1470             current_idx = i+1;
    1471         }
    1472         if (i < 0) break; /* out of bands */
    1473 
    1474         /* now find the prev band (starts at i) */
    1475             prev = &infoPtr->bands[i];
    1476         prev_idx = i;
    1477         while (HIDDENBAND(prev)) {
    1478             i--;
    1479             if (i < 0) break; /* out of bands */
    1480             prev = &infoPtr->bands[i];
    1481             prev_idx = i;
    1482         }
    1483         if (i < 0) break; /* out of bands */
    1484 
    1485         prev_rh = ircBw(prev);
    1486         if (prev->iRow == current->iRow) {
    1487             new_rh = (infoPtr->dwStyle & RBS_VARHEIGHT) ?
    1488             current->lcy + REBARSPACE :
    1489             mmcy;
    1490             adj_rh = new_rh + SEP_WIDTH;
    1491             infoPtr->uNumRows++;
    1492             current->fDraw |= NTF_INVALIDATE;
    1493             current->iRow++;
    1494             if (infoPtr->dwStyle & CCS_VERT) {
    1495                 current->rcBand.top = 0;
    1496             current->rcBand.bottom = clientcy;
    1497             current->rcBand.left += (prev_rh + SEP_WIDTH);
    1498             current->rcBand.right = current->rcBand.left + new_rh;
    1499             x += adj_rh;
    1500             }
    1501             else {
    1502                 current->rcBand.left = 0;
    1503             current->rcBand.right = clientcx;
    1504             current->rcBand.top += (prev_rh + SEP_WIDTH);
    1505             current->rcBand.bottom = current->rcBand.top + new_rh;
    1506             y += adj_rh;
    1507             }
    1508             TRACE("moving band %d to own row at (%d,%d)-(%d,%d)\n",
    1509               current_idx,
    1510               current->rcBand.left, current->rcBand.top,
    1511               current->rcBand.right, current->rcBand.bottom);
    1512             TRACE("prev band %d at (%d,%d)-(%d,%d)\n",
    1513               prev_idx,
    1514               prev->rcBand.left, prev->rcBand.top,
    1515               prev->rcBand.right, prev->rcBand.bottom);
    1516             TRACE("values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
    1517               prev_rh, new_rh, adj_rh);
    1518             /* for bands below current adjust row # and top/bottom */
    1519             for (j = current_idx+1; j<infoPtr->uNumBands; j++) {
    1520                 walk = &infoPtr->bands[j];
    1521             if (HIDDENBAND(walk)) continue;
    1522             walk->fDraw |= NTF_INVALIDATE;
    1523             walk->iRow++;
    1524             if (infoPtr->dwStyle & CCS_VERT) {
    1525                 walk->rcBand.left += adj_rh;
    1526                 walk->rcBand.right += adj_rh;
    1527             }
    1528             else {
    1529                 walk->rcBand.top += adj_rh;
    1530                 walk->rcBand.bottom += adj_rh;
    1531             }
    1532             }
    1533             if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy))
    1534                 break; /* all done */
    1535         }
    1536         }
    1537     }
     1590             ) &&
     1591            (infoPtr->uNumBands > 1)) {
     1592            for (i=(INT)infoPtr->uNumBands-2; i>=0; i--) {
     1593                TRACE("P2 adjcx=%d, adjcy=%d, x=%d, y=%d\n",
     1594                      adjcx, adjcy, x, y);
     1595
     1596                /* find the current band (starts at i+1) */
     1597                current = &infoPtr->bands[i+1];
     1598                current_idx = i+1;
     1599                while (HIDDENBAND(current)) {
     1600                    i--;
     1601                    if (i < 0) break; /* out of bands */
     1602                    current = &infoPtr->bands[i+1];
     1603                    current_idx = i+1;
     1604                }
     1605                if (i < 0) break; /* out of bands */
     1606
     1607                /* now find the prev band (starts at i) */
     1608                prev = &infoPtr->bands[i];
     1609                prev_idx = i;
     1610                while (HIDDENBAND(prev)) {
     1611                    i--;
     1612                    if (i < 0) break; /* out of bands */
     1613                    prev = &infoPtr->bands[i];
     1614                    prev_idx = i;
     1615                }
     1616                if (i < 0) break; /* out of bands */
     1617
     1618                prev_rh = ircBw(prev);
     1619                if (prev->iRow == current->iRow) {
     1620                    new_rh = (infoPtr->dwStyle & RBS_VARHEIGHT) ?
     1621                        current->lcy + REBARSPACE(current) :
     1622                        mmcy;
     1623                    adj_rh = new_rh + SEP_WIDTH;
     1624                    infoPtr->uNumRows++;
     1625                    current->fDraw |= NTF_INVALIDATE;
     1626                    current->iRow++;
     1627                    if (infoPtr->dwStyle & CCS_VERT) {
     1628                        current->rcBand.top = inity;
     1629                        current->rcBand.bottom = clientcy;
     1630                        current->rcBand.left += (prev_rh + SEP_WIDTH);
     1631                        current->rcBand.right = current->rcBand.left + new_rh;
     1632                        x += adj_rh;
     1633                    }
     1634                    else {
     1635                        current->rcBand.left = initx;
     1636                        current->rcBand.right = clientcx;
     1637                        current->rcBand.top += (prev_rh + SEP_WIDTH);
     1638                        current->rcBand.bottom = current->rcBand.top + new_rh;
     1639                        y += adj_rh;
     1640                    }
     1641                    TRACE("P2 moving band %d to own row at (%d,%d)-(%d,%d)\n",
     1642                          current_idx,
     1643                          current->rcBand.left, current->rcBand.top,
     1644                          current->rcBand.right, current->rcBand.bottom);
     1645                    TRACE("P2 prev band %d at (%d,%d)-(%d,%d)\n",
     1646                          prev_idx,
     1647                          prev->rcBand.left, prev->rcBand.top,
     1648                          prev->rcBand.right, prev->rcBand.bottom);
     1649                    TRACE("P2 values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
     1650                          prev_rh, new_rh, adj_rh);
     1651                    /* for bands below current adjust row # and top/bottom */
     1652                    for (j = current_idx+1; j<infoPtr->uNumBands; j++) {
     1653                        walk = &infoPtr->bands[j];
     1654                        if (HIDDENBAND(walk)) continue;
     1655                        walk->fDraw |= NTF_INVALIDATE;
     1656                        walk->iRow++;
     1657                        if (infoPtr->dwStyle & CCS_VERT) {
     1658                            walk->rcBand.left += adj_rh;
     1659                            walk->rcBand.right += adj_rh;
     1660                        }
     1661                        else {
     1662                            walk->rcBand.top += adj_rh;
     1663                            walk->rcBand.bottom += adj_rh;
     1664                        }
     1665                    }
     1666                    if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy))
     1667                        break; /* all done */
     1668                }
     1669            }
     1670        }
    15381671    }
    15391672
     
    15411674
    15421675
    1543     /* ******* Start Phase 2a - adjust all bands for height full ******* */
     1676    /* ******* Start Phase 2a - create array of start and end  ******* */
     1677    /*                          indexes by row                         */
     1678
     1679    if (infoPtr->uNumRows != origrows) {
     1680        if (infoPtr->rows) COMCTL32_Free (infoPtr->rows);
     1681        infoPtr->rows = COMCTL32_Alloc (sizeof (REBAR_ROW) * infoPtr->uNumRows);
     1682    }
     1683
     1684    row = 0;
     1685    for (i = 0; i < infoPtr->uNumBands; i++) {
     1686        lpBand = &infoPtr->bands[i];
     1687        if (HIDDENBAND(lpBand)) continue;
     1688
     1689        if (lpBand->iRow > row) {
     1690            row++;
     1691            infoPtr->rows[row-1].istartband = i;
     1692        }
     1693        if (row == 0) {
     1694            ERR("P2a bug!!!!!!\n");
     1695        }
     1696        infoPtr->rows[row-1].iendband = i;
     1697    }
     1698
     1699    for (i = 0; i < infoPtr->uNumRows; i++) {
     1700        REBAR_ROW *p;
     1701
     1702        p = &infoPtr->rows[i];
     1703        TRACE("P2a row %d, starts %d, ends %d\n",
     1704              i+1, p->istartband, p->iendband);
     1705    }
     1706
     1707    /* ******* End Phase 2a - create array of start and end    ******* */
     1708    /*                          indexes by row                         */
     1709
     1710
     1711    /* ******* Start Phase 2b - adjust all bands for height full ******* */
    15441712    /* assumes that the following variables contain:                 */
    15451713    /*   y/x     current height/width of all rows                    */
    15461714    /*   clientcy/clientcx     height/width of client area           */
    15471715
    1548     /* **** FIXME FIXME FIXME
    1549      *   this does not take into account that more than one band
    1550      *   is in a row!!!!!!!!!
    1551      */
    1552 
    15531716    if (((infoPtr->dwStyle & CCS_VERT) ? clientcx > x : clientcy > y) &&
    1554     infoPtr->uNumBands) {
    1555     INT diff, i, j;
    1556 
    1557     diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y;
    1558     for (i = infoPtr->uNumBands-1; i >= 0; i--) {
    1559         lpBand = &infoPtr->bands[i];
    1560         if(HIDDENBAND(lpBand)) continue;
    1561         if (!lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
    1562         if (((INT)lpBand->cyMaxChild < 1) ||
    1563         ((INT)lpBand->cyIntegral < 1)) {
    1564         if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue;
    1565         ERR("band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
    1566             i, lpBand->cyMaxChild, lpBand->cyIntegral);
    1567         continue;
    1568         }
    1569         /* j is now the maximum height/width in the client area */
    1570         j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) +
    1571         ircBw(lpBand);
    1572         if (j > lpBand->cyMaxChild + REBARSPACE)
    1573         j = lpBand->cyMaxChild + REBARSPACE;
    1574         diff -= (j - ircBw(lpBand));
    1575         if (infoPtr->dwStyle & CCS_VERT)
    1576         lpBand->rcBand.right = lpBand->rcBand.left + j;
    1577         else
    1578         lpBand->rcBand.bottom = lpBand->rcBand.top + j;
    1579         TRACE("P2a band %d, row %d changed to (%d,%d)-(%d,%d)\n",
    1580           i, lpBand->iRow,
    1581           lpBand->rcBand.left, lpBand->rcBand.top,
    1582           lpBand->rcBand.right, lpBand->rcBand.bottom);
    1583         if (diff <= 0) break;
    1584     }
    1585     if (diff < 0) {
    1586         ERR("allocated more than available, diff=%d\n", diff);
    1587         diff = 0;
    1588     }
    1589     if (infoPtr->dwStyle & CCS_VERT)
    1590         x = clientcx - diff;
    1591     else
    1592         y = clientcy - diff;
    1593     }
    1594 
    1595     /* ******* End Phase 2a - adjust all bands for height full ******* */
     1717        infoPtr->uNumBands) {
     1718        INT diff, i, iband, j;
     1719
     1720        diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y;
     1721        for (i = infoPtr->uNumRows; i >= 1; i--) {
     1722            /* if row has more than 1 band, ignore row   */
     1723            if (infoPtr->rows[i-1].istartband != infoPtr->rows[i-1].iendband)
     1724                continue;
     1725            /* point to only band in row  */
     1726            iband = infoPtr->rows[i-1].istartband;
     1727            lpBand = &infoPtr->bands[iband];
     1728            if(HIDDENBAND(lpBand)) continue;
     1729            if (!lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
     1730            if (((INT)lpBand->cyMaxChild < 1) ||
     1731                ((INT)lpBand->cyIntegral < 1)) {
     1732                if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue;
     1733                ERR("P2b band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
     1734                    iband, lpBand->cyMaxChild, lpBand->cyIntegral);
     1735                continue;
     1736            }
     1737            /* j is now the maximum height/width in the client area */
     1738            j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) +
     1739                ircBw(lpBand);
     1740            if (j > lpBand->cyMaxChild + REBARSPACE(lpBand))
     1741                j = lpBand->cyMaxChild + REBARSPACE(lpBand);
     1742            diff -= (j - ircBw(lpBand));
     1743            if (infoPtr->dwStyle & CCS_VERT)
     1744                lpBand->rcBand.right = lpBand->rcBand.left + j;
     1745            else
     1746                lpBand->rcBand.bottom = lpBand->rcBand.top + j;
     1747            TRACE("P2b band %d, row %d changed to (%d,%d)-(%d,%d)\n",
     1748                  iband, lpBand->iRow,
     1749                  lpBand->rcBand.left, lpBand->rcBand.top,
     1750                  lpBand->rcBand.right, lpBand->rcBand.bottom);
     1751            if (diff <= 0) break;
     1752        }
     1753        if (diff < 0) {
     1754            ERR("P2b allocated more than available, diff=%d\n", diff);
     1755            diff = 0;
     1756        }
     1757        if (infoPtr->dwStyle & CCS_VERT)
     1758            x = clientcx - diff;
     1759        else
     1760            y = clientcy - diff;
     1761    }
     1762
     1763    /* ******* End Phase 2b - adjust all bands for height full ******* */
    15961764
    15971765
     
    15991767
    16001768    if (infoPtr->uNumBands) {
    1601     INT bandnum, bandnum_start, bandnum_end;
    1602 
    1603     /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
    1604     /* on all bands in all rows but last row.                        */
    1605     /* Also indicate to draw the right separator for each band in    */
    1606     /* each row but the rightmost band.                              */
    1607     if (infoPtr->dwStyle & RBS_BANDBORDERS) {
    1608         REBAR_BAND *prevband;
    1609         INT currow;
    1610 
    1611         prevband = NULL;
    1612         currow = -1;
    1613         for (i = 0; i < infoPtr->uNumBands; i++) {
    1614             lpBand = &infoPtr->bands[i];
    1615         if (HIDDENBAND(lpBand)) continue;
    1616 
    1617         if (lpBand->iRow < infoPtr->uNumRows)
    1618             lpBand->fDraw |= DRAW_BOTTOMSEP;
    1619 
    1620         if (lpBand->iRow != currow) prevband = NULL;
    1621         currow = lpBand->iRow;
    1622         if (prevband) prevband->fDraw |= DRAW_RIGHTSEP;
    1623         prevband = lpBand;
    1624         }
    1625     }
    1626 
    1627     /* Distribute the extra space on the horizontal and adjust  */
    1628     /* all bands in row to same height.                         */
    1629     bandnum = 0;
    1630     for (i=1; i<=infoPtr->uNumRows; i++) {
    1631         bandnum_start = -1;
    1632         bandnum_end = -1;
    1633         mcy = 0;
    1634         TRACE("processing row %d, starting band %d\n", i, bandnum);
    1635         while (TRUE) {
    1636         lpBand = &infoPtr->bands[bandnum];
    1637         if ((bandnum >= infoPtr->uNumBands) ||
    1638             ((lpBand->iRow != i) &&
    1639              !HIDDENBAND(lpBand))) {
    1640             if ((bandnum_start == -1) ||
    1641             (bandnum_end == -1)) {
    1642             ERR("logic error? bands=%d, rows=%d, start=%d, end=%d\n",
    1643                 infoPtr->uNumBands, infoPtr->uNumRows,
    1644                 (INT)bandnum_start, (INT)bandnum_end);
    1645             ERR("  current row=%d, band=%d\n",
    1646                 i, bandnum);
    1647             break;
    1648             }
    1649             REBAR_AdjustBands (infoPtr, bandnum_start, bandnum_end,
    1650                        (infoPtr->dwStyle & CCS_VERT) ?
    1651                        clientcy : clientcx, mcy);
    1652             break;
    1653         }
    1654         if (!HIDDENBAND(lpBand)) {
    1655             if (bandnum_start == -1) bandnum_start = bandnum;
    1656             if (bandnum_end < bandnum) bandnum_end = bandnum;
    1657             if (mcy < ircBw(lpBand))
    1658             mcy = ircBw(lpBand);
    1659         }
    1660         bandnum++;
    1661         TRACE("point 1, bandnum=%d\n", bandnum);
    1662         }
    1663         TRACE("point 2, i=%d, numrows=%d, bandnum=%d\n",
    1664           i, infoPtr->uNumRows, bandnum);
    1665     }
    1666     TRACE("point 3\n");
    1667 
    1668     /* Calculate the other rectangles in each band */
    1669     if (infoPtr->dwStyle & CCS_VERT) {
    1670         REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands,
    1671                 notify);
    1672     }
    1673     else {
    1674         REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands,
    1675                 notify);
    1676     }
     1769        REBAR_ROW *p;
     1770
     1771        /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
     1772        /* on all bands in all rows but last row.                        */
     1773        /* Also indicate to draw the right separator for each band in    */
     1774        /* each row but the rightmost band.                              */
     1775        if (infoPtr->dwStyle & RBS_BANDBORDERS) {
     1776
     1777            for(i = 0; i < infoPtr->uNumRows; i++) {
     1778                p = &infoPtr->rows[i];
     1779                for (j = p->istartband; j <= p->iendband; j++) {
     1780                    lpBand = &infoPtr->bands[j];
     1781                    if (HIDDENBAND(lpBand)) continue;
     1782                    if (j != p->iendband)
     1783                        lpBand->fDraw |= DRAW_RIGHTSEP;
     1784                    if (i != infoPtr->uNumRows-1)
     1785                        lpBand->fDraw |= DRAW_BOTTOMSEP;
     1786                }
     1787            }
     1788        }
     1789
     1790        /* Distribute the extra space on the horizontal and adjust  */
     1791        /* all bands in row to same height.                         */
     1792        for (i=1; i<=infoPtr->uNumRows; i++) {
     1793            p = &infoPtr->rows[i-1];
     1794            mcy = 0;
     1795
     1796            TRACE("P3 processing row %d, starting band %d, ending band %d\n",
     1797                  i, p->istartband, p->iendband);
     1798
     1799            /* Find the largest height of the bands in the row */
     1800            for (j = p->istartband; j <= p->iendband; j++) {
     1801                lpBand = &infoPtr->bands[j];
     1802                if (HIDDENBAND(lpBand)) continue;
     1803                if (mcy < ircBw(lpBand))
     1804                    mcy = ircBw(lpBand);
     1805            }
     1806
     1807            REBAR_AdjustBands (infoPtr, p->istartband, p->iendband,
     1808                               (infoPtr->dwStyle & CCS_VERT) ?
     1809                               clientcy : clientcx, mcy);
     1810        }
     1811
     1812        /* Calculate the other rectangles in each band */
     1813        if (infoPtr->dwStyle & CCS_VERT) {
     1814            REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands,
     1815                                notify);
     1816        }
     1817        else {
     1818            REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands,
     1819                                notify);
     1820        }
    16771821    }
    16781822
     
    16811825    /* now compute size of Rebar itself */
    16821826    infoPtr->oldSize = infoPtr->calcSize;
     1827    if (infoPtr->uNumBands == 0) {
     1828        /* we have no bands, so make size the size of client */
     1829        x = clientcx;
     1830        y = clientcy;
     1831    }
    16831832    if (infoPtr->dwStyle & CCS_VERT) {
    1684     infoPtr->calcSize.cx = x;
    1685     infoPtr->calcSize.cy = clientcy;
    1686     TRACE("vert, notify=%d, x=%d, origheight=%d\n",
    1687           notify, x, origheight);
    1688     if (notify && (x != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
     1833        infoPtr->calcSize.cx = x;
     1834        infoPtr->calcSize.cy = clientcy;
     1835        TRACE("vert, notify=%d, x=%d, origheight=%d\n",
     1836              notify, x, origheight);
     1837        if (notify && (x != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
    16891838    }
    16901839    else {
    1691     infoPtr->calcSize.cx = clientcx;
    1692     infoPtr->calcSize.cy = y;
    1693     TRACE("horz, notify=%d, y=%d, origheight=%d\n",
    1694           notify, y, origheight);
    1695     if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
     1840        infoPtr->calcSize.cx = clientcx;
     1841        infoPtr->calcSize.cy = y;
     1842        TRACE("horz, notify=%d, y=%d, origheight=%d\n",
     1843              notify, y, origheight);
     1844        if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
    16961845    }
    16971846
     
    17501899    /* calculate gripper rectangle */
    17511900    if (  (!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
    1752       ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
    1753         ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (infoPtr->uNumBands > 1)))
     1901          ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
     1902            ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (infoPtr->uNumBands > 1)))
    17541903       ) {
    1755     lpBand->fStatus |= HAS_GRIPPER;
     1904        lpBand->fStatus |= HAS_GRIPPER;
    17561905        if (infoPtr->dwStyle & CCS_VERT)
    1757         if (infoPtr->dwStyle & RBS_VERTICALGRIPPER)
     1906            if (infoPtr->dwStyle & RBS_VERTICALGRIPPER)
    17581907                header += (GRIPPER_HEIGHT + REBAR_PRE_GRIPPER);
    17591908            else
    1760             header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER);
     1909                header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER);
    17611910        else
    17621911            header += (REBAR_PRE_GRIPPER + GRIPPER_WIDTH);
     
    17671916    /* image is visible */
    17681917    if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) {
    1769     lpBand->fStatus |= HAS_IMAGE;
     1918        lpBand->fStatus |= HAS_IMAGE;
    17701919        if (infoPtr->dwStyle & CCS_VERT) {
    1771        header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE);
    1772        lpBand->lcy = infoPtr->imageSize.cx + 2;
    1773     }
    1774     else {
    1775        header += (infoPtr->imageSize.cx + REBAR_POST_IMAGE);
    1776        lpBand->lcy = infoPtr->imageSize.cy + 2;
    1777     }
     1920           header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE);
     1921           lpBand->lcy = infoPtr->imageSize.cx + 2;
     1922        }
     1923        else {
     1924           header += (infoPtr->imageSize.cx + REBAR_POST_IMAGE);
     1925           lpBand->lcy = infoPtr->imageSize.cy + 2;
     1926        }
    17781927    }
    17791928
    17801929    /* text is visible */
    17811930    if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText)) {
    1782     HDC hdc = GetDC (0);
    1783     HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
    1784     SIZE size;
    1785 
    1786     lpBand->fStatus |= HAS_TEXT;
    1787     GetTextExtentPoint32W (hdc, lpBand->lpText,
    1788                    lstrlenW (lpBand->lpText), &size);
    1789     header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
    1790     textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy;
    1791 
    1792     SelectObject (hdc, hOldFont);
    1793     ReleaseDC (0, hdc);
     1931        HDC hdc = GetDC (0);
     1932        HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
     1933        SIZE size;
     1934
     1935        lpBand->fStatus |= HAS_TEXT;
     1936        GetTextExtentPoint32W (hdc, lpBand->lpText,
     1937                               lstrlenW (lpBand->lpText), &size);
     1938        header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
     1939        textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy;
     1940
     1941        SelectObject (hdc, hOldFont);
     1942        ReleaseDC (0, hdc);
    17941943    }
    17951944
    17961945    /* if no gripper but either image or text, then leave space */
    17971946    if ((lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) &&
    1798     !(lpBand->fStatus & HAS_GRIPPER)) {
    1799     header += REBAR_ALWAYS_SPACE;
     1947        !(lpBand->fStatus & HAS_GRIPPER)) {
     1948        header += REBAR_ALWAYS_SPACE;
    18001949    }
    18011950
     
    18111960    lpBand->ccy = lpBand->lcy;
    18121961    if (lpBand->fMask & RBBIM_CHILDSIZE) {
    1813     if (!(lpBand->fStyle & RBBS_FIXEDSIZE)) {
    1814         lpBand->offChild.cx = 4;
    1815         lpBand->offChild.cy = 2;
    1816         }
    18171962        lpBand->lcx = lpBand->cxMinChild;
    18181963
    1819     /* Set the .cy values for CHILDSIZE case */
     1964        /* Set the .cy values for CHILDSIZE case */
    18201965        lpBand->lcy = max(lpBand->lcy, lpBand->cyMinChild);
    1821     lpBand->ccy = lpBand->lcy;
     1966        lpBand->ccy = lpBand->lcy;
    18221967        lpBand->hcy = lpBand->lcy;
    18231968        if (lpBand->cyMaxChild != 0xffffffff) {
    1824         lpBand->hcy = lpBand->cyMaxChild;
     1969            lpBand->hcy = lpBand->cyMaxChild;
    18251970        }
    1826     if (lpBand->cyChild != 0xffffffff)
    1827         lpBand->ccy = max (lpBand->cyChild, lpBand->lcy);
     1971        if (lpBand->cyChild != 0xffffffff)
     1972            lpBand->ccy = max (lpBand->cyChild, lpBand->lcy);
    18281973
    18291974        TRACE("_CHILDSIZE\n");
     
    18521997
    18531998    if (lprbbi->fMask & RBBIM_STYLE)
    1854     lpBand->fStyle = lprbbi->fStyle;
     1999        lpBand->fStyle = lprbbi->fStyle;
    18552000
    18562001    if (lprbbi->fMask & RBBIM_COLORS) {
    1857     lpBand->clrFore = lprbbi->clrFore;
    1858     lpBand->clrBack = lprbbi->clrBack;
     2002        lpBand->clrFore = lprbbi->clrFore;
     2003        lpBand->clrBack = lprbbi->clrBack;
    18592004    }
    18602005
    18612006    if (lprbbi->fMask & RBBIM_IMAGE)
    1862     lpBand->iImage = lprbbi->iImage;
     2007        lpBand->iImage = lprbbi->iImage;
    18632008
    18642009    if (lprbbi->fMask & RBBIM_CHILD) {
    1865     if (lprbbi->hwndChild) {
    1866         lpBand->hwndChild = lprbbi->hwndChild;
    1867         lpBand->hwndPrevParent =
    1868         SetParent (lpBand->hwndChild, hwnd);
    1869         /* below in trace fro WinRAR */
    1870         ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL);
    1871         /* above in trace fro WinRAR */
    1872     }
    1873     else {
    1874         TRACE("child: 0x%x  prev parent: 0x%x\n",
    1875            lpBand->hwndChild, lpBand->hwndPrevParent);
    1876         lpBand->hwndChild = 0;
    1877         lpBand->hwndPrevParent = 0;
    1878     }
     2010        if (lprbbi->hwndChild) {
     2011            lpBand->hwndChild = lprbbi->hwndChild;
     2012            lpBand->hwndPrevParent =
     2013                SetParent (lpBand->hwndChild, hwnd);
     2014            /* below in trace fro WinRAR */
     2015            ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL);
     2016            /* above in trace fro WinRAR */
     2017        }
     2018        else {
     2019            TRACE("child: 0x%x  prev parent: 0x%x\n",
     2020                   lpBand->hwndChild, lpBand->hwndPrevParent);
     2021            lpBand->hwndChild = 0;
     2022            lpBand->hwndPrevParent = 0;
     2023        }
    18792024    }
    18802025
    18812026    if (lprbbi->fMask & RBBIM_CHILDSIZE) {
    1882     lpBand->cxMinChild = lprbbi->cxMinChild;
    1883     lpBand->cyMinChild = lprbbi->cyMinChild;
    1884     if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
    1885         lpBand->cyChild    = lprbbi->cyChild;
    1886         lpBand->cyMaxChild = lprbbi->cyMaxChild;
    1887         lpBand->cyIntegral = lprbbi->cyIntegral;
    1888     }
    1889     else { /* special case - these should be zeroed out since   */
    1890            /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
    1891         lpBand->cyChild    = 0;
    1892         lpBand->cyMaxChild = 0;
    1893         lpBand->cyIntegral = 0;
    1894     }
     2027        lpBand->cxMinChild = lprbbi->cxMinChild;
     2028        lpBand->cyMinChild = lprbbi->cyMinChild;
     2029        if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
     2030            lpBand->cyChild    = lprbbi->cyChild;
     2031            lpBand->cyMaxChild = lprbbi->cyMaxChild;
     2032            lpBand->cyIntegral = lprbbi->cyIntegral;
     2033        }
     2034        else { /* special case - these should be zeroed out since   */
     2035               /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
     2036            lpBand->cyChild    = 0;
     2037            lpBand->cyMaxChild = 0;
     2038            lpBand->cyIntegral = 0;
     2039        }
    18952040    }
    18962041
    18972042    if (lprbbi->fMask & RBBIM_SIZE)
    1898     lpBand->cx = lprbbi->cx;
     2043        lpBand->cx = lprbbi->cx;
    18992044
    19002045    if (lprbbi->fMask & RBBIM_BACKGROUND)
    1901     lpBand->hbmBack = lprbbi->hbmBack;
     2046        lpBand->hbmBack = lprbbi->hbmBack;
    19022047
    19032048    if (lprbbi->fMask & RBBIM_ID)
    1904     lpBand->wID = lprbbi->wID;
     2049        lpBand->wID = lprbbi->wID;
    19052050
    19062051    /* check for additional data */
    19072052    if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
    1908     if (lprbbi->fMask & RBBIM_IDEALSIZE)
    1909         lpBand->cxIdeal = lprbbi->cxIdeal;
    1910 
    1911     if (lprbbi->fMask & RBBIM_LPARAM)
    1912         lpBand->lParam = lprbbi->lParam;
    1913 
    1914     if (lprbbi->fMask & RBBIM_HEADERSIZE)
    1915         lpBand->cxHeader = lprbbi->cxHeader;
     2053        if (lprbbi->fMask & RBBIM_IDEALSIZE)
     2054            lpBand->cxIdeal = lprbbi->cxIdeal;
     2055
     2056        if (lprbbi->fMask & RBBIM_LPARAM)
     2057            lpBand->lParam = lprbbi->lParam;
     2058
     2059        if (lprbbi->fMask & RBBIM_HEADERSIZE)
     2060            lpBand->cxHeader = lprbbi->cxHeader;
    19162061    }
    19172062}
     
    19332078    for(i=0; i<infoPtr->uNumBands; i++) {
    19342079        lpBand = &infoPtr->bands[i];
    1935     if (HIDDENBAND(lpBand)) continue;
    1936 
    1937     /* draw band separator between rows */
    1938     if (lpBand->iRow != oldrow) {
    1939         oldrow = lpBand->iRow;
    1940         if (lpBand->fDraw & DRAW_BOTTOMSEP) {
    1941         RECT rcRowSep;
    1942         rcRowSep = lpBand->rcBand;
    1943         if (infoPtr->dwStyle & CCS_VERT) {
    1944             rcRowSep.right += SEP_WIDTH_SIZE;
    1945             rcRowSep.bottom = infoPtr->calcSize.cy;
    1946             DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
    1947         }
    1948         else {
    1949             rcRowSep.bottom += SEP_WIDTH_SIZE;
    1950             rcRowSep.right = infoPtr->calcSize.cx;
    1951             DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
    1952         }
    1953         TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n",
    1954                rcRowSep.left, rcRowSep.top,
    1955                rcRowSep.right, rcRowSep.bottom);
    1956         }
    1957     }
    1958 
    1959     /* draw band separator between bands in a row */
    1960     if (lpBand->fDraw & DRAW_RIGHTSEP) {
    1961         RECT rcSep;
    1962         rcSep = lpBand->rcBand;
    1963         if (infoPtr->dwStyle & CCS_VERT) {
    1964         rcSep.bottom += SEP_WIDTH_SIZE;
    1965         DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
    1966         }
    1967         else {
    1968         rcSep.right += SEP_WIDTH_SIZE;
    1969         DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
    1970         }
    1971         TRACE("drawing band separator right (%d,%d)-(%d,%d)\n",
    1972           rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
    1973     }
    1974 
    1975     /* draw the actual background */
    1976     if (lpBand->clrBack != CLR_NONE)
    1977         new = lpBand->clrBack;
    1978     else
    1979         new = infoPtr->clrBtnFace;
    1980     rect = lpBand->rcBand;
    1981     old = SetBkColor (hdc, new);
    1982     TRACE("%s backround color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
    1983           (lpBand->clrBack == CLR_NONE) ? "std" : "",
    1984           new,
    1985           lpBand->rcBand.left,lpBand->rcBand.top,
    1986           lpBand->rcBand.right,lpBand->rcBand.bottom,
    1987           clip->left, clip->top,
    1988           clip->right, clip->bottom);
    1989     ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0);
    1990     SetBkColor (hdc, old);
     2080        if (HIDDENBAND(lpBand)) continue;
     2081
     2082        /* draw band separator between rows */
     2083        if (lpBand->iRow != oldrow) {
     2084            oldrow = lpBand->iRow;
     2085            if (lpBand->fDraw & DRAW_BOTTOMSEP) {
     2086                RECT rcRowSep;
     2087                rcRowSep = lpBand->rcBand;
     2088                if (infoPtr->dwStyle & CCS_VERT) {
     2089                    rcRowSep.right += SEP_WIDTH_SIZE;
     2090                    rcRowSep.bottom = infoPtr->calcSize.cy;
     2091                    DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
     2092                }
     2093                else {
     2094                    rcRowSep.bottom += SEP_WIDTH_SIZE;
     2095                    rcRowSep.right = infoPtr->calcSize.cx;
     2096                    DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
     2097                }
     2098                TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n",
     2099                       rcRowSep.left, rcRowSep.top,
     2100                       rcRowSep.right, rcRowSep.bottom);
     2101            }
     2102        }
     2103
     2104        /* draw band separator between bands in a row */
     2105        if (lpBand->fDraw & DRAW_RIGHTSEP) {
     2106            RECT rcSep;
     2107            rcSep = lpBand->rcBand;
     2108            if (infoPtr->dwStyle & CCS_VERT) {
     2109                rcSep.bottom += SEP_WIDTH_SIZE;
     2110                DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
     2111            }
     2112            else {
     2113                rcSep.right += SEP_WIDTH_SIZE;
     2114                DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
     2115            }
     2116            TRACE("drawing band separator right (%d,%d)-(%d,%d)\n",
     2117                  rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
     2118        }
     2119
     2120        /* draw the actual background */
     2121        if (lpBand->clrBack != CLR_NONE)
     2122            new = lpBand->clrBack;
     2123        else
     2124            new = infoPtr->clrBtnFace;
     2125        rect = lpBand->rcBand;
     2126#if GLATESTING
     2127        /* testing only - make background green to see it */
     2128        new = RGB(0,128,0);
     2129#endif
     2130        old = SetBkColor (hdc, new);
     2131        TRACE("%s background color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
     2132              (lpBand->clrBack == CLR_NONE) ? "std" : "",
     2133              new,
     2134              lpBand->rcBand.left,lpBand->rcBand.top,
     2135              lpBand->rcBand.right,lpBand->rcBand.bottom,
     2136              clip->left, clip->top,
     2137              clip->right, clip->bottom);
     2138        ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0);
     2139        SetBkColor (hdc, old);
    19912140    }
    19922141    return TRUE;
     
    20052154    if (PtInRect (&rect, *lpPt))
    20062155    {
    2007     if (infoPtr->uNumBands == 0) {
    2008         *pFlags = RBHT_NOWHERE;
    2009         if (pBand)
    2010         *pBand = -1;
    2011         TRACE("NOWHERE\n");
    2012         return;
     2156        if (infoPtr->uNumBands == 0) {
     2157            *pFlags = RBHT_NOWHERE;
     2158            if (pBand)
     2159                *pBand = -1;
     2160            TRACE("NOWHERE\n");
     2161            return;
     2162        }
     2163        else {
     2164            /* somewhere inside */
     2165            infoPtr->ihitBand = -1;
     2166            for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
     2167                lpBand = &infoPtr->bands[iCount];
     2168                if (HIDDENBAND(lpBand)) continue;
     2169                if (PtInRect (&lpBand->rcBand, *lpPt)) {
     2170                    if (pBand)
     2171                        *pBand = iCount;
     2172                    if (PtInRect (&lpBand->rcGripper, *lpPt)) {
     2173                        *pFlags = RBHT_GRABBER;
     2174                        infoPtr->ihitBand = iCount;
     2175                        TRACE("ON GRABBER %d\n", iCount);
     2176                        return;
     2177                    }
     2178                    else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
     2179                        *pFlags = RBHT_CAPTION;
     2180                        TRACE("ON CAPTION %d\n", iCount);
     2181                        return;
     2182                    }
     2183                    else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
     2184                        *pFlags = RBHT_CAPTION;
     2185                        TRACE("ON CAPTION %d\n", iCount);
     2186                        return;
     2187                    }
     2188                    else if (PtInRect (&lpBand->rcChild, *lpPt)) {
     2189                        *pFlags = RBHT_CLIENT;
     2190                        TRACE("ON CLIENT %d\n", iCount);
     2191                        return;
     2192                    }
     2193                    else {
     2194                        *pFlags = RBHT_NOWHERE;
     2195                        TRACE("NOWHERE %d\n", iCount);
     2196                        return;
     2197                    }
     2198                }
     2199            }
     2200
     2201            *pFlags = RBHT_NOWHERE;
     2202            if (pBand)
     2203                *pBand = -1;
     2204
     2205            TRACE("NOWHERE\n");
     2206            return;
     2207        }
    20132208    }
    20142209    else {
    2015         /* somewhere inside */
    2016         infoPtr->ihitBand = -1;
    2017         for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
    2018         lpBand = &infoPtr->bands[iCount];
    2019         if (HIDDENBAND(lpBand)) continue;
    2020         if (PtInRect (&lpBand->rcBand, *lpPt)) {
    2021             if (pBand)
    2022             *pBand = iCount;
    2023             if (PtInRect (&lpBand->rcGripper, *lpPt)) {
    2024             *pFlags = RBHT_GRABBER;
    2025             infoPtr->ihitBand = iCount;
    2026             TRACE("ON GRABBER %d\n", iCount);
    2027             return;
    2028             }
    2029             else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
    2030             *pFlags = RBHT_CAPTION;
    2031             TRACE("ON CAPTION %d\n", iCount);
    2032             return;
    2033             }
    2034             else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
    2035             *pFlags = RBHT_CAPTION;
    2036             TRACE("ON CAPTION %d\n", iCount);
    2037             return;
    2038             }
    2039             else if (PtInRect (&lpBand->rcChild, *lpPt)) {
    2040             *pFlags = RBHT_CLIENT;
    2041             TRACE("ON CLIENT %d\n", iCount);
    2042             return;
    2043             }
    2044             else {
    2045             *pFlags = RBHT_NOWHERE;
    2046             TRACE("NOWHERE %d\n", iCount);
    2047             return;
    2048             }
    2049         }
    2050         }
    2051 
    2052         *pFlags = RBHT_NOWHERE;
    2053         if (pBand)
    2054         *pBand = -1;
    2055 
    2056         TRACE("NOWHERE\n");
    2057         return;
    2058     }
    2059     }
    2060     else {
    2061     *pFlags = RBHT_NOWHERE;
    2062     if (pBand)
    2063         *pBand = -1;
    2064     TRACE("NOWHERE\n");
    2065     return;
     2210        *pFlags = RBHT_NOWHERE;
     2211        if (pBand)
     2212            *pBand = -1;
     2213        TRACE("NOWHERE\n");
     2214        return;
    20662215    }
    20672216
     
    20922241        /* if this band is not shrinkable, then just move it */
    20932242        Leadjust = Readjust = movement;
    2094     ret = movement;
     2243        ret = movement;
    20952244    }
    20962245    else {
    20972246        if (movement < 0) {
    2098         /* Drag to left */
    2099         if (avail <= abs(movement)) {
    2100             Readjust = movement;
    2101         Leadjust = movement + avail;
    2102         ret = Leadjust;
    2103         }
    2104         else {
    2105             Readjust = movement;
    2106         Leadjust = 0;
    2107         ret = 0;
    2108         }
    2109     }
    2110     else {
    2111         /* Drag to right */
    2112         if (avail <= abs(movement)) {
    2113             Leadjust = movement;
    2114         Readjust = movement - avail;
    2115         ret = Readjust;
    2116         }
    2117         else {
    2118             Leadjust = movement;
    2119         Readjust = 0;
    2120         ret = 0;
    2121         }
    2122     }
     2247            /* Drag to left */
     2248            if (avail <= abs(movement)) {
     2249                Readjust = movement;
     2250                Leadjust = movement + avail;
     2251                ret = Leadjust;
     2252            }
     2253            else {
     2254                Readjust = movement;
     2255                Leadjust = 0;
     2256                ret = 0;
     2257            }
     2258        }
     2259        else {
     2260            /* Drag to right */
     2261            if (avail <= abs(movement)) {
     2262                Leadjust = movement;
     2263                Readjust = movement - avail;
     2264                ret = Readjust;
     2265            }
     2266            else {
     2267                Leadjust = movement;
     2268                Readjust = 0;
     2269                ret = 0;
     2270            }
     2271        }
    21232272    }
    21242273
     
    21262275    if (rcBlt(band) + Leadjust < 0) {
    21272276        ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n",
    2128         i, Leadjust, Readjust, movement, ret);
     2277            i, Leadjust, Readjust, movement, ret);
    21292278    }
    21302279
     
    21332282
    21342283    TRACE("band %d:  left=%d, right=%d, move=%d, rtn=%d, rcBand=(%d,%d)-(%d,%d)\n",
    2135       i, Leadjust, Readjust, movement, ret,
    2136       band->rcBand.left, band->rcBand.top,
    2137       band->rcBand.right, band->rcBand.bottom);
     2284          i, Leadjust, Readjust, movement, ret,
     2285          band->rcBand.left, band->rcBand.top,
     2286          band->rcBand.right, band->rcBand.bottom);
    21382287    return ret;
    21392288}
     
    21582307
    21592308    if (!(infoPtr->fStatus & BEGIN_DRAG_ISSUED)) {
    2160     if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) {
    2161         /* Notify returned TRUE - abort drag */
    2162         infoPtr->dragStart.x = 0;
    2163         infoPtr->dragStart.y = 0;
    2164         infoPtr->dragNow = infoPtr->dragStart;
    2165         infoPtr->ihitBand = -1;
    2166         ReleaseCapture ();
    2167         return ;
    2168     }
    2169     infoPtr->fStatus |= BEGIN_DRAG_ISSUED;
     2309        if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) {
     2310            /* Notify returned TRUE - abort drag */
     2311            infoPtr->dragStart.x = 0;
     2312            infoPtr->dragStart.y = 0;
     2313            infoPtr->dragNow = infoPtr->dragStart;
     2314            infoPtr->ihitBand = -1;
     2315            ReleaseCapture ();
     2316            return ;
     2317        }
     2318        infoPtr->fStatus |= BEGIN_DRAG_ISSUED;
    21702319    }
    21712320
     
    21772326    for (i=0; i<infoPtr->uNumBands; i++) {
    21782327        band = &infoPtr->bands[i];
    2179     if (HIDDENBAND(band)) continue;
    2180     if (band->iRow == hitBand->iRow) {
    2181         imaxdBand = i;
    2182         if (imindBand == -1) imindBand = i;
    2183         /* minimum size of each band is size of header plus            */
    2184         /* size of minimum child plus offset of child from header plus */
    2185         /* a one to separate each band.                                */
    2186         if (i < ihitBand)
    2187             LHeaderSum += (band->lcx + SEP_WIDTH);
    2188         else
    2189             RHeaderSum += (band->lcx + SEP_WIDTH);
    2190 
    2191     }
     2328        if (HIDDENBAND(band)) continue;
     2329        if (band->iRow == hitBand->iRow) {
     2330            imaxdBand = i;
     2331            if (imindBand == -1) imindBand = i;
     2332            /* minimum size of each band is size of header plus            */
     2333            /* size of minimum child plus offset of child from header plus */
     2334            /* a one to separate each band.                                */
     2335            if (i < ihitBand)
     2336                LHeaderSum += (band->lcx + SEP_WIDTH);
     2337            else
     2338                RHeaderSum += (band->lcx + SEP_WIDTH);
     2339
     2340        }
    21922341    }
    21932342    if (RHeaderSum) RHeaderSum -= SEP_WIDTH; /* no separator afterlast band */
     
    22012350    /* limit movement to inside adjustable bands - Left */
    22022351    if ( (ptsmove->x < mindBand->rcBand.left) ||
    2203     (ptsmove->x > maxdBand->rcBand.right) ||
    2204     (ptsmove->y < mindBand->rcBand.top) ||
    2205     (ptsmove->y > maxdBand->rcBand.bottom))
     2352        (ptsmove->x > maxdBand->rcBand.right) ||
     2353        (ptsmove->y < mindBand->rcBand.top) ||
     2354        (ptsmove->y > maxdBand->rcBand.bottom))
    22062355        return; /* should swap bands */
    22072356
    22082357    if (infoPtr->dwStyle & CCS_VERT)
    22092358        movement = ptsmove->y - ((hitBand->rcBand.top+REBAR_PRE_GRIPPER) -
    2210                  infoPtr->ihitoffset);
     2359                             infoPtr->ihitoffset);
    22112360    else
    22122361        movement = ptsmove->x - ((hitBand->rcBand.left+REBAR_PRE_GRIPPER) -
    2213                  infoPtr->ihitoffset);
     2362                             infoPtr->ihitoffset);
    22142363    infoPtr->dragNow = *ptsmove;
    22152364
    22162365    TRACE("before: movement=%d (%d,%d), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
    2217       movement, ptsmove->x, ptsmove->y, imindBand, ihitBand,
    2218       imaxdBand, LHeaderSum, RHeaderSum);
     2366          movement, ptsmove->x, ptsmove->y, imindBand, ihitBand,
     2367          imaxdBand, LHeaderSum, RHeaderSum);
    22192368    REBAR_DumpBand (infoPtr);
    22202369
    2221     if (movement < 0) {
     2370    if (movement < 0) { 
    22222371
    22232372        /* ***  Drag left/up *** */
    22242373        compress = rcBlt(hitBand) - rcBlt(mindBand) -
    2225                LHeaderSum;
    2226     if (compress < abs(movement)) {
    2227         TRACE("limiting left drag, was %d changed to %d\n",
    2228           movement, -compress);
    2229         movement = -compress;
    2230     }
     2374                   LHeaderSum;
     2375        if (compress < abs(movement)) {
     2376            TRACE("limiting left drag, was %d changed to %d\n",
     2377                  movement, -compress);
     2378            movement = -compress;
     2379        }
    22312380
    22322381        for (i=ihitBand; i>=imindBand; i--) {
    2233         band = &infoPtr->bands[i];
    2234         if (HIDDENBAND(band)) continue;
    2235         if (i == ihitBand) {
    2236         LEADJ(band, movement)
    2237         }
    2238         else
    2239             movement = REBAR_Shrink (infoPtr, band, movement, i);
    2240         band->ccx = rcBw(band);
    2241     }
     2382            band = &infoPtr->bands[i];
     2383            if (HIDDENBAND(band)) continue;
     2384            if (i == ihitBand) {
     2385                LEADJ(band, movement)
     2386            }
     2387            else
     2388                movement = REBAR_Shrink (infoPtr, band, movement, i);
     2389            band->ccx = rcBw(band);
     2390        }
    22422391    }
    22432392    else {
    2244     BOOL first = TRUE;
     2393        BOOL first = TRUE;
    22452394
    22462395        /* ***  Drag right/down *** */
    22472396        compress = rcBrb(maxdBand) - rcBlt(hitBand) -
    2248                RHeaderSum;
    2249     if (compress < abs(movement)) {
    2250         TRACE("limiting right drag, was %d changed to %d\n",
    2251           movement, compress);
    2252         movement = compress;
    2253     }
     2397                   RHeaderSum;
     2398        if (compress < abs(movement)) {
     2399            TRACE("limiting right drag, was %d changed to %d\n",
     2400                  movement, compress);
     2401            movement = compress;
     2402        }
    22542403        for (i=ihitBand-1; i<=imaxdBand; i++) {
    2255         band = &infoPtr->bands[i];
    2256         if (HIDDENBAND(band)) continue;
    2257         if (first) {
    2258         first = FALSE;
    2259         READJ(band, movement)
    2260         }
    2261         else
    2262             movement = REBAR_Shrink (infoPtr, band, movement, i);
    2263         band->ccx = rcBw(band);
    2264     }
     2404            band = &infoPtr->bands[i];
     2405            if (HIDDENBAND(band)) continue;
     2406            if (first) {
     2407                first = FALSE;
     2408                READJ(band, movement)
     2409            }
     2410            else
     2411                movement = REBAR_Shrink (infoPtr, band, movement, i);
     2412            band->ccx = rcBw(band);
     2413        }
    22652414    }
    22662415
    22672416    /* recompute all rectangles */
    22682417    if (infoPtr->dwStyle & CCS_VERT) {
    2269     REBAR_CalcVertBand (infoPtr, imindBand, imaxdBand+1,
    2270                 FALSE);
     2418        REBAR_CalcVertBand (infoPtr, imindBand, imaxdBand+1,
     2419                            FALSE);
    22712420    }
    22722421    else {
    2273     REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1,
    2274                 FALSE);
     2422        REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1,
     2423                            FALSE);
    22752424    }
    22762425
    22772426    TRACE("bands after adjustment, see band # %d, %d\n",
    2278       imindBand, imaxdBand);
     2427          imindBand, imaxdBand);
    22792428    REBAR_DumpBand (infoPtr);
    22802429
    2281     SetRect (&newrect,
    2282          mindBand->rcBand.left,
    2283          mindBand->rcBand.top,
    2284          maxdBand->rcBand.right,
    2285          maxdBand->rcBand.bottom);
     2430    SetRect (&newrect, 
     2431             mindBand->rcBand.left,
     2432             mindBand->rcBand.top,
     2433             maxdBand->rcBand.right,
     2434             maxdBand->rcBand.bottom);
    22862435
    22872436    REBAR_MoveChildWindows (infoPtr, imindBand, imaxdBand+1);
     
    23052454
    23062455    if (uBand >= infoPtr->uNumBands)
    2307     return FALSE;
     2456        return FALSE;
    23082457
    23092458    TRACE("deleting band %u!\n", uBand);
     
    23122461
    23132462    if (infoPtr->uNumBands == 1) {
    2314     TRACE(" simple delete!\n");
    2315     if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
    2316         childhwnd = lpBand->hwndChild;
    2317     COMCTL32_Free (infoPtr->bands);
    2318     infoPtr->bands = NULL;
    2319     infoPtr->uNumBands = 0;
     2463        TRACE(" simple delete!\n");
     2464        if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
     2465            childhwnd = lpBand->hwndChild;
     2466        COMCTL32_Free (infoPtr->bands);
     2467        infoPtr->bands = NULL;
     2468        infoPtr->uNumBands = 0;
    23202469    }
    23212470    else {
    2322     REBAR_BAND *oldBands = infoPtr->bands;
     2471        REBAR_BAND *oldBands = infoPtr->bands;
    23232472        TRACE("complex delete! [uBand=%u]\n", uBand);
    23242473
    2325     if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
    2326         childhwnd = lpBand->hwndChild;
    2327 
    2328     infoPtr->uNumBands--;
    2329     infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
     2474        if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
     2475            childhwnd = lpBand->hwndChild;
     2476
     2477        infoPtr->uNumBands--;
     2478        infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
    23302479        if (uBand > 0) {
    23312480            memcpy (&infoPtr->bands[0], &oldBands[0],
     
    23382487        }
    23392488
    2340     COMCTL32_Free (oldBands);
     2489        COMCTL32_Free (oldBands);
    23412490    }
    23422491
     
    23702519
    23712520    if (!lParam)
    2372     return 0;
     2521        return 0;
    23732522    if ((UINT)wParam >= infoPtr->uNumBands)
    2374     return 0;
     2523        return 0;
    23752524
    23762525    lpBand = &infoPtr->bands[(UINT)wParam];
     
    23822531    /* style.  -  GA                                                   */
    23832532    if (infoPtr->dwStyle & RBS_BANDBORDERS) {
    2384     if (infoPtr->dwStyle & CCS_VERT) {
    2385         lpRect->left = 1;
    2386         lpRect->top = lpBand->cxHeader + 4;
    2387         lpRect->right = 1;
    2388         lpRect->bottom = 0;
     2533        if (infoPtr->dwStyle & CCS_VERT) {
     2534            lpRect->left = 1;
     2535            lpRect->top = lpBand->cxHeader + 4;
     2536            lpRect->right = 1;
     2537            lpRect->bottom = 0;
     2538        }
     2539        else {
     2540            lpRect->left = lpBand->cxHeader + 4;
     2541            lpRect->top = 1;
     2542            lpRect->right = 0;
     2543            lpRect->bottom = 1;
     2544        }
    23892545    }
    23902546    else {
    2391         lpRect->left = lpBand->cxHeader + 4;
    2392         lpRect->top = 1;
    2393         lpRect->right = 0;
    2394         lpRect->bottom = 1;
    2395     }
    2396     }
    2397     else {
    2398     lpRect->left = lpBand->cxHeader;
     2547        lpRect->left = lpBand->cxHeader;
    23992548    }
    24002549    return 0;
     
    24182567
    24192568    if (lprbbi == NULL)
    2420     return FALSE;
     2569        return FALSE;
    24212570    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
    2422     return FALSE;
     2571        return FALSE;
    24232572    if ((UINT)wParam >= infoPtr->uNumBands)
    2424     return FALSE;
     2573        return FALSE;
    24252574
    24262575    TRACE("index %u\n", (UINT)wParam);
     
    24302579
    24312580    if (lprbbi->fMask & RBBIM_STYLE)
    2432     lprbbi->fStyle = lpBand->fStyle;
     2581        lprbbi->fStyle = lpBand->fStyle;
    24332582
    24342583    if (lprbbi->fMask & RBBIM_COLORS) {
    2435     lprbbi->clrFore = lpBand->clrFore;
    2436     lprbbi->clrBack = lpBand->clrBack;
    2437     if (lprbbi->clrBack == CLR_NONE)
    2438         lprbbi->clrBack = infoPtr->clrBtnFace;
     2584        lprbbi->clrFore = lpBand->clrFore;
     2585        lprbbi->clrBack = lpBand->clrBack;
     2586        if (lprbbi->clrBack == CLR_NONE)
     2587            lprbbi->clrBack = infoPtr->clrBtnFace;
    24392588    }
    24402589
     
    24462595              lprbbi->lpText[lprbbi->cch-1] = 0;
    24472596      }
    2448       else
    2449     *lprbbi->lpText = 0;
     2597      else 
     2598        *lprbbi->lpText = 0;
    24502599    }
    24512600
    24522601    if (lprbbi->fMask & RBBIM_IMAGE) {
    24532602      if (lpBand->fMask & RBBIM_IMAGE)
    2454     lprbbi->iImage = lpBand->iImage;
     2603        lprbbi->iImage = lpBand->iImage;
    24552604      else
    2456     lprbbi->iImage = -1;
     2605        lprbbi->iImage = -1;
    24572606    }
    24582607
    24592608    if (lprbbi->fMask & RBBIM_CHILD)
    2460     lprbbi->hwndChild = lpBand->hwndChild;
     2609        lprbbi->hwndChild = lpBand->hwndChild;
    24612610
    24622611    if (lprbbi->fMask & RBBIM_CHILDSIZE) {
    2463     lprbbi->cxMinChild = lpBand->cxMinChild;
    2464     lprbbi->cyMinChild = lpBand->cyMinChild;
    2465     if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
    2466         lprbbi->cyChild    = lpBand->cyChild;
    2467         lprbbi->cyMaxChild = lpBand->cyMaxChild;
    2468         lprbbi->cyIntegral = lpBand->cyIntegral;
    2469     }
     2612        lprbbi->cxMinChild = lpBand->cxMinChild;
     2613        lprbbi->cyMinChild = lpBand->cyMinChild;
     2614        if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
     2615            lprbbi->cyChild    = lpBand->cyChild;
     2616            lprbbi->cyMaxChild = lpBand->cyMaxChild;
     2617            lprbbi->cyIntegral = lpBand->cyIntegral;
     2618        }
    24702619    }
    24712620
    24722621    if (lprbbi->fMask & RBBIM_SIZE)
    2473     lprbbi->cx = lpBand->cx;
     2622        lprbbi->cx = lpBand->cx;
    24742623
    24752624    if (lprbbi->fMask & RBBIM_BACKGROUND)
    2476     lprbbi->hbmBack = lpBand->hbmBack;
     2625        lprbbi->hbmBack = lpBand->hbmBack;
    24772626
    24782627    if (lprbbi->fMask & RBBIM_ID)
    2479     lprbbi->wID = lpBand->wID;
     2628        lprbbi->wID = lpBand->wID;
    24802629
    24812630    /* check for additional data */
    24822631    if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
    2483     if (lprbbi->fMask & RBBIM_IDEALSIZE)
    2484         lprbbi->cxIdeal = lpBand->cxIdeal;
    2485 
    2486     if (lprbbi->fMask & RBBIM_LPARAM)
    2487         lprbbi->lParam = lpBand->lParam;
    2488 
    2489     if (lprbbi->fMask & RBBIM_HEADERSIZE)
    2490         lprbbi->cxHeader = lpBand->cxHeader;
     2632        if (lprbbi->fMask & RBBIM_IDEALSIZE)
     2633            lprbbi->cxIdeal = lpBand->cxIdeal;
     2634
     2635        if (lprbbi->fMask & RBBIM_LPARAM)
     2636            lprbbi->lParam = lpBand->lParam;
     2637
     2638        if (lprbbi->fMask & RBBIM_HEADERSIZE)
     2639            lprbbi->cxHeader = lpBand->cxHeader;
    24912640    }
    24922641
     
    25042653
    25052654    if (lprbbi == NULL)
    2506     return FALSE;
     2655        return FALSE;
    25072656    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
    2508     return FALSE;
     2657        return FALSE;
    25092658    if ((UINT)wParam >= infoPtr->uNumBands)
    2510     return FALSE;
     2659        return FALSE;
    25112660
    25122661    TRACE("index %u\n", (UINT)wParam);
     
    25162665
    25172666    if (lprbbi->fMask & RBBIM_STYLE)
    2518     lprbbi->fStyle = lpBand->fStyle;
     2667        lprbbi->fStyle = lpBand->fStyle;
    25192668
    25202669    if (lprbbi->fMask & RBBIM_COLORS) {
    2521     lprbbi->clrFore = lpBand->clrFore;
    2522     lprbbi->clrBack = lpBand->clrBack;
    2523     if (lprbbi->clrBack == CLR_NONE)
    2524         lprbbi->clrBack = infoPtr->clrBtnFace;
     2670        lprbbi->clrFore = lpBand->clrFore;
     2671        lprbbi->clrBack = lpBand->clrBack;
     2672        if (lprbbi->clrBack == CLR_NONE)
     2673            lprbbi->clrBack = infoPtr->clrBtnFace;
    25252674    }
    25262675
    25272676    if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
    25282677      if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
    2529     lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
    2530       else
    2531     *lprbbi->lpText = 0;
     2678        lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
     2679      else 
     2680        *lprbbi->lpText = 0;
    25322681    }
    25332682
    25342683    if (lprbbi->fMask & RBBIM_IMAGE) {
    25352684      if (lpBand->fMask & RBBIM_IMAGE)
    2536     lprbbi->iImage = lpBand->iImage;
     2685        lprbbi->iImage = lpBand->iImage;
    25372686      else
    2538     lprbbi->iImage = -1;
     2687        lprbbi->iImage = -1;
    25392688    }
    25402689
    25412690    if (lprbbi->fMask & RBBIM_CHILD)
    2542     lprbbi->hwndChild = lpBand->hwndChild;
     2691        lprbbi->hwndChild = lpBand->hwndChild;
    25432692
    25442693    if (lprbbi->fMask & RBBIM_CHILDSIZE) {
    2545     lprbbi->cxMinChild = lpBand->cxMinChild;
    2546     lprbbi->cyMinChild = lpBand->cyMinChild;
    2547     if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
    2548         lprbbi->cyChild    = lpBand->cyChild;
    2549         lprbbi->cyMaxChild = lpBand->cyMaxChild;
    2550         lprbbi->cyIntegral = lpBand->cyIntegral;
    2551     }
     2694        lprbbi->cxMinChild = lpBand->cxMinChild;
     2695        lprbbi->cyMinChild = lpBand->cyMinChild;
     2696        if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
     2697            lprbbi->cyChild    = lpBand->cyChild;
     2698            lprbbi->cyMaxChild = lpBand->cyMaxChild;
     2699            lprbbi->cyIntegral = lpBand->cyIntegral;
     2700        }
    25522701    }
    25532702
    25542703    if (lprbbi->fMask & RBBIM_SIZE)
    2555     lprbbi->cx = lpBand->cx;
     2704        lprbbi->cx = lpBand->cx;
    25562705
    25572706    if (lprbbi->fMask & RBBIM_BACKGROUND)
    2558     lprbbi->hbmBack = lpBand->hbmBack;
     2707        lprbbi->hbmBack = lpBand->hbmBack;
    25592708
    25602709    if (lprbbi->fMask & RBBIM_ID)
    2561     lprbbi->wID = lpBand->wID;
     2710        lprbbi->wID = lpBand->wID;
    25622711
    25632712    /* check for additional data */
    25642713    if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
    2565     if (lprbbi->fMask & RBBIM_IDEALSIZE)
    2566         lprbbi->cxIdeal = lpBand->cxIdeal;
    2567 
    2568     if (lprbbi->fMask & RBBIM_LPARAM)
    2569         lprbbi->lParam = lpBand->lParam;
    2570 
    2571     if (lprbbi->fMask & RBBIM_HEADERSIZE)
    2572         lprbbi->cxHeader = lpBand->cxHeader;
     2714        if (lprbbi->fMask & RBBIM_IDEALSIZE)
     2715            lprbbi->cxIdeal = lpBand->cxIdeal;
     2716
     2717        if (lprbbi->fMask & RBBIM_LPARAM)
     2718            lprbbi->lParam = lpBand->lParam;
     2719
     2720        if (lprbbi->fMask & RBBIM_HEADERSIZE)
     2721            lprbbi->cxHeader = lpBand->cxHeader;
    25732722    }
    25742723
     
    25982747
    25992748    if (lpInfo == NULL)
    2600     return FALSE;
     2749        return FALSE;
    26012750
    26022751    if (lpInfo->cbSize < sizeof (REBARINFO))
    2603     return FALSE;
     2752        return FALSE;
    26042753
    26052754    TRACE("getting bar info!\n");
    26062755
    26072756    if (infoPtr->himl) {
    2608     lpInfo->himl = infoPtr->himl;
    2609     lpInfo->fMask |= RBIM_IMAGELIST;
     2757        lpInfo->himl = infoPtr->himl;
     2758        lpInfo->fMask |= RBIM_IMAGELIST;
    26102759    }
    26112760
     
    26492798
    26502799    if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
    2651     return FALSE;
     2800        return FALSE;
    26522801    if (!lprc)
    2653     return FALSE;
     2802        return FALSE;
    26542803
    26552804    lpBand = &infoPtr->bands[iBand];
     
    26572806
    26582807    TRACE("band %d, (%d,%d)-(%d,%d)\n", iBand,
    2659       lprc->left, lprc->top, lprc->right, lprc->bottom);
     2808          lprc->left, lprc->top, lprc->right, lprc->bottom);
    26602809
    26612810    return TRUE;
     
    26812830
    26822831    for (i=0; i<infoPtr->uNumBands; i++) {
    2683     lpBand = &infoPtr->bands[i];
    2684     if (HIDDENBAND(lpBand)) continue;
    2685     if (lpBand->iRow != iRow) continue;
    2686     if (infoPtr->dwStyle & CCS_VERT)
    2687         j = lpBand->rcBand.right - lpBand->rcBand.left;
    2688     else
    2689         j = lpBand->rcBand.bottom - lpBand->rcBand.top;
    2690     if (j > ret) ret = j;
     2832        lpBand = &infoPtr->bands[i];
     2833        if (HIDDENBAND(lpBand)) continue;
     2834        if (lpBand->iRow != iRow) continue;
     2835        if (infoPtr->dwStyle & CCS_VERT)
     2836            j = lpBand->rcBand.right - lpBand->rcBand.left;
     2837        else
     2838            j = lpBand->rcBand.bottom - lpBand->rcBand.top;
     2839        if (j > ret) ret = j;
    26912840    }
    26922841
     
    27162865REBAR_GetUnicodeFormat (REBAR_INFO *infoPtr)
    27172866{
    2718     TRACE("%s hwnd=0x%x\n",
    2719       infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
     2867    TRACE("%s hwnd=0x%x\n", 
     2868          infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
    27202869
    27212870    return infoPtr->bUnicode;
     
    27342883REBAR_HitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
    27352884{
    2736     LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
     2885    LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam; 
    27372886
    27382887    if (!lprbht)
    2739     return -1;
     2888        return -1;
    27402889
    27412890    REBAR_InternalHitTest (infoPtr, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
     
    27512900
    27522901    if (infoPtr == NULL)
    2753     return -1;
     2902        return -1;
    27542903
    27552904    if (infoPtr->uNumBands < 1)
    2756     return -1;
     2905        return -1;
    27572906
    27582907    for (i = 0; i < infoPtr->uNumBands; i++) {
    2759     if (infoPtr->bands[i].wID == (UINT)wParam) {
    2760         TRACE("id %u is band %u found!\n", (UINT)wParam, i);
    2761         return i;
    2762     }
     2908        if (infoPtr->bands[i].wID == (UINT)wParam) {
     2909            TRACE("id %u is band %u found!\n", (UINT)wParam, i);
     2910            return i;
     2911        }
    27632912    }
    27642913
     
    27762925
    27772926    if (infoPtr == NULL)
    2778     return FALSE;
     2927        return FALSE;
    27792928    if (lprbbi == NULL)
    2780     return FALSE;
     2929        return FALSE;
    27812930    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
    2782     return FALSE;
     2931        return FALSE;
    27832932
    27842933    /* trace the index as signed to see the -1 */
     
    27872936
    27882937    if (infoPtr->uNumBands == 0) {
    2789     infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
    2790     uIndex = 0;
     2938        infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
     2939        uIndex = 0;
    27912940    }
    27922941    else {
    2793     REBAR_BAND *oldBands = infoPtr->bands;
    2794     infoPtr->bands =
    2795         (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
    2796     if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
    2797         uIndex = infoPtr->uNumBands;
    2798 
    2799     /* pre insert copy */
    2800     if (uIndex > 0) {
    2801         memcpy (&infoPtr->bands[0], &oldBands[0],
    2802             uIndex * sizeof(REBAR_BAND));
    2803     }
    2804 
    2805     /* post copy */
    2806     if (uIndex < infoPtr->uNumBands - 1) {
    2807         memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
    2808             (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
    2809     }
    2810 
    2811     COMCTL32_Free (oldBands);
     2942        REBAR_BAND *oldBands = infoPtr->bands;
     2943        infoPtr->bands =
     2944            (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
     2945        if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
     2946            uIndex = infoPtr->uNumBands;
     2947
     2948        /* pre insert copy */
     2949        if (uIndex > 0) {
     2950            memcpy (&infoPtr->bands[0], &oldBands[0],
     2951                    uIndex * sizeof(REBAR_BAND));
     2952        }
     2953
     2954        /* post copy */
     2955        if (uIndex < infoPtr->uNumBands - 1) {
     2956            memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
     2957                    (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
     2958        }
     2959
     2960        COMCTL32_Free (oldBands);
    28122961    }
    28132962
     
    28322981            lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR));
    28332982            MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
    2834     }
     2983        }
    28352984    }
    28362985
     
    28382987    /* On insert of second band, revalidate band 1 to possible add gripper */
    28392988    if (infoPtr->uNumBands == 2)
    2840     REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
     2989        REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
    28412990
    28422991    REBAR_DumpBand (infoPtr);
    28432992
    28442993    REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
     2994    InvalidateRect(infoPtr->hwndSelf, 0, 1);
    28452995
    28462996    return TRUE;
     
    28563006
    28573007    if (infoPtr == NULL)
    2858     return FALSE;
     3008        return FALSE;
    28593009    if (lprbbi == NULL)
    2860     return FALSE;
     3010        return FALSE;
    28613011    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
    2862     return FALSE;
     3012        return FALSE;
    28633013
    28643014    /* trace the index as signed to see the -1 */
     
    28673017
    28683018    if (infoPtr->uNumBands == 0) {
    2869     infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
    2870     uIndex = 0;
     3019        infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
     3020        uIndex = 0;
    28713021    }
    28723022    else {
    2873     REBAR_BAND *oldBands = infoPtr->bands;
    2874     infoPtr->bands =
    2875         (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
    2876     if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
    2877         uIndex = infoPtr->uNumBands;
    2878 
    2879     /* pre insert copy */
    2880     if (uIndex > 0) {
    2881         memcpy (&infoPtr->bands[0], &oldBands[0],
    2882             uIndex * sizeof(REBAR_BAND));
    2883     }
    2884 
    2885     /* post copy */
    2886     if (uIndex < infoPtr->uNumBands - 1) {
    2887         memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
    2888             (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
    2889     }
    2890 
    2891     COMCTL32_Free (oldBands);
     3023        REBAR_BAND *oldBands = infoPtr->bands;
     3024        infoPtr->bands =
     3025            (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
     3026        if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
     3027            uIndex = infoPtr->uNumBands;
     3028
     3029        /* pre insert copy */
     3030        if (uIndex > 0) {
     3031            memcpy (&infoPtr->bands[0], &oldBands[0],
     3032                    uIndex * sizeof(REBAR_BAND));
     3033        }
     3034
     3035        /* post copy */
     3036        if (uIndex < infoPtr->uNumBands - 1) {
     3037            memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
     3038                    (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
     3039        }
     3040
     3041        COMCTL32_Free (oldBands);
    28923042    }
    28933043
     
    29083058    lpBand->lpText = NULL;
    29093059    if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
    2910     INT len = lstrlenW (lprbbi->lpText);
    2911     if (len > 0) {
    2912         lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    2913         strcpyW (lpBand->lpText, lprbbi->lpText);
    2914     }
     3060        INT len = lstrlenW (lprbbi->lpText);
     3061        if (len > 0) {
     3062            lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     3063            strcpyW (lpBand->lpText, lprbbi->lpText);
     3064        }
    29153065    }
    29163066
     
    29183068    /* On insert of second band, revalidate band 1 to possible add gripper */
    29193069    if (infoPtr->uNumBands == 2)
    2920     REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
     3070        REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
    29213071
    29223072    REBAR_DumpBand (infoPtr);
    29233073
    29243074    REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
     3075    InvalidateRect(infoPtr->hwndSelf, 0, 1);
    29253076
    29263077    return TRUE;
     
    29313082REBAR_MaximizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
    29323083{
    2933     FIXME("(uBand = %u fIdeal = %s) stub\n",
    2934        (UINT)wParam, lParam ? "TRUE" : "FALSE");
    2935 
    2936     return 0;
     3084    REBAR_BAND *lpBand;
     3085    UINT uBand = (UINT) wParam;
     3086
     3087    /* Validate */
     3088    if ((infoPtr->uNumBands == 0) ||
     3089        ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
     3090        /* error !!! */
     3091        ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
     3092              (INT)uBand, infoPtr->uNumBands);
     3093        return FALSE;
     3094    }
     3095
     3096    lpBand = &infoPtr->bands[uBand];
     3097
     3098    if (lParam && (lpBand->fMask & RBBIM_IDEALSIZE)) {
     3099        /* handle setting ideal size */
     3100        lpBand->ccx = lpBand->cxIdeal;
     3101    }
     3102    else {
     3103        /* handle setting to max */
     3104        FIXME("(uBand = %u fIdeal = %s) case not coded\n",
     3105              (UINT)wParam, lParam ? "TRUE" : "FALSE");
     3106        return FALSE;
     3107    }
     3108
     3109    infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
     3110    REBAR_Layout (infoPtr, 0, TRUE, TRUE);
     3111    InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
     3112
     3113    return TRUE;
    29373114
    29383115}
     
    29553132    /* Validate */
    29563133    if ((infoPtr->uNumBands == 0) ||
    2957     ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
    2958     /* error !!! */
    2959     ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
    2960           (INT)uBand, infoPtr->uNumBands);
    2961         return FALSE;
     3134        ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
     3135        /* error !!! */
     3136        ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
     3137              (INT)uBand, infoPtr->uNumBands);
     3138        return FALSE;
    29623139    }
    29633140
     
    29663143
    29673144    if (infoPtr->dwStyle & CCS_VERT)
    2968     movement = lpBand->rcBand.bottom - lpBand->rcBand.top -
    2969         lpBand->cxHeader;
     3145        movement = lpBand->rcBand.bottom - lpBand->rcBand.top -
     3146            lpBand->cxHeader;
    29703147    else
    2971     movement = lpBand->rcBand.right - lpBand->rcBand.left -
    2972         lpBand->cxHeader;
     3148        movement = lpBand->rcBand.right - lpBand->rcBand.left -
     3149            lpBand->cxHeader;
    29733150    if (movement < 0) {
    2974     ERR("something is wrong, band=(%d,%d)-(%d,%d), cxheader=%d\n",
    2975         lpBand->rcBand.left, lpBand->rcBand.top,
    2976         lpBand->rcBand.right, lpBand->rcBand.bottom,
    2977         lpBand->cxHeader);
    2978     return FALSE;
     3151        ERR("something is wrong, band=(%d,%d)-(%d,%d), cxheader=%d\n",
     3152            lpBand->rcBand.left, lpBand->rcBand.top,
     3153            lpBand->rcBand.right, lpBand->rcBand.bottom,
     3154            lpBand->cxHeader);
     3155        return FALSE;
    29793156    }
    29803157
     
    29863163    for (i=0; i<infoPtr->uNumBands; i++) {
    29873164        band = &infoPtr->bands[i];
    2988     if (HIDDENBAND(band)) continue;
    2989     if (band->iRow == lpBand->iRow) {
    2990         imaxdBand = i;
    2991         if (imindBand == -1) imindBand = i;
    2992     }
     3165        if (HIDDENBAND(band)) continue;
     3166        if (band->iRow == lpBand->iRow) {
     3167            imaxdBand = i;
     3168            if (imindBand == -1) imindBand = i;
     3169        }
    29933170    }
    29943171
     
    29963173    /* next visible band                                        */
    29973174    if (imindBand == uBand) {
    2998     band = NULL;
    2999     movement = -movement;
    3000     /* find the first visible band to the right of the selected band */
    3001     for (i=uBand+1; i<=imaxdBand; i++) {
    3002         band = &infoPtr->bands[i];
    3003         if (!HIDDENBAND(band)) {
    3004         iprevBand = i;
    3005         LEADJ(band, movement);
    3006         band->ccx = rcBw(band);
    3007         break;
    3008         }
    3009     }
    3010     /* what case is this */
    3011     if (iprevBand == -1) {
    3012         ERR("no previous visible band\n");
    3013         return FALSE;
    3014     }
    3015     startBand = uBand;
    3016     endBand = iprevBand;
    3017     SetRect (&newrect,
    3018         lpBand->rcBand.left,
    3019         lpBand->rcBand.top,
    3020         band->rcBand.right,
    3021         band->rcBand.bottom);
     3175        band = NULL;
     3176        movement = -movement;
     3177        /* find the first visible band to the right of the selected band */
     3178        for (i=uBand+1; i<=imaxdBand; i++) {
     3179            band = &infoPtr->bands[i];
     3180            if (!HIDDENBAND(band)) {
     3181                iprevBand = i;
     3182                LEADJ(band, movement);
     3183                band->ccx = rcBw(band);
     3184                break;
     3185            }
     3186        }
     3187        /* what case is this */
     3188        if (iprevBand == -1) {
     3189            ERR("no previous visible band\n");
     3190            return FALSE;
     3191        }
     3192        startBand = uBand;
     3193        endBand = iprevBand;
     3194        SetRect (&newrect,
     3195                lpBand->rcBand.left,
     3196                lpBand->rcBand.top,
     3197                band->rcBand.right,
     3198                band->rcBand.bottom);
    30223199    }
    30233200    /* otherwise expand previous visible band                   */
    30243201    else {
    3025     band = NULL;
    3026     /* find the first visible band to the left of the selected band */
    3027     for (i=uBand-1; i>=imindBand; i--) {
    3028         band = &infoPtr->bands[i];
    3029         if (!HIDDENBAND(band)) {
    3030         iprevBand = i;
    3031         READJ(band, movement);
    3032         band->ccx = rcBw(band);
    3033         break;
    3034         }
    3035     }
    3036     /* what case is this */
    3037     if (iprevBand == -1) {
    3038         ERR("no previous visible band\n");
    3039         return FALSE;
    3040     }
    3041     startBand = iprevBand;
    3042     endBand = uBand;
    3043     SetRect (&newrect,
    3044         band->rcBand.left,
    3045         band->rcBand.top,
    3046         lpBand->rcBand.right,
    3047         lpBand->rcBand.bottom);
     3202        band = NULL;
     3203        /* find the first visible band to the left of the selected band */
     3204        for (i=uBand-1; i>=imindBand; i--) {
     3205            band = &infoPtr->bands[i];
     3206            if (!HIDDENBAND(band)) {
     3207                iprevBand = i;
     3208                READJ(band, movement);
     3209                band->ccx = rcBw(band);
     3210                break;
     3211            }
     3212        }
     3213        /* what case is this */
     3214        if (iprevBand == -1) {
     3215            ERR("no previous visible band\n");
     3216            return FALSE;
     3217        }
     3218        startBand = iprevBand;
     3219        endBand = uBand;
     3220        SetRect (&newrect,
     3221                band->rcBand.left,
     3222                band->rcBand.top,
     3223                lpBand->rcBand.right,
     3224                lpBand->rcBand.bottom);
    30483225    }
    30493226
     
    30523229    /* recompute all rectangles */
    30533230    if (infoPtr->dwStyle & CCS_VERT) {
    3054     REBAR_CalcVertBand (infoPtr, startBand, endBand+1,
    3055                 FALSE);
     3231        REBAR_CalcVertBand (infoPtr, startBand, endBand+1,
     3232                            FALSE);
    30563233    }
    30573234    else {
    3058     REBAR_CalcHorzBand (infoPtr, startBand, endBand+1,
    3059                 FALSE);
     3235        REBAR_CalcHorzBand (infoPtr, startBand, endBand+1,
     3236                            FALSE);
    30603237    }
    30613238
    30623239    TRACE("bands after minimize, see band # %d, %d\n",
    3063       startBand, endBand);
     3240          startBand, endBand);
    30643241    REBAR_DumpBand (infoPtr);
    30653242
     
    30823259    /* Validate */
    30833260    if ((infoPtr->uNumBands == 0) ||
    3084     ((INT)uFrom < 0) || (uFrom >= infoPtr->uNumBands) ||
    3085     ((INT)uTo < 0)   || (uTo >= infoPtr->uNumBands)) {
    3086     /* error !!! */
    3087     ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
    3088           (INT)uFrom, (INT)uTo, infoPtr->uNumBands);
    3089         return FALSE;
     3261        ((INT)uFrom < 0) || (uFrom >= infoPtr->uNumBands) ||
     3262        ((INT)uTo < 0)   || (uTo >= infoPtr->uNumBands)) {
     3263        /* error !!! */
     3264        ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
     3265              (INT)uFrom, (INT)uTo, infoPtr->uNumBands);
     3266        return FALSE;
    30903267    }
    30913268
     
    30953272    /* close up rest of bands (psuedo delete) */
    30963273    if (uFrom < infoPtr->uNumBands - 1) {
    3097     memcpy (&oldBands[uFrom], &oldBands[uFrom+1],
    3098         (infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND));
     3274        memcpy (&oldBands[uFrom], &oldBands[uFrom+1],
     3275                (infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND));
    30993276    }
    31003277
    31013278    /* allocate new space and copy rest of bands into it */
    31023279    infoPtr->bands =
    3103     (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
     3280        (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
    31043281
    31053282    /* pre insert copy */
    31063283    if (uTo > 0) {
    3107     memcpy (&infoPtr->bands[0], &oldBands[0],
    3108         uTo * sizeof(REBAR_BAND));
     3284        memcpy (&infoPtr->bands[0], &oldBands[0],
     3285                uTo * sizeof(REBAR_BAND));
    31093286    }
    31103287
     
    31143291    /* post copy */
    31153292    if (uTo < infoPtr->uNumBands - 1) {
    3116     memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo],
    3117         (infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND));
     3293        memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo],
     3294                (infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND));
    31183295    }
    31193296
     
    31443321
    31453322    if (lprbbi == NULL)
    3146     return FALSE;
     3323        return FALSE;
    31473324    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
    3148     return FALSE;
     3325        return FALSE;
    31493326    if ((UINT)wParam >= infoPtr->uNumBands)
    3150     return FALSE;
     3327        return FALSE;
    31513328
    31523329    TRACE("index %u\n", (UINT)wParam);
     
    31583335    REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
    31593336    if (lprbbi->fMask & RBBIM_TEXT) {
    3160     if (lpBand->lpText) {
    3161         COMCTL32_Free (lpBand->lpText);
    3162         lpBand->lpText = NULL;
    3163     }
    3164     if (lprbbi->lpText) {
     3337        if (lpBand->lpText) {
     3338            COMCTL32_Free (lpBand->lpText);
     3339            lpBand->lpText = NULL;
     3340        }
     3341        if (lprbbi->lpText) {
    31653342            INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
    31663343            lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR));
    31673344            MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
    3168     }
     3345        }
    31693346    }
    31703347
     
    31733350    REBAR_DumpBand (infoPtr);
    31743351
    3175     if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE))
    3176       REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
     3352    if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) {
     3353          REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
     3354          InvalidateRect(infoPtr->hwndSelf, 0, 1);
     3355    }
    31773356
    31783357    return TRUE;
     
    31873366
    31883367    if (lprbbi == NULL)
    3189     return FALSE;
     3368        return FALSE;
    31903369    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
    3191     return FALSE;
     3370        return FALSE;
    31923371    if ((UINT)wParam >= infoPtr->uNumBands)
    3193     return FALSE;
     3372        return FALSE;
    31943373
    31953374    TRACE("index %u\n", (UINT)wParam);
     
    32013380    REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
    32023381    if (lprbbi->fMask & RBBIM_TEXT) {
    3203     if (lpBand->lpText) {
    3204         COMCTL32_Free (lpBand->lpText);
    3205         lpBand->lpText = NULL;
    3206     }
    3207     if (lprbbi->lpText) {
    3208         INT len = lstrlenW (lprbbi->lpText);
    3209         lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    3210         strcpyW (lpBand->lpText, lprbbi->lpText);
    3211     }
     3382        if (lpBand->lpText) {
     3383            COMCTL32_Free (lpBand->lpText);
     3384            lpBand->lpText = NULL;
     3385        }
     3386        if (lprbbi->lpText) {
     3387            INT len = lstrlenW (lprbbi->lpText);
     3388            lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     3389            strcpyW (lpBand->lpText, lprbbi->lpText);
     3390        }
    32123391    }
    32133392
     
    32163395    REBAR_DumpBand (infoPtr);
    32173396
    3218     if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE))
     3397    if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) {
    32193398      REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
     3399      InvalidateRect(infoPtr->hwndSelf, 0, 1);
     3400    }
    32203401
    32213402    return TRUE;
     
    32313412
    32323413    if (lpInfo == NULL)
    3233     return FALSE;
     3414        return FALSE;
    32343415
    32353416    if (lpInfo->cbSize < sizeof (REBARINFO))
    3236     return FALSE;
     3417        return FALSE;
    32373418
    32383419    TRACE("setting bar info!\n");
    32393420
    32403421    if (lpInfo->fMask & RBIM_IMAGELIST) {
    3241     infoPtr->himl = lpInfo->himl;
    3242     if (infoPtr->himl) {
     3422        infoPtr->himl = lpInfo->himl;
     3423        if (infoPtr->himl) {
    32433424            INT cx, cy;
    3244         ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
    3245         infoPtr->imageSize.cx = cx;
    3246         infoPtr->imageSize.cy = cy;
    3247     }
    3248     else {
    3249         infoPtr->imageSize.cx = 0;
    3250         infoPtr->imageSize.cy = 0;
    3251     }
    3252     TRACE("new image cx=%ld, cy=%ld\n", infoPtr->imageSize.cx,
    3253           infoPtr->imageSize.cy);
     3425            ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
     3426            infoPtr->imageSize.cx = cx;
     3427            infoPtr->imageSize.cy = cy;
     3428        }
     3429        else {
     3430            infoPtr->imageSize.cx = 0;
     3431            infoPtr->imageSize.cy = 0;
     3432        }
     3433        TRACE("new image cx=%ld, cy=%ld\n", infoPtr->imageSize.cx,
     3434              infoPtr->imageSize.cy);
    32543435    }
    32553436
     
    32573438    for (i=0; i<infoPtr->uNumBands; i++) {
    32583439        lpBand = &infoPtr->bands[i];
    3259     REBAR_ValidateBand (infoPtr, lpBand);
     3440        REBAR_ValidateBand (infoPtr, lpBand);
    32603441    }
    32613442
     
    33153496    BOOL bTemp = infoPtr->bUnicode;
    33163497
    3317     TRACE("to %s hwnd=0x%04x, was %s\n",
    3318       ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf,
    3319       (bTemp) ? "TRUE" : "FALSE");
     3498    TRACE("to %s hwnd=0x%04x, was %s\n", 
     3499          ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf,
     3500          (bTemp) ? "TRUE" : "FALSE");
    33203501
    33213502    infoPtr->bUnicode = (BOOL)wParam;
    3322 
     3503 
    33233504   return bTemp;
    33243505}
     
    33313512
    33323513    if (iVersion > COMCTL32_VERSION)
    3333     return -1;
     3514        return -1;
    33343515
    33353516    infoPtr->iVersion = iVersion;
     
    33473528
    33483529    if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
    3349     return FALSE;
     3530        return FALSE;
    33503531
    33513532    lpBand = &infoPtr->bands[(INT)wParam];
    33523533
    33533534    if ((BOOL)lParam) {
    3354     TRACE("show band %d\n", (INT)wParam);
    3355     lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
    3356     if (IsWindow (lpBand->hwndChild))
    3357         ShowWindow (lpBand->hwndChild, SW_SHOW);
     3535        TRACE("show band %d\n", (INT)wParam);
     3536        lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
     3537        if (IsWindow (lpBand->hwndChild))
     3538            ShowWindow (lpBand->hwndChild, SW_SHOW);
    33583539    }
    33593540    else {
    3360     TRACE("hide band %d\n", (INT)wParam);
    3361     lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
    3362     if (IsWindow (lpBand->hwndChild))
    3363         ShowWindow (lpBand->hwndChild, SW_HIDE);
     3541        TRACE("hide band %d\n", (INT)wParam);
     3542        lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
     3543        if (IsWindow (lpBand->hwndChild))
     3544            ShowWindow (lpBand->hwndChild, SW_HIDE);
    33643545    }
    33653546
    33663547    REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
     3548    InvalidateRect(infoPtr->hwndSelf, 0, 1);
    33673549
    33683550    return TRUE;
     
    33803562
    33813563    TRACE("[%d %d %d %d]\n",
    3382       lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
     3564          lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
    33833565
    33843566    /*  what is going on???? */
    33853567    GetWindowRect(infoPtr->hwndSelf, &t1);
    33863568    TRACE("window rect [%d %d %d %d]\n",
    3387       t1.left, t1.top, t1.right, t1.bottom);
     3569          t1.left, t1.top, t1.right, t1.bottom);
    33883570    GetClientRect(infoPtr->hwndSelf, &t1);
    33893571    TRACE("client rect [%d %d %d %d]\n",
    3390       t1.left, t1.top, t1.right, t1.bottom);
     3572          t1.left, t1.top, t1.right, t1.bottom);
    33913573
    33923574    /* force full _Layout processing */
     
    34073589
    34083590    if (TRACE_ON(rebar)) {
    3409     GetWindowRect(infoPtr->hwndSelf, &wnrc1);
    3410     GetClientRect(infoPtr->hwndSelf, &clrc1);
    3411     TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
    3412           wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
    3413           clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
    3414           cs->x, cs->y, cs->cx, cs->cy);
     3591        GetWindowRect(infoPtr->hwndSelf, &wnrc1);
     3592        GetClientRect(infoPtr->hwndSelf, &clrc1);
     3593        TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
     3594              wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
     3595              clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
     3596              cs->x, cs->y, cs->cx, cs->cy);
    34153597    }
    34163598
     
    34293611    /* free rebar bands */
    34303612    if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
    3431     /* clean up each band */
    3432     for (i = 0; i < infoPtr->uNumBands; i++) {
    3433         lpBand = &infoPtr->bands[i];
    3434 
    3435         /* delete text strings */
    3436         if (lpBand->lpText) {
    3437         COMCTL32_Free (lpBand->lpText);
    3438         lpBand->lpText = NULL;
    3439         }
    3440         /* destroy child window */
    3441         DestroyWindow (lpBand->hwndChild);
    3442     }
    3443 
    3444     /* free band array */
    3445     COMCTL32_Free (infoPtr->bands);
    3446     infoPtr->bands = NULL;
     3613        /* clean up each band */
     3614        for (i = 0; i < infoPtr->uNumBands; i++) {
     3615            lpBand = &infoPtr->bands[i];
     3616
     3617            /* delete text strings */
     3618            if (lpBand->lpText) {
     3619                COMCTL32_Free (lpBand->lpText);
     3620                lpBand->lpText = NULL;
     3621            }
     3622            /* destroy child window */
     3623            DestroyWindow (lpBand->hwndChild);
     3624        }
     3625
     3626        /* free band array */
     3627        COMCTL32_Free (infoPtr->bands);
     3628        infoPtr->bands = NULL;
    34473629    }
    34483630
     
    34513633    DeleteObject (infoPtr->hcurVert);
    34523634    DeleteObject (infoPtr->hcurDrag);
     3635    DeleteObject (infoPtr->hFont);
    34533636    SetWindowLongA (infoPtr->hwndSelf, 0, 0);
    34543637
     
    35233706    if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
    35243707        REBAR_Notify((NMHDR *) &layout, infoPtr, RBN_LAYOUTCHANGED);
    3525     REBAR_Notify_NMREBAR (infoPtr, ihitBand, RBN_ENDDRAG);
    3526     infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
     3708        REBAR_Notify_NMREBAR (infoPtr, ihitBand, RBN_ENDDRAG);
     3709        infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
    35273710    }
    35283711
     
    35483731    /* if mouse did not move much, exit */
    35493732    if ((abs(ptsmove.x - infoPtr->dragNow.x) <= mindragx) &&
    3550     (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
     3733        (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
    35513734
    35523735    band1 = &infoPtr->bands[infoPtr->ihitBand-1];
     
    35553738    /* Test for valid drag case - must not be first band in row */
    35563739    if (infoPtr->dwStyle & CCS_VERT) {
    3557     if ((ptsmove.x < band2->rcBand.left) ||
    3558         (ptsmove.x > band2->rcBand.right) ||
    3559         ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
    3560         FIXME("Cannot drag to other rows yet!!\n");
     3740        if ((ptsmove.x < band2->rcBand.left) ||
     3741            (ptsmove.x > band2->rcBand.right) ||
     3742            ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
     3743            FIXME("Cannot drag to other rows yet!!\n");
     3744        }
     3745        else {
     3746            REBAR_HandleLRDrag (infoPtr, &ptsmove);
     3747        }
    35613748    }
    35623749    else {
    3563         REBAR_HandleLRDrag (infoPtr, &ptsmove);
    3564     }
    3565     }
    3566     else {
    3567     if ((ptsmove.y < band2->rcBand.top) ||
    3568         (ptsmove.y > band2->rcBand.bottom) ||
    3569         ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
    3570         FIXME("Cannot drag to other rows yet!!\n");
    3571     }
    3572     else {
    3573         REBAR_HandleLRDrag (infoPtr, &ptsmove);
    3574     }
     3750        if ((ptsmove.y < band2->rcBand.top) ||
     3751            (ptsmove.y > band2->rcBand.bottom) ||
     3752            ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
     3753            FIXME("Cannot drag to other rows yet!!\n");
     3754        }
     3755        else {
     3756            REBAR_HandleLRDrag (infoPtr, &ptsmove);
     3757        }
    35753758    }
    35763759    return 0;
     
    35813764REBAR_NCCalcSize (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
    35823765{
    3583     ((LPRECT)lParam)->top    += GetSystemMetrics(SM_CYEDGE);
    3584     ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE);
    3585 
    3586     /* While the code below seems to be the reasonable way of   */
    3587     /*  handling the WS_BORDER style, the native version (as    */
    3588     /*  of 4.71 seems to only do the above. Go figure!!         */
    3589 #if 0
    3590     if (GetWindowLongA (infoPtr->hwndSelf, GWL_STYLE) & WS_BORDER) {
    3591     ((LPRECT)lParam)->left   += GetSystemMetrics(SM_CXEDGE);
    3592     ((LPRECT)lParam)->top    += GetSystemMetrics(SM_CYEDGE);
    3593     ((LPRECT)lParam)->right  -= GetSystemMetrics(SM_CXEDGE);
    3594     ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE);
    3595     }
    3596 #endif
    3597 
     3766    if (infoPtr->dwStyle & WS_BORDER) {
     3767        InflateRect((LPRECT)lParam, -GetSystemMetrics(SM_CXEDGE),
     3768                    -GetSystemMetrics(SM_CYEDGE));
     3769    }
     3770    TRACE("new client=(%d,%d)-(%d,%d)\n",
     3771          ((LPRECT)lParam)->left, ((LPRECT)lParam)->top,
     3772          ((LPRECT)lParam)->right, ((LPRECT)lParam)->bottom);
    35983773    return 0;
    35993774}
     
    36063781    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    36073782    RECT wnrc1, clrc1;
     3783    NONCLIENTMETRICSA ncm;
     3784    HFONT tfont;
    36083785    INT i;
    36093786
    36103787    if (infoPtr != NULL) {
    3611     ERR("Strange info structure pointer *not* NULL\n");
    3612     return FALSE;
     3788        ERR("Strange info structure pointer *not* NULL\n");
     3789        return FALSE;
    36133790    }
    36143791
    36153792    if (TRACE_ON(rebar)) {
    3616     GetWindowRect(hwnd, &wnrc1);
    3617     GetClientRect(hwnd, &clrc1);
    3618     TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
    3619           wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
    3620           clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
    3621           cs->x, cs->y, cs->cx, cs->cy);
     3793        GetWindowRect(hwnd, &wnrc1);
     3794        GetClientRect(hwnd, &clrc1);
     3795        TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
     3796              wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
     3797              clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
     3798              cs->x, cs->y, cs->cx, cs->cy);
    36223799    }
    36233800
     
    36443821    infoPtr->bUnicode = IsWindowUnicode (hwnd);
    36453822    infoPtr->fStatus = CREATE_RUNNING;
     3823    infoPtr->hFont = GetStockObject (SYSTEM_FONT);
    36463824
    36473825    /* issue WM_NOTIFYFORMAT to get unicode status of parent */
    36483826    i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
    3649              WM_NOTIFYFORMAT, hwnd, NF_QUERY);
     3827                     WM_NOTIFYFORMAT, hwnd, NF_QUERY);
    36503828    if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
    3651     ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
    3652         i);
    3653     i = NFR_ANSI;
     3829        ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     3830            i);
     3831        i = NFR_ANSI;
    36543832    }
    36553833    infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
     
    36593837    SetWindowLongA (hwnd, GWL_STYLE, infoPtr->dwStyle);
    36603838
     3839    /* get font handle for Caption Font */
     3840    ncm.cbSize = sizeof(NONCLIENTMETRICSA);
     3841    SystemParametersInfoA (SPI_GETNONCLIENTMETRICS,
     3842                          ncm.cbSize, &ncm, 0);
     3843    /* if the font is bold, set to normal */
     3844    if (ncm.lfCaptionFont.lfWeight > FW_NORMAL) {
     3845        ncm.lfCaptionFont.lfWeight = FW_NORMAL;
     3846    }
     3847    tfont = CreateFontIndirectA (&ncm.lfCaptionFont);
     3848    if (tfont) {
     3849        infoPtr->hFont = tfont;
     3850    }
     3851
    36613852/* native does:
    3662         GetSysColor (numerous);
    3663         GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
    3664         GetStockObject (SYSTEM_FONT);
    3665        *SetWindowLong (hwnd, 0, info ptr);
    3666        *WM_NOTIFYFORMAT;
    3667        *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
     3853            GetSysColor (numerous);
     3854            GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
     3855           *GetStockObject (SYSTEM_FONT);
     3856           *SetWindowLong (hwnd, 0, info ptr);
     3857           *WM_NOTIFYFORMAT;
     3858           *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
    36683859                                    WS_VISIBLE = 0x10000000;
    36693860                                    CCS_TOP    = 0x00000001;
    3670         SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
    3671         CreateFontIndirect (lfCaptionFont from above);
    3672         GetDC ();
    3673         SelectObject (hdc, fontabove);
    3674         GetTextMetrics (hdc, );    guessing is tmHeight
    3675         SelectObject (hdc, oldfont);
    3676         ReleaseDC ();
    3677         GetWindowRect ();
    3678         MapWindowPoints (0, parent, rectabove, 2);
    3679         GetWindowRect ();
    3680         GetClientRect ();
    3681         ClientToScreen (clientrect);
    3682         SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
     3861           *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
     3862           *CreateFontIndirect (lfCaptionFont from above);
     3863            GetDC ();
     3864            SelectObject (hdc, fontabove);
     3865            GetTextMetrics (hdc, );    guessing is tmHeight
     3866            SelectObject (hdc, oldfont);
     3867            ReleaseDC ();
     3868            GetWindowRect ();
     3869            MapWindowPoints (0, parent, rectabove, 2);
     3870            GetWindowRect ();
     3871            GetClientRect ();
     3872            ClientToScreen (clientrect);
     3873            SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
    36833874 */
    36843875    return TRUE;
     
    37083899    clpt = pt;
    37093900    ScreenToClient (infoPtr->hwndSelf, &clpt);
    3710     REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
    3711                (INT *)&nmmouse.dwItemSpec);
     3901    REBAR_InternalHitTest (infoPtr, &clpt, &scrap, 
     3902                           (INT *)&nmmouse.dwItemSpec);
    37123903    nmmouse.dwItemData = 0;
    37133904    nmmouse.pt = clpt;
    37143905    nmmouse.dwHitInfo = 0;
    37153906    if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) {
    3716     TRACE("notify changed return value from %ld to %d\n",
    3717           ret, i);
    3718     ret = (LRESULT) i;
     3907        TRACE("notify changed return value from %ld to %d\n",
     3908              ret, i);
     3909        ret = (LRESULT) i;
    37193910    }
    37203911    TRACE("returning %ld, client point (%ld,%ld)\n", ret, clpt.x, clpt.y);
     
    37303921
    37313922    if (infoPtr->dwStyle & WS_MINIMIZE)
    3732     return 0; /* Nothing to do */
    3733 
    3734     DefWindowProcA (infoPtr->hwndSelf, WM_NCPAINT, wParam, lParam);
    3735 
    3736     if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
    3737     return 0;
     3923        return 0; /* Nothing to do */
    37383924
    37393925    if (infoPtr->dwStyle & WS_BORDER) {
    3740     GetWindowRect (infoPtr->hwndSelf, &rcWindow);
    3741     OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
    3742     TRACE("rect (%d,%d)-(%d,%d)\n",
    3743           rcWindow.left, rcWindow.top,
    3744           rcWindow.right, rcWindow.bottom);
    3745     /* see comments in _NCCalcSize for reason this is not done */
    3746     /* DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT); */
    3747     DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP | BF_BOTTOM);
    3748     }
    3749 
    3750     ReleaseDC( infoPtr->hwndSelf, hdc );
     3926
     3927        /* adjust rectangle and draw the necessary edge */
     3928        if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
     3929            return 0;
     3930        GetWindowRect (infoPtr->hwndSelf, &rcWindow);
     3931        OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
     3932        TRACE("rect (%d,%d)-(%d,%d)\n",
     3933              rcWindow.left, rcWindow.top,
     3934              rcWindow.right, rcWindow.bottom);
     3935        DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
     3936        ReleaseDC( infoPtr->hwndSelf, hdc );
     3937    }
    37513938
    37523939    return 0;
     
    37603947
    37613948    if (lParam == NF_REQUERY) {
    3762     i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
    3763             WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
    3764     if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
    3765         ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
    3766         i);
    3767         i = NFR_ANSI;
    3768     }
    3769     infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
    3770     return (LRESULT)i;
     3949        i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
     3950                        WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
     3951        if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
     3952            ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     3953                i);
     3954            i = NFR_ANSI;
     3955        }
     3956        infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
     3957        return (LRESULT)i;
    37713958    }
    37723959    return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
     
    37853972
    37863973    TRACE("painting (%d,%d)-(%d,%d) client (%d,%d)-(%d,%d)\n",
    3787       ps.rcPaint.left, ps.rcPaint.top,
    3788       ps.rcPaint.right, ps.rcPaint.bottom,
    3789       rc.left, rc.top, rc.right, rc.bottom);
     3974          ps.rcPaint.left, ps.rcPaint.top,
     3975          ps.rcPaint.right, ps.rcPaint.bottom,
     3976          rc.left, rc.top, rc.right, rc.bottom);
    37903977
    37913978    if (ps.fErase) {
    3792     /* Erase area of paint if requested */
     3979        /* Erase area of paint if requested */
    37933980        REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint);
    37943981    }
     
    37963983    REBAR_Refresh (infoPtr, hdc);
    37973984    if (!wParam)
    3798     EndPaint (infoPtr->hwndSelf, &ps);
     3985        EndPaint (infoPtr->hwndSelf, &ps);
    37993986    return 0;
    38003987}
     
    38154002
    38164003    if (flags == RBHT_GRABBER) {
    3817     if ((infoPtr->dwStyle & CCS_VERT) &&
    3818         !(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
    3819         SetCursor (infoPtr->hcurVert);
    3820     else
    3821         SetCursor (infoPtr->hcurHorz);
     4004        if ((infoPtr->dwStyle & CCS_VERT) &&
     4005            !(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
     4006            SetCursor (infoPtr->hcurVert);
     4007        else
     4008            SetCursor (infoPtr->hcurHorz);
    38224009    }
    38234010    else if (flags != RBHT_CLIENT)
    3824     SetCursor (infoPtr->hcurArrow);
     4011        SetCursor (infoPtr->hcurArrow);
    38254012
    38264013    return 0;
     
    38404027    for (i=0; i<infoPtr->uNumBands; i++) {
    38414028        lpBand = &infoPtr->bands[i];
    3842     REBAR_ValidateBand (infoPtr, lpBand);
     4029        REBAR_ValidateBand (infoPtr, lpBand);
    38434030    }
    38444031
     
    38614048      *
    38624049      * Documentation:
    3863       *  According to testing V4.71 of COMCTL32 returns the
     4050      *  According to testing V4.71 of COMCTL32 returns the 
    38644051      *  *previous* status of the redraw flag (either 0 or -1)
    38654052      *  instead of the MSDN documented value of 0 if handled
     
    38694056    BOOL oldredraw = infoPtr->DoRedraw;
    38704057
    3871     TRACE("set to %s, fStatus=%08x\n",
    3872       (wParam) ? "TRUE" : "FALSE", infoPtr->fStatus);
     4058    TRACE("set to %s, fStatus=%08x\n", 
     4059          (wParam) ? "TRUE" : "FALSE", infoPtr->fStatus);
    38734060    infoPtr->DoRedraw = (BOOL) wParam;
    38744061    if (wParam) {
    3875     if (infoPtr->fStatus & BAND_NEEDS_REDRAW) {
    3876         REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
    3877         REBAR_ForceResize (infoPtr);
    3878         InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
    3879     }
    3880     infoPtr->fStatus &= ~BAND_NEEDS_REDRAW;
     4062        if (infoPtr->fStatus & BAND_NEEDS_REDRAW) {
     4063            REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
     4064            REBAR_ForceResize (infoPtr);
     4065            InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
     4066        }
     4067        infoPtr->fStatus &= ~BAND_NEEDS_REDRAW;
    38814068    }
    38824069    return (oldredraw) ? -1 : 0;
     
    38914078    /* auto resize deadlock check */
    38924079    if (infoPtr->fStatus & AUTO_RESIZE) {
    3893     infoPtr->fStatus &= ~AUTO_RESIZE;
    3894     TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
    3895           infoPtr->fStatus, lParam);
    3896     return 0;
     4080        infoPtr->fStatus &= ~AUTO_RESIZE;
     4081        TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
     4082              infoPtr->fStatus, lParam);
     4083        return 0;
    38974084    }
    38984085
    38994086    if (infoPtr->fStatus & CREATE_RUNNING) {
    3900     /* still in CreateWindow */
    3901     RECT rcWin;
    3902 
    3903     TRACE("still in CreateWindow\n");
    3904     infoPtr->fStatus &= ~CREATE_RUNNING;
    3905     GetWindowRect ( infoPtr->hwndSelf, &rcWin);
    3906     TRACE("win rect (%d,%d)-(%d,%d)\n",
    3907           rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
    3908 
    3909     if ((lParam == 0) && (rcWin.right-rcWin.left == 0) &&
    3910         (rcWin.bottom-rcWin.top == 0)) {
    3911         /* native control seems to do this */
    3912         GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
    3913         TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n",
    3914           rcClient.right, rcClient.bottom);
     4087        /* still in CreateWindow */
     4088        RECT rcWin;
     4089
     4090        if ((INT)wParam != SIZE_RESTORED) {
     4091            ERR("WM_SIZE in create and flags=%08x, lParam=%08lx\n",
     4092                wParam, lParam);
     4093        }
     4094
     4095        TRACE("still in CreateWindow\n");
     4096        infoPtr->fStatus &= ~CREATE_RUNNING;
     4097        GetWindowRect ( infoPtr->hwndSelf, &rcWin);
     4098        TRACE("win rect (%d,%d)-(%d,%d)\n",
     4099              rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
     4100
     4101        if ((lParam == 0) && (rcWin.right-rcWin.left == 0) &&
     4102            (rcWin.bottom-rcWin.top == 0)) {
     4103            /* native control seems to do this */
     4104            GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
     4105            TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n",
     4106                  rcClient.right, rcClient.bottom);
     4107        }
     4108        else {
     4109            INT cx, cy;
     4110
     4111            cx = rcWin.right - rcWin.left;
     4112            cy = rcWin.bottom - rcWin.top;
     4113            if ((cx == LOWORD(lParam)) && (cy == HIWORD(lParam))) {
     4114                return 0;
     4115            }
     4116
     4117            /* do the actual WM_SIZE request */
     4118            GetClientRect (infoPtr->hwndSelf, &rcClient);
     4119            TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
     4120                  infoPtr->calcSize.cx, infoPtr->calcSize.cy,
     4121                  LOWORD(lParam), HIWORD(lParam),
     4122                  rcClient.right, rcClient.bottom);
     4123        }
    39154124    }
    39164125    else {
    3917         INT cx, cy;
    3918 
    3919         cx = rcWin.right - rcWin.left;
    3920         cy = rcWin.bottom - rcWin.top;
    3921         if ((cx == LOWORD(lParam)) && (cy == HIWORD(lParam))) {
    3922         return 0;
    3923         }
    3924 
    3925         /* do the actual WM_SIZE request */
    3926         GetClientRect (infoPtr->hwndSelf, &rcClient);
    3927         TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
    3928           infoPtr->calcSize.cx, infoPtr->calcSize.cy,
    3929           LOWORD(lParam), HIWORD(lParam),
    3930           rcClient.right, rcClient.bottom);
    3931     }
    3932     }
    3933     else {
    3934     /* Handle cases when outside of the CreateWindow process */
    3935 
    3936     GetClientRect (infoPtr->hwndSelf, &rcClient);
    3937     if ((lParam == 0) && (rcClient.right + rcClient.bottom != 0) &&
    3938         (infoPtr->dwStyle & RBS_AUTOSIZE)) {
    3939         /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
    3940         /* native seems to use the current client rect for the size      */
    3941         infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
    3942         TRACE("sizing rebar to client (%d,%d) size is zero but AUTOSIZE set\n",
    3943           rcClient.right, rcClient.bottom);
    3944     }
    3945     else {
    3946         TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
    3947           infoPtr->calcSize.cx, infoPtr->calcSize.cy,
    3948           LOWORD(lParam), HIWORD(lParam),
    3949           rcClient.right, rcClient.bottom);
    3950     }
     4126        if ((INT)wParam != SIZE_RESTORED) {
     4127            ERR("WM_SIZE out of create and flags=%08x, lParam=%08lx\n",
     4128                wParam, lParam);
     4129        }
     4130
     4131        /* Handle cases when outside of the CreateWindow process */
     4132
     4133        GetClientRect (infoPtr->hwndSelf, &rcClient);
     4134        if ((lParam == 0) && (rcClient.right + rcClient.bottom != 0) &&
     4135            (infoPtr->dwStyle & RBS_AUTOSIZE)) {
     4136            /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
     4137            /* native seems to use the current client rect for the size      */
     4138            infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
     4139            TRACE("sizing rebar to client (%d,%d) size is zero but AUTOSIZE set\n",
     4140                  rcClient.right, rcClient.bottom);
     4141        }
     4142        else {
     4143            TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
     4144                  infoPtr->calcSize.cx, infoPtr->calcSize.cy,
     4145                  LOWORD(lParam), HIWORD(lParam),
     4146                  rcClient.right, rcClient.bottom);
     4147        }
    39514148    }
    39524149
    39534150    if (infoPtr->dwStyle & RBS_AUTOSIZE) {
    3954     NMRBAUTOSIZE autosize;
    3955 
    3956     GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget);
    3957     autosize.fChanged = 0;  /* ??? */
    3958     autosize.rcActual = autosize.rcTarget;  /* ??? */
    3959     REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
    3960     TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n",
    3961           autosize.rcTarget.right, autosize.rcTarget.bottom, lParam);
     4151        NMRBAUTOSIZE autosize;
     4152
     4153        GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget);
     4154        autosize.fChanged = 0;  /* ??? */
     4155        autosize.rcActual = autosize.rcTarget;  /* ??? */
     4156        REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
     4157        TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n",
     4158              autosize.rcTarget.right, autosize.rcTarget.bottom, lParam);
    39624159    }
    39634160
    39644161    if ((infoPtr->calcSize.cx != rcClient.right) ||
    3965     (infoPtr->calcSize.cy != rcClient.bottom))
    3966     infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
     4162        (infoPtr->calcSize.cy != rcClient.bottom))
     4163        infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
    39674164
    39684165    REBAR_Layout (infoPtr, &rcClient, TRUE, TRUE);
     
    39794176
    39804177    TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n",
    3981       infoPtr->dwStyle, ss->styleOld, ss->styleNew);
     4178          infoPtr->dwStyle, ss->styleOld, ss->styleNew);
    39824179    infoPtr->dwStyle = ss->styleNew;
    39834180
     
    39914188    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    39924189
    3993     TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
    3994       hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
     4190    TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", 
     4191          hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
    39954192    if (!infoPtr && (uMsg != WM_NCCREATE))
    3996         return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     4193            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    39974194    switch (uMsg)
    39984195    {
    3999 /*  case RB_BEGINDRAG: */
    4000 
    4001     case RB_DELETEBAND:
    4002         return REBAR_DeleteBand (infoPtr, wParam, lParam);
    4003 
    4004 /*  case RB_DRAGMOVE: */
    4005 /*  case RB_ENDDRAG: */
    4006 
    4007     case RB_GETBANDBORDERS:
    4008         return REBAR_GetBandBorders (infoPtr, wParam, lParam);
    4009 
    4010     case RB_GETBANDCOUNT:
    4011         return REBAR_GetBandCount (infoPtr);
    4012 
    4013     case RB_GETBANDINFO:    /* obsoleted after IE3, but we have to
    4014                    support it anyway. */
    4015     case RB_GETBANDINFOA:
    4016         return REBAR_GetBandInfoA (infoPtr, wParam, lParam);
    4017 
    4018     case RB_GETBANDINFOW:
    4019         return REBAR_GetBandInfoW (infoPtr, wParam, lParam);
    4020 
    4021     case RB_GETBARHEIGHT:
    4022         return REBAR_GetBarHeight (infoPtr, wParam, lParam);
    4023 
    4024     case RB_GETBARINFO:
    4025         return REBAR_GetBarInfo (infoPtr, wParam, lParam);
    4026 
    4027     case RB_GETBKCOLOR:
    4028         return REBAR_GetBkColor (infoPtr);
    4029 
    4030 /*  case RB_GETCOLORSCHEME: */
    4031 /*  case RB_GETDROPTARGET: */
    4032 
    4033     case RB_GETPALETTE:
    4034         return REBAR_GetPalette (infoPtr, wParam, lParam);
    4035 
    4036     case RB_GETRECT:
    4037         return REBAR_GetRect (infoPtr, wParam, lParam);
    4038 
    4039     case RB_GETROWCOUNT:
    4040         return REBAR_GetRowCount (infoPtr);
    4041 
    4042     case RB_GETROWHEIGHT:
    4043         return REBAR_GetRowHeight (infoPtr, wParam, lParam);
    4044 
    4045     case RB_GETTEXTCOLOR:
    4046         return REBAR_GetTextColor (infoPtr);
    4047 
    4048     case RB_GETTOOLTIPS:
    4049         return REBAR_GetToolTips (infoPtr);
    4050 
    4051     case RB_GETUNICODEFORMAT:
    4052         return REBAR_GetUnicodeFormat (infoPtr);
    4053 
    4054     case CCM_GETVERSION:
    4055         return REBAR_GetVersion (infoPtr);
    4056 
    4057     case RB_HITTEST:
    4058         return REBAR_HitTest (infoPtr, wParam, lParam);
    4059 
    4060     case RB_IDTOINDEX:
    4061         return REBAR_IdToIndex (infoPtr, wParam, lParam);
    4062 
    4063     case RB_INSERTBANDA:
    4064         return REBAR_InsertBandA (infoPtr, wParam, lParam);
    4065 
    4066     case RB_INSERTBANDW:
    4067         return REBAR_InsertBandW (infoPtr, wParam, lParam);
    4068 
    4069     case RB_MAXIMIZEBAND:
    4070         return REBAR_MaximizeBand (infoPtr, wParam, lParam);
    4071 
    4072     case RB_MINIMIZEBAND:
    4073         return REBAR_MinimizeBand (infoPtr, wParam, lParam);
    4074 
    4075     case RB_MOVEBAND:
    4076         return REBAR_MoveBand (infoPtr, wParam, lParam);
    4077 
    4078     case RB_SETBANDINFOA:
    4079         return REBAR_SetBandInfoA (infoPtr, wParam, lParam);
    4080 
    4081     case RB_SETBANDINFOW:
    4082         return REBAR_SetBandInfoW (infoPtr, wParam, lParam);
    4083 
    4084     case RB_SETBARINFO:
    4085         return REBAR_SetBarInfo (infoPtr, wParam, lParam);
    4086 
    4087     case RB_SETBKCOLOR:
    4088         return REBAR_SetBkColor (infoPtr, wParam, lParam);
    4089 
    4090 /*  case RB_SETCOLORSCHEME: */
    4091 /*  case RB_SETPALETTE: */
    4092 /*      return REBAR_GetPalette (infoPtr, wParam, lParam); */
    4093 
    4094     case RB_SETPARENT:
    4095         return REBAR_SetParent (infoPtr, wParam, lParam);
    4096 
    4097     case RB_SETTEXTCOLOR:
    4098         return REBAR_SetTextColor (infoPtr, wParam, lParam);
    4099 
    4100 /*  case RB_SETTOOLTIPS: */
    4101 
    4102     case RB_SETUNICODEFORMAT:
    4103         return REBAR_SetUnicodeFormat (infoPtr, wParam);
    4104 
    4105     case CCM_SETVERSION:
    4106         return REBAR_SetVersion (infoPtr, (INT)wParam);
    4107 
    4108     case RB_SHOWBAND:
    4109         return REBAR_ShowBand (infoPtr, wParam, lParam);
    4110 
    4111     case RB_SIZETORECT:
    4112         return REBAR_SizeToRect (infoPtr, wParam, lParam);
     4196/*      case RB_BEGINDRAG: */
     4197
     4198        case RB_DELETEBAND:
     4199            return REBAR_DeleteBand (infoPtr, wParam, lParam);
     4200
     4201/*      case RB_DRAGMOVE: */
     4202/*      case RB_ENDDRAG: */
     4203
     4204        case RB_GETBANDBORDERS:
     4205            return REBAR_GetBandBorders (infoPtr, wParam, lParam);
     4206
     4207        case RB_GETBANDCOUNT:
     4208            return REBAR_GetBandCount (infoPtr);
     4209
     4210        case RB_GETBANDINFO:    /* obsoleted after IE3, but we have to
     4211                                   support it anyway. */
     4212        case RB_GETBANDINFOA:
     4213            return REBAR_GetBandInfoA (infoPtr, wParam, lParam);
     4214
     4215        case RB_GETBANDINFOW:
     4216            return REBAR_GetBandInfoW (infoPtr, wParam, lParam);
     4217
     4218        case RB_GETBARHEIGHT:
     4219            return REBAR_GetBarHeight (infoPtr, wParam, lParam);
     4220
     4221        case RB_GETBARINFO:
     4222            return REBAR_GetBarInfo (infoPtr, wParam, lParam);
     4223
     4224        case RB_GETBKCOLOR:
     4225            return REBAR_GetBkColor (infoPtr);
     4226
     4227/*      case RB_GETCOLORSCHEME: */
     4228/*      case RB_GETDROPTARGET: */
     4229
     4230        case RB_GETPALETTE:
     4231            return REBAR_GetPalette (infoPtr, wParam, lParam);
     4232
     4233        case RB_GETRECT:
     4234            return REBAR_GetRect (infoPtr, wParam, lParam);
     4235
     4236        case RB_GETROWCOUNT:
     4237            return REBAR_GetRowCount (infoPtr);
     4238
     4239        case RB_GETROWHEIGHT:
     4240            return REBAR_GetRowHeight (infoPtr, wParam, lParam);
     4241
     4242        case RB_GETTEXTCOLOR:
     4243            return REBAR_GetTextColor (infoPtr);
     4244
     4245        case RB_GETTOOLTIPS:
     4246            return REBAR_GetToolTips (infoPtr);
     4247
     4248        case RB_GETUNICODEFORMAT:
     4249            return REBAR_GetUnicodeFormat (infoPtr);
     4250
     4251        case CCM_GETVERSION:
     4252            return REBAR_GetVersion (infoPtr);
     4253
     4254        case RB_HITTEST:
     4255            return REBAR_HitTest (infoPtr, wParam, lParam);
     4256
     4257        case RB_IDTOINDEX:
     4258            return REBAR_IdToIndex (infoPtr, wParam, lParam);
     4259
     4260        case RB_INSERTBANDA:
     4261            return REBAR_InsertBandA (infoPtr, wParam, lParam);
     4262
     4263        case RB_INSERTBANDW:
     4264            return REBAR_InsertBandW (infoPtr, wParam, lParam);
     4265
     4266        case RB_MAXIMIZEBAND:
     4267            return REBAR_MaximizeBand (infoPtr, wParam, lParam);
     4268
     4269        case RB_MINIMIZEBAND:
     4270            return REBAR_MinimizeBand (infoPtr, wParam, lParam);
     4271
     4272        case RB_MOVEBAND:
     4273            return REBAR_MoveBand (infoPtr, wParam, lParam);
     4274
     4275        case RB_SETBANDINFOA:
     4276            return REBAR_SetBandInfoA (infoPtr, wParam, lParam);
     4277
     4278        case RB_SETBANDINFOW:
     4279            return REBAR_SetBandInfoW (infoPtr, wParam, lParam);
     4280
     4281        case RB_SETBARINFO:
     4282            return REBAR_SetBarInfo (infoPtr, wParam, lParam);
     4283
     4284        case RB_SETBKCOLOR:
     4285            return REBAR_SetBkColor (infoPtr, wParam, lParam);
     4286
     4287/*      case RB_SETCOLORSCHEME: */
     4288/*      case RB_SETPALETTE: */
     4289/*          return REBAR_GetPalette (infoPtr, wParam, lParam); */
     4290
     4291        case RB_SETPARENT:
     4292            return REBAR_SetParent (infoPtr, wParam, lParam);
     4293
     4294        case RB_SETTEXTCOLOR:
     4295            return REBAR_SetTextColor (infoPtr, wParam, lParam);
     4296
     4297/*      case RB_SETTOOLTIPS: */
     4298
     4299        case RB_SETUNICODEFORMAT:
     4300            return REBAR_SetUnicodeFormat (infoPtr, wParam);
     4301
     4302        case CCM_SETVERSION:
     4303            return REBAR_SetVersion (infoPtr, (INT)wParam);
     4304
     4305        case RB_SHOWBAND:
     4306            return REBAR_ShowBand (infoPtr, wParam, lParam);
     4307
     4308        case RB_SIZETORECT:
     4309            return REBAR_SizeToRect (infoPtr, wParam, lParam);
    41134310
    41144311
    41154312/*    Messages passed to parent */
    4116     case WM_COMMAND:
    4117     case WM_DRAWITEM:
    4118     case WM_NOTIFY:
    4119         if (infoPtr->NtfUnicode)
    4120         return SendMessageW (REBAR_GetNotifyParent (infoPtr),
    4121                      uMsg, wParam, lParam);
    4122         else
    4123         return SendMessageA (REBAR_GetNotifyParent (infoPtr),
    4124                      uMsg, wParam, lParam);
     4313        case WM_COMMAND:
     4314        case WM_DRAWITEM:
     4315        case WM_NOTIFY:
     4316            if (infoPtr->NtfUnicode)
     4317                return SendMessageW (REBAR_GetNotifyParent (infoPtr),
     4318                                     uMsg, wParam, lParam);
     4319            else
     4320                return SendMessageA (REBAR_GetNotifyParent (infoPtr),
     4321                                     uMsg, wParam, lParam);
    41254322
    41264323
    41274324/*      case WM_CHARTOITEM:     supported according to ControlSpy */
    41284325
    4129     case WM_CREATE:
    4130         return REBAR_Create (infoPtr, wParam, lParam);
    4131 
    4132     case WM_DESTROY:
    4133         return REBAR_Destroy (infoPtr, wParam, lParam);
     4326        case WM_CREATE:
     4327            return REBAR_Create (infoPtr, wParam, lParam);
     4328
     4329        case WM_DESTROY:
     4330            return REBAR_Destroy (infoPtr, wParam, lParam);
    41344331
    41354332        case WM_ERASEBKGND:
    4136         return REBAR_EraseBkGnd (infoPtr, wParam, lParam);
    4137 
    4138     case WM_GETFONT:
    4139         return REBAR_GetFont (infoPtr, wParam, lParam);
     4333            return REBAR_EraseBkGnd (infoPtr, wParam, lParam);
     4334
     4335        case WM_GETFONT:
     4336            return REBAR_GetFont (infoPtr, wParam, lParam);
    41404337
    41414338/*      case WM_LBUTTONDBLCLK:  supported according to ControlSpy */
    41424339
    4143     case WM_LBUTTONDOWN:
    4144         return REBAR_LButtonDown (infoPtr, wParam, lParam);
    4145 
    4146     case WM_LBUTTONUP:
    4147         return REBAR_LButtonUp (infoPtr, wParam, lParam);
     4340        case WM_LBUTTONDOWN:
     4341            return REBAR_LButtonDown (infoPtr, wParam, lParam);
     4342
     4343        case WM_LBUTTONUP:
     4344            return REBAR_LButtonUp (infoPtr, wParam, lParam);
    41484345
    41494346/*      case WM_MEASUREITEM:    supported according to ControlSpy */
    41504347
    4151     case WM_MOUSEMOVE:
    4152         return REBAR_MouseMove (infoPtr, wParam, lParam);
    4153 
    4154     case WM_NCCALCSIZE:
    4155         return REBAR_NCCalcSize (infoPtr, wParam, lParam);
     4348        case WM_MOUSEMOVE:
     4349            return REBAR_MouseMove (infoPtr, wParam, lParam);
     4350
     4351        case WM_NCCALCSIZE:
     4352            return REBAR_NCCalcSize (infoPtr, wParam, lParam);
    41564353
    41574354        case WM_NCCREATE:
    4158         return REBAR_NCCreate (hwnd, wParam, lParam);
     4355            return REBAR_NCCreate (hwnd, wParam, lParam);
    41594356
    41604357        case WM_NCHITTEST:
    4161         return REBAR_NCHitTest (infoPtr, wParam, lParam);
    4162 
    4163     case WM_NCPAINT:
    4164         return REBAR_NCPaint (infoPtr, wParam, lParam);
     4358            return REBAR_NCHitTest (infoPtr, wParam, lParam);
     4359
     4360        case WM_NCPAINT:
     4361            return REBAR_NCPaint (infoPtr, wParam, lParam);
    41654362
    41664363        case WM_NOTIFYFORMAT:
    4167         return REBAR_NotifyFormat (infoPtr, wParam, lParam);
    4168 
    4169     case WM_PAINT:
    4170         return REBAR_Paint (infoPtr, wParam, lParam);
     4364            return REBAR_NotifyFormat (infoPtr, wParam, lParam);
     4365
     4366        case WM_PAINT:
     4367            return REBAR_Paint (infoPtr, wParam, lParam);
    41714368
    41724369/*      case WM_PALETTECHANGED: supported according to ControlSpy */
     
    41764373/*      case WM_RBUTTONUP:      supported according to ControlSpy */
    41774374
    4178     case WM_SETCURSOR:
    4179         return REBAR_SetCursor (infoPtr, wParam, lParam);
    4180 
    4181     case WM_SETFONT:
    4182         return REBAR_SetFont (infoPtr, wParam, lParam);
     4375        case WM_SETCURSOR:
     4376            return REBAR_SetCursor (infoPtr, wParam, lParam);
     4377
     4378        case WM_SETFONT:
     4379            return REBAR_SetFont (infoPtr, wParam, lParam);
    41834380
    41844381        case WM_SETREDRAW:
    4185         return REBAR_SetRedraw (infoPtr, wParam, lParam);
    4186 
    4187     case WM_SIZE:
    4188         return REBAR_Size (infoPtr, wParam, lParam);
     4382            return REBAR_SetRedraw (infoPtr, wParam, lParam);
     4383
     4384        case WM_SIZE:
     4385            return REBAR_Size (infoPtr, wParam, lParam);
    41894386
    41904387        case WM_STYLECHANGED:
    4191         return REBAR_StyleChanged (infoPtr, wParam, lParam);
     4388            return REBAR_StyleChanged (infoPtr, wParam, lParam);
    41924389
    41934390/*      case WM_SYSCOLORCHANGE: supported according to ControlSpy */
    41944391/*      "Applications that have brushes using the existing system colors
    4195          should delete those brushes and recreate them using the new
     4392         should delete those brushes and recreate them using the new 
    41964393         system colors."  per MSDN                                */
    41974394
    41984395/*      case WM_VKEYTOITEM:     supported according to ControlSpy */
    4199 /*  case WM_WININICHANGE: */
    4200 
    4201     default:
    4202         if (uMsg >= WM_USER)
    4203         ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    4204              uMsg, wParam, lParam);
     4396/*      case WM_WININICHANGE: */
     4397
     4398        default:
     4399            if (uMsg >= WM_USER)
     4400                ERR("unknown msg %04x wp=%08x lp=%08lx\n",
     4401                     uMsg, wParam, lParam);
    42054402#ifdef __WIN32OS2__
    42064403            return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
    42074404#else
    4208         return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     4405            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    42094406#endif
    42104407    }
     
    42254422    wndClass.hCursor       = 0;
    42264423    wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
     4424#if GLATESTING
     4425    wndClass.hbrBackground = CreateSolidBrush(RGB(0,128,0));
     4426#endif
    42274427    wndClass.lpszClassName = REBARCLASSNAMEA;
    4228 
     4428 
    42294429    RegisterClassA (&wndClass);
    42304430
  • trunk/src/comctl32/status.c

    r6644 r6705  
    1 /* $Id: status.c,v 1.23 2001-09-05 12:05:02 bird Exp $ */
    21/*
    32 * Interface code to StatusWindow widget/control
  • trunk/src/comctl32/tab.c

    r6644 r6705  
    1 /* $Id: tab.c,v 1.21 2001-09-05 12:05:02 bird Exp $ */
    21/*
    32 * Tab control
  • trunk/src/comctl32/toolbar.c

    r6644 r6705  
    1 /* $Id: toolbar.c,v 1.29 2001-09-05 12:05:03 bird Exp $ */
    21/*
    32 * Toolbar control
     
    54 * Copyright 1998,1999 Eric Kohl
    65 * Copyright 2000 Eric Kohl for CodeWeavers
     6 *
     7 *  Differences between MSDN and actual native control operation:
     8 *   1. MSDN says: "TBSTYLE_LIST: Creates a flat toolbar with button text
     9 *                  to the right of the bitmap. Otherwise, this style is
     10 *                  identical to TBSTYLE_FLAT."
     11 *      As implemented by both v4.71 and v5.80 of the native COMCTL32.DLL
     12 *      you can create a TBSTYLE_LIST without TBSTYLE_FLAT and the result
     13 *      is non-flat non-transparent buttons. Therefore TBSTYLE_LIST does
     14 *      *not* imply TBSTYLE_FLAT as documented.  (GA 8/2001)
     15 *
    716 *
    817 * TODO:
     
    5160DEFAULT_DEBUG_CHANNEL(toolbar);
    5261
     62#ifdef __WIN32OS2__
     63#undef inline
     64#define inline
     65#define COMCTL32_hPattern55AABrush GetPattern55AABrush()
     66#endif
     67
    5368typedef struct
    5469{
     
    6378    INT nRow;
    6479    RECT rect;
    65 } TBUTTON_INFO;
    66 
    67 #ifdef __WIN32OS2__
    68 #define COMCTL32_hPattern55AABrush GetPattern55AABrush()
    69 #endif
     80} TBUTTON_INFO;
    7081
    7182typedef struct
     
    98109    HWND     hwndToolTip;     /* handle to tool tip control */
    99110    HWND     hwndNotify;      /* handle to the window that gets notifications */
     111    HWND     hwndSelf;        /* my own handle */
    100112    BOOL     bTransparent;    /* background transparency flag */
     113    BOOL     bBtnTranspnt;    /* button transparency flag */
    101114    BOOL     bAutoSize;       /* auto size deadlock indicator */
    102115    BOOL     bAnchor;         /* anchor highlight enabled */
     116    BOOL     bNtfUnicode;     /* TRUE if NOTIFYs use {W} */
    103117    DWORD      dwExStyle;       /* extended toolbar style */
    104118    DWORD      dwDTFlags;       /* DrawText flags */
     
    132146#define TOP_BORDER         2
    133147#define BOTTOM_BORDER      2
    134 #define DDARROW_WIDTH      11
     148#define DDARROW_WIDTH      11 
    135149
    136150#define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
    137151#define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
    138152#define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
     153
     154
     155static void
     156TOOLBAR_DumpButton(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *bP, INT btn_num, BOOL internal)
     157{
     158    if (TRACE_ON(toolbar)){
     159        TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, string=%d\n",
     160              btn_num, bP->idCommand,
     161              bP->iBitmap, bP->fsState, bP->fsStyle, bP->dwData, bP->iString);
     162        if (internal)
     163            TRACE("button %d id %d, hot=%s, row=%d, rect=(%d,%d)-(%d,%d)\n",
     164                  btn_num, bP->idCommand,
     165                  (bP->bHot) ? "TRUE":"FALSE", bP->nRow,
     166                  bP->rect.left, bP->rect.top,
     167                  bP->rect.right, bP->rect.bottom);
     168    }
     169}
     170
     171
     172static void
     173TOOLBAR_DumpToolbar(TOOLBAR_INFO *iP, INT line)
     174{
     175    if (TRACE_ON(toolbar)) {
     176        INT i;
     177        DWORD dwStyle;
     178
     179        dwStyle = GetWindowLongA (iP->hwndSelf, GWL_STYLE);
     180        TRACE("toolbar %08x at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n",
     181              iP->hwndSelf, line,
     182              iP->dwExStyle, iP->nNumButtons, iP->nNumBitmaps,
     183              iP->nNumStrings, dwStyle);
     184        TRACE("toolbar %08x at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p\n",
     185              iP->hwndSelf, line,
     186              iP->himlInt, iP->himlDef, iP->himlHot, iP->himlDis);
     187        for(i=0; i<iP->nNumButtons; i++) {
     188            TOOLBAR_DumpButton(iP, &iP->buttons[i], i, TRUE);
     189        }
     190    }
     191}
     192
     193
     194/***********************************************************************
     195*               TOOLBAR_CheckStyle
     196*
     197* This function validates that the styles set are implemented and
     198* issues FIXME's warning of possible problems. In a perfect world this
     199* function should be null.
     200*/
     201static void
     202TOOLBAR_CheckStyle (HWND hwnd, DWORD dwStyle)
     203{
     204    if (dwStyle & TBSTYLE_ALTDRAG)
     205        FIXME("[%04x] TBSTYLE_ALTDRAG not implemented\n", hwnd);
     206    if (dwStyle & TBSTYLE_REGISTERDROP)
     207        FIXME("[%04x] TBSTYLE_REGISTERDROP not implemented\n", hwnd);
     208}
     209
     210
     211static INT
     212TOOLBAR_SendNotify (NMHDR *nmhdr, TOOLBAR_INFO *infoPtr, UINT code)
     213{
     214    nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
     215    nmhdr->hwndFrom = infoPtr->hwndSelf;
     216    nmhdr->code = code;
     217
     218    TRACE("to window %04x, code=%08x, %s\n", infoPtr->hwndNotify, code,
     219          (infoPtr->bNtfUnicode) ? "via Unicode" : "via ANSI");
     220
     221    if (infoPtr->bNtfUnicode)
     222        return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
     223                             (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
     224    else
     225        return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
     226                             (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
     227}
    139228
    140229static LPWSTR
     
    148237    else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
    149238        lpText = infoPtr->strings[btnPtr->iString];
    150 
     239   
    151240    return lpText;
    152241}
    153242
    154 static BOOL
     243/***********************************************************************
     244*               TOOLBAR_GetBitmapIndex
     245*
     246* This function returns the bitmap index associated with a button.
     247* If the button specifies I_IMAGECALLBACK, then the TBN_GETDISPINFO
     248* is issued to retrieve the index.
     249*/
     250static INT
     251TOOLBAR_GetBitmapIndex(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
     252{
     253    INT ret = btnPtr->iBitmap;
     254
     255    if (ret == I_IMAGECALLBACK) {
     256        /* issue TBN_GETDISPINFO */
     257        NMTBDISPINFOA nmgd;
     258
     259        nmgd.idCommand = btnPtr->idCommand;
     260        nmgd.lParam = btnPtr->dwData;
     261        nmgd.dwMask = TBNF_IMAGE;
     262        TOOLBAR_SendNotify ((NMHDR *) &nmgd, infoPtr,
     263                        (infoPtr->bNtfUnicode) ? TBN_GETDISPINFOW :
     264                        TBN_GETDISPINFOA);
     265        if (nmgd.dwMask & TBNF_DI_SETITEM) {
     266            btnPtr->iBitmap = nmgd.iImage;
     267        }
     268        ret = nmgd.iImage;
     269        TRACE("TBN_GETDISPINFOA returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
     270              ret, nmgd.dwMask, infoPtr->nNumBitmaps);
     271    }
     272    return ret;
     273}
     274
     275
     276static BOOL
    155277TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO *infoPtr, INT index)
    156278{
    157     if ((index>=0) && (index < infoPtr->nNumBitmaps))
     279    if (((index>=0) && (index <= infoPtr->nNumBitmaps)) ||
     280        (index == I_IMAGECALLBACK))
    158281      return TRUE;
    159282    else
    160283      return FALSE;
     284}
     285
     286
     287/***********************************************************************
     288*               TOOLBAR_DrawImageList
     289*
     290* This function validates the bitmap index (including I_IMAGECALLBACK
     291* functionality). It then draws the image via the ImageList_Draw
     292* function. It returns TRUE if the image was drawn, FALSE otherwise.
     293*/
     294static BOOL
     295TOOLBAR_DrawImageList (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl,
     296                        HDC hdc, UINT left, UINT top, UINT draw_flags)
     297{
     298    INT index;
     299
     300    if (!himl) return FALSE;
     301
     302    if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
     303        ERR("index %d is not valid, max %d\n",
     304            btnPtr->iBitmap, infoPtr->nNumBitmaps);
     305        return FALSE;
     306    }
     307
     308    if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
     309        if (index == -1) return FALSE;
     310        ERR("TBN_GETDISPINFO returned invalid index %d\n",
     311            index);
     312        return FALSE;
     313    }
     314    TRACE("drawing index=%d, himl=%p, left=%d, top=%d, flags=%08x\n",
     315          index, himl, left, top, draw_flags);
     316
     317    ImageList_Draw (himl, index, hdc, left, top, draw_flags);
     318    return TRUE;
     319}
     320
     321
     322/***********************************************************************
     323*               TOOLBAR_TestImageExist
     324*
     325* This function is similar to TOOLBAR_DrawImageList, except it does not
     326* draw the image. The I_IMAGECALLBACK functionality is implemented.
     327*/
     328static BOOL
     329TOOLBAR_TestImageExist (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl)
     330{
     331    INT index;
     332
     333    if (!himl) return FALSE;
     334
     335    if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
     336        ERR("index %d is not valid, max %d\n",
     337            btnPtr->iBitmap, infoPtr->nNumBitmaps);
     338        return FALSE;
     339    }
     340
     341    if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
     342        if (index == -1) return FALSE;
     343        ERR("TBN_GETDISPINFO returned invalid index %d\n",
     344            index);
     345        return FALSE;
     346    }
     347    return TRUE;
    161348}
    162349
     
    177364    LineTo (hdc, x, yTop);
    178365}
     366
     367
     368/***********************************************************************
     369*               TOOLBAR_DrawDDFlatSeparator
     370*
     371* This function draws the separator that was flaged as TBSTYLE_DROPDOWN.
     372* In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
     373* followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
     374* are horizontal as opposed to the vertical separators for not dropdown
     375* type.
     376*
     377* FIXME: It is possible that the height of each line is really SM_CYBORDER.
     378*/
     379static void
     380TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect, HDC hdc, TBUTTON_INFO *btnPtr)
     381{
     382    RECT myrect;
     383    COLORREF oldcolor, newcolor;
     384
     385    myrect.left = lpRect->left;
     386    myrect.right = lpRect->right;
     387    myrect.top = lpRect->top + (lpRect->bottom - lpRect->top - 2)/2;
     388    myrect.bottom = myrect.top + 1;
     389
     390    InflateRect (&myrect, -2, 0);
     391
     392    TRACE("rect=(%d,%d)-(%d,%d)\n",
     393          myrect.left, myrect.top, myrect.right, myrect.bottom);
     394
     395    newcolor = GetSysColor (COLOR_BTNSHADOW);
     396    oldcolor = SetBkColor (hdc, newcolor);
     397    ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
     398
     399    myrect.top = myrect.bottom;
     400    myrect.bottom = myrect.top + 1;
     401
     402    newcolor = GetSysColor (COLOR_BTNHIGHLIGHT);
     403    SetBkColor (hdc, newcolor);
     404    ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
     405
     406    SetBkColor (hdc, oldcolor);
     407}
     408
    179409
    180410static void
     
    196426 * Draw the text string for this button.
    197427 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
    198  *  is non-zero, so we can simply check himlDef to see if we have
     428 *      is non-zero, so we can simply check himlDef to see if we have
    199429 *      an image list
    200430 */
    201431static void
    202432TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
    203             HDC hdc, INT nState, DWORD dwStyle)
     433                    HDC hdc, INT nState, DWORD dwStyle)
    204434{
    205435    RECT   rcText = btnPtr->rect;
    206436    HFONT  hOldFont;
    207     INT    nOldBkMode;
    208437    COLORREF clrOld;
    209438    LPWSTR lpText = NULL;
     
    220449    if (lpText) {
    221450
    222     InflateRect (&rcText, -3, -3);
    223 
    224     if (himl && TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
    225         if ((dwStyle & TBSTYLE_LIST) &&
    226             ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
    227             (btnPtr->iBitmap != I_IMAGENONE)) {
    228             rcText.left += infoPtr->nBitmapWidth;
    229         }
    230         else {
    231             rcText.top += infoPtr->nBitmapHeight;
    232         }
    233     }
    234 
    235     if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
    236         OffsetRect (&rcText, 1, 1);
    237 
    238     hOldFont = SelectObject (hdc, infoPtr->hFont);
    239     nOldBkMode = SetBkMode (hdc, TRANSPARENT);
    240     if (!(nState & TBSTATE_ENABLED)) {
    241         clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
    242         OffsetRect (&rcText, 1, 1);
    243         DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
    244         SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
    245         OffsetRect (&rcText, -1, -1);
    246         DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
    247     }
    248     else if (nState & TBSTATE_INDETERMINATE) {
    249         clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
    250         DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
    251     }
    252     else {
    253         clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
    254         DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
    255     }
    256 
    257     SetTextColor (hdc, clrOld);
    258     SelectObject (hdc, hOldFont);
    259     if (nOldBkMode != TRANSPARENT)
    260         SetBkMode (hdc, nOldBkMode);
     451        InflateRect (&rcText, -3, -3);
     452
     453        if (himl && TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
     454                /* The following test looked like this before
     455                 * I changed it. IE4 "Links" toolbar would not
     456                 * draw correctly with the original code.  - GA 8/01
     457                 *   ((dwStyle & TBSTYLE_LIST) &&
     458                 *    ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
     459                 *       (btnPtr->iBitmap != I_IMAGENONE))
     460                 */
     461                if (dwStyle & TBSTYLE_LIST) {
     462                    /* LIST style w/ ICON offset is by matching native. */
     463                    /* Matches IE4 "Links" bar.   - GA 8/01             */
     464                    rcText.left += (infoPtr->nBitmapWidth + 2);
     465                }
     466                else {
     467                    rcText.top += infoPtr->nBitmapHeight + 1;
     468                }
     469        }
     470        else {
     471                if (dwStyle & TBSTYLE_LIST) {
     472                    /* LIST style w/o ICON offset is by matching native. */
     473                    /* Matches IE4 "menu" bar.   - GA  8/01              */
     474                    rcText.left += 4;
     475                }
     476        }
     477
     478        if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
     479            OffsetRect (&rcText, 1, 1);
     480
     481        TRACE("string rect=(%d,%d)-(%d,%d)\n",
     482              rcText.left, rcText.top, rcText.right, rcText.bottom);
     483
     484        hOldFont = SelectObject (hdc, infoPtr->hFont);
     485        if (!(nState & TBSTATE_ENABLED)) {
     486            clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
     487            OffsetRect (&rcText, 1, 1);
     488            DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
     489            SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
     490            OffsetRect (&rcText, -1, -1);
     491            DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
     492        }
     493        else if (nState & TBSTATE_INDETERMINATE) {
     494            clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
     495            DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
     496        }
     497        else {
     498            clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
     499            DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
     500        }
     501
     502        SetTextColor (hdc, clrOld);
     503        SelectObject (hdc, hOldFont);
    261504    }
    262505}
     
    276519static void
    277520TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
    278             HDC hdc, INT x, INT y)
     521                    HDC hdc, INT x, INT y)
    279522{
    280523    /* FIXME: this function is a hack since it uses image list
    281           internals directly */
     524              internals directly */
    282525
    283526    HIMAGELIST himl = infoPtr->himlDef;
     
    287530
    288531    if (!himl)
    289     return;
     532        return;
    290533
    291534    /* create new dc's */
     
    302545    SetTextColor (hdcImageList, RGB(0, 0, 0));
    303546    BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
    304           hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
     547              hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
    305548
    306549    /* draw the new mask */
    307550    SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
    308551    BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
    309           hdcMask, 0, 0, 0xB8074A);
     552              hdcMask, 0, 0, 0xB8074A);
    310553
    311554    SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
    312555    BitBlt (hdc, x, y, himl->cx, himl->cy,
    313           hdcMask, 0, 0, 0xB8074A);
     556              hdcMask, 0, 0, 0xB8074A);
    314557
    315558    DeleteObject (hbmMask);
     
    325568    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    326569    BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) &&
    327                         (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
     570                            (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
    328571    RECT rc, rcArrow, rcBitmap;
    329572
    330573    if (btnPtr->fsState & TBSTATE_HIDDEN)
    331     return;
     574        return;
    332575
    333576    rc = btnPtr->rect;
     
    335578    CopyRect(&rcBitmap, &rc);
    336579
    337     FillRect( hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
     580    if (!infoPtr->bBtnTranspnt)
     581        FillRect( hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
    338582
    339583    if (hasDropDownArrow)
    340584    {
    341     if (dwStyle & TBSTYLE_FLAT)
     585        if (dwStyle & TBSTYLE_FLAT)
    342586            rc.right = max(rc.left, rc.right - DDARROW_WIDTH);
     587        else
     588            rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2);
     589        rcArrow.left = rc.right;
     590    }
     591
     592    /* Center the bitmap horizontally and vertically */
     593    if (dwStyle & TBSTYLE_LIST)
     594        rcBitmap.left += 3;
    343595    else
    344             rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2);
    345     rcArrow.left = rc.right;
    346     }
    347 
    348     /* Center the bitmap horizontally and vertically */
    349     rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2;
     596        rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2;
    350597
    351598    if(TOOLBAR_HasText(infoPtr, btnPtr))
     
    354601        rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2;
    355602
    356     TRACE("iBitmap: %d\n", btnPtr->iBitmap);
     603    TRACE("iBitmap: %d, start=(%d,%d) w=%d, h=%d\n",
     604          btnPtr->iBitmap, rcBitmap.left, rcBitmap.top,
     605          infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
    357606
    358607    /* separator */
     
    363612        /* empirical tests show that iBitmap can/will be non-zero    */
    364613        /* when drawing the vertical bar...      */
    365         if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */)
    366         TOOLBAR_DrawFlatSeparator (&rc, hdc);
    367     return;
     614        if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) {
     615            if (btnPtr->fsStyle & TBSTYLE_DROPDOWN)
     616                TOOLBAR_DrawDDFlatSeparator (&rc, hdc, btnPtr);
     617            else
     618                TOOLBAR_DrawFlatSeparator (&rc, hdc);
     619        }
     620        return;
    368621    }
    369622
    370623    /* disabled */
    371624    if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
    372     if (!(dwStyle & TBSTYLE_FLAT))
    373     {
    374         DrawEdge (hdc, &rc, EDGE_RAISED,
    375               BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     625        if (!(dwStyle & TBSTYLE_FLAT))
     626        {
     627            DrawEdge (hdc, &rc, EDGE_RAISED,
     628                      BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    376629            if (hasDropDownArrow)
    377630            DrawEdge (hdc, &rcArrow, EDGE_RAISED,
    378               BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    379     }
    380 
     631                      BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     632        }
     633       
    381634        if (hasDropDownArrow)
    382     {
    383         TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT);
    384         TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW);
    385     }
    386 
    387     if (infoPtr->himlDis &&
    388             TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    389         ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
    390             rcBitmap.left, rcBitmap.top, ILD_NORMAL);
    391     else
    392         TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
    393 
    394     TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    395     return;
     635        {
     636            TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT);
     637            TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW);
     638        }
     639
     640        if (!TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDis,
     641                                   hdc, rcBitmap.left, rcBitmap.top,
     642                                   ILD_NORMAL))
     643            TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
     644
     645        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
     646        return;
    396647    }
    397648
    398649    /* pressed TBSTYLE_BUTTON */
    399650    if (btnPtr->fsState & TBSTATE_PRESSED) {
    400     if (dwStyle & TBSTYLE_FLAT)
    401     {
    402         DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST);
     651        if (dwStyle & TBSTYLE_FLAT)
     652        {
     653            DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
    403654            if (hasDropDownArrow)
    404         DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST);
    405     }
    406     else
    407     {
    408         DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
     655            DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
     656        }
     657        else
     658        {
     659            DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
    409660            if (hasDropDownArrow)
    410         DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
    411     }
     661            DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
     662        }
    412663
    413664        if (hasDropDownArrow)
    414         TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
    415 
    416         if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    417         ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    418             rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL);
    419 
    420     TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    421     return;
     665            TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
     666
     667        TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
     668                               hdc, rcBitmap.left+1, rcBitmap.top+1,
     669                              ILD_NORMAL);
     670
     671        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
     672        return;
    422673    }
    423674
    424675    /* checked TBSTYLE_CHECK */
    425676    if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
    426     (btnPtr->fsState & TBSTATE_CHECKED)) {
    427     if (dwStyle & TBSTYLE_FLAT)
    428         DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
    429             BF_RECT | BF_MIDDLE | BF_ADJUST);
    430     else
    431         DrawEdge (hdc, &rc, EDGE_SUNKEN,
    432             BF_RECT | BF_MIDDLE | BF_ADJUST);
    433 
    434     TOOLBAR_DrawPattern (hdc, &rc);
    435 
    436         if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    437         ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    438             rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL);
    439     TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    440     return;
    441     }
    442 
    443     /* indeterminate */
     677        (btnPtr->fsState & TBSTATE_CHECKED)) {
     678        if (dwStyle & TBSTYLE_FLAT)
     679            DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
     680                        BF_RECT | BF_ADJUST);
     681        else
     682            DrawEdge (hdc, &rc, EDGE_SUNKEN,
     683                        BF_RECT | BF_MIDDLE | BF_ADJUST);
     684
     685        TOOLBAR_DrawPattern (hdc, &rc);
     686       
     687        TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
     688                               hdc, rcBitmap.left+1, rcBitmap.top+1,
     689                               ILD_NORMAL);
     690
     691        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
     692        return;
     693    }
     694
     695    /* indeterminate */
    444696    if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
    445     DrawEdge (hdc, &rc, EDGE_RAISED,
    446             BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    447 
    448     TOOLBAR_DrawPattern (hdc, &rc);
    449     TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
    450     TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    451     return;
     697        DrawEdge (hdc, &rc, EDGE_RAISED,
     698                    BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     699
     700        TOOLBAR_DrawPattern (hdc, &rc);
     701        TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
     702        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
     703        return;
    452704    }
    453705
     
    455707    if (dwStyle & TBSTYLE_FLAT)
    456708    {
    457     if (btnPtr->bHot)
    458     {
    459         DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
     709        if (btnPtr->bHot)
     710        {
     711            DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT);
    460712            if (hasDropDownArrow)
    461         DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
    462     }
    463         else
    464     {
     713            DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT);
     714        }
     715#if 1
     716        else /* The following code needs to be removed after
     717              * "hot item" support has been implemented for the
     718              * case where it is being de-selected.
     719              */
     720        {
    465721            FrameRect(hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
    466722            if (hasDropDownArrow)
    467723            FrameRect(hdc, &rcArrow, GetSysColorBrush(COLOR_BTNFACE));
    468     }
     724        }
     725#endif
    469726
    470727        if (hasDropDownArrow)
    471         TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME);
    472 
    473     if (btnPtr->bHot && infoPtr->himlHot &&
    474             TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    475         ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc,
    476             rcBitmap.left, rcBitmap.top, ILD_NORMAL);
    477     else if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    478         ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    479             rcBitmap.left, rcBitmap.top, ILD_NORMAL);
     728            TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME);
     729
     730        if (btnPtr->bHot) {
     731            /* if hot, attempt to draw with himlHot, if fails, use himlDef */
     732            if (!TOOLBAR_DrawImageList (infoPtr, btnPtr,
     733                                        infoPtr->himlHot,
     734                                        hdc, rcBitmap.left,
     735                                        rcBitmap.top, ILD_NORMAL))
     736                TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
     737                                       hdc, rcBitmap.left, rcBitmap.top,
     738                                       ILD_NORMAL);
     739        }
     740        else
     741            TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
     742                                   hdc, rcBitmap.left, rcBitmap.top,
     743                                   ILD_NORMAL);
    480744    }
    481745    else
    482746    {
    483     DrawEdge (hdc, &rc, EDGE_RAISED,
    484         BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     747        DrawEdge (hdc, &rc, EDGE_RAISED,
     748                BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    485749
    486750        if (hasDropDownArrow)
    487     {
    488         DrawEdge (hdc, &rcArrow, EDGE_RAISED,
    489             BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    490         TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
    491     }
    492 
    493         if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    494         ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    495             rcBitmap.left, rcBitmap.top, ILD_NORMAL);
     751        {
     752            DrawEdge (hdc, &rcArrow, EDGE_RAISED,
     753                    BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     754            TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
     755        }
     756
     757        TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
     758                               hdc, rcBitmap.left, rcBitmap.top,
     759                              ILD_NORMAL);
    496760    }
    497761
     
    505769    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    506770    TBUTTON_INFO *btnPtr;
    507     INT i;
     771    INT i, oldBKmode = 0;
    508772    RECT rcTemp;
    509773
     
    512776    if (infoPtr->himlDef != infoPtr->himlInt)
    513777        infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef);
     778
     779    TOOLBAR_DumpToolbar (infoPtr, __LINE__);
     780
     781    if (infoPtr->bBtnTranspnt)
     782        oldBKmode = SetBkMode (hdc, TRANSPARENT);
     783
    514784    /* redraw necessary buttons */
    515785    btnPtr = infoPtr->buttons;
     
    519789            TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
    520790    }
    521 }
    522 
     791
     792    if (infoPtr->bBtnTranspnt && (oldBKmode != TRANSPARENT))
     793        SetBkMode (hdc, oldBKmode);
     794}
     795
     796/***********************************************************************
     797*               TOOLBAR_MeasureString
     798*
     799* This function gets the width and height of a string in pixels. This
     800* is done first by using GetTextExtentPoint to get the basic width
     801* and height. The DrawText is called with DT_CALCRECT to get the exact
     802* width. The reason is because the text may have more than one "&" (or
     803* prefix characters as M$ likes to call them). The prefix character
     804* indicates where the underline goes, except for the string "&&" which
     805* is reduced to a single "&". GetTextExtentPoint does not process these
     806* only DrawText does. Note that the TBSTYLE_NOPREFIX is handled here.
     807*/
    523808static void
    524 TOOLBAR_MeasureString(HWND hwnd, INT index, LPSIZE lpSize)
    525 {
    526     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    527     TBUTTON_INFO *btnPtr;
    528     HDC hdc;
    529     HFONT hOldFont;
     809TOOLBAR_MeasureString(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
     810                      HDC hdc, LPSIZE lpSize)
     811{
     812    RECT myrect;
    530813
    531814    lpSize->cx = 0;
    532815    lpSize->cy = 0;
    533     hdc = GetDC (0);
    534     hOldFont = SelectObject (hdc, infoPtr->hFont);
    535 
    536     btnPtr = &infoPtr->buttons[index];
    537816
    538817    if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
    539818         (btnPtr->iString > -1) &&
    540          (btnPtr->iString < infoPtr->nNumStrings))
     819         (btnPtr->iString < infoPtr->nNumStrings)) 
    541820    {
    542821        LPWSTR lpText = infoPtr->strings[btnPtr->iString];
     822
     823        /* first get size of all the text */
    543824        GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize);
    544     }
    545 
    546     SelectObject (hdc, hOldFont);
    547     ReleaseDC (0, hdc);
     825
     826        /* feed above size into the rectangle for DrawText */
     827        myrect.left = myrect.top = 0;
     828        myrect.right = lpSize->cx;
     829        myrect.bottom = lpSize->cy;
     830
     831        /* Use DrawText to get true size as drawn (less pesky "&") */
     832        DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE |
     833                   DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ?
     834                                  DT_NOPREFIX : 0));
     835
     836        /* feed back to caller  */
     837        lpSize->cx = myrect.right;
     838        lpSize->cy = myrect.bottom;
     839    }
    548840
    549841    TRACE("string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
    550842}
    551843
     844/***********************************************************************
     845*               TOOLBAR_CalcStrings
     846*
     847* This function walks through each string and measures it and returns
     848* the largest height and width to caller.
     849*/
    552850static void
    553851TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
     
    557855    INT i;
    558856    SIZE sz;
    559 
     857    HDC hdc;
     858    HFONT hOldFont;
    560859
    561860    lpSize->cx = 0;
    562861    lpSize->cy = 0;
     862
     863    hdc = GetDC (hwnd);
     864    hOldFont = SelectObject (hdc, infoPtr->hFont);
    563865
    564866    btnPtr = infoPtr->buttons;
     
    566868        if(TOOLBAR_HasText(infoPtr, btnPtr))
    567869        {
    568             TOOLBAR_MeasureString(hwnd,i,&sz);
     870            TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
    569871            if (sz.cx > lpSize->cx)
    570872                lpSize->cx = sz.cx;
     
    574876    }
    575877
    576     TRACE("string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
     878    SelectObject (hdc, hOldFont);
     879    ReleaseDC (hwnd, hdc);
     880
     881    TRACE("max string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
    577882}
    578883
    579884/***********************************************************************
    580 *       TOOLBAR_WrapToolbar
     885*               TOOLBAR_WrapToolbar
    581886*
    582 * This function walks through the buttons and seperators in the
    583 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
    584 * wrapping should occur based on the width of the toolbar window.
    585 * It does *not* calculate button placement itself.  That task
    586 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
    587 * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE
     887* This function walks through the buttons and seperators in the 
     888* toolbar, and sets the TBSTATE_WRAP flag only on those items where 
     889* wrapping should occur based on the width of the toolbar window. 
     890* It does *not* calculate button placement itself.  That task 
     891* takes place in TOOLBAR_CalcToolbar. If the program wants to manage 
     892* the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
    588893* flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
    589 */
     894*/ 
    590895
    591896static void
     
    598903    BOOL bWrap, bButtonWrap;
    599904
    600     /*  When the toolbar window style is not TBSTYLE_WRAPABLE,  */
    601     /*  no layout is necessary. Applications may use this style */
    602     /*  to perform their own layout on the toolbar.         */
     905    /*  When the toolbar window style is not TBSTYLE_WRAPABLE,  */
     906    /*  no layout is necessary. Applications may use this style */
     907    /*  to perform their own layout on the toolbar.             */
    603908    if( !(dwStyle & TBSTYLE_WRAPABLE) )
    604     return;
     909        return;
    605910
    606911    btnPtr = infoPtr->buttons;
     
    615920    bButtonWrap = FALSE;
    616921
     922    TRACE("start ButtonWidth=%d, BitmapWidth=%d, nWidth=%d, nIndent=%d\n",
     923          infoPtr->nButtonWidth, infoPtr->nBitmapWidth, infoPtr->nWidth,
     924          infoPtr->nIndent);
     925
    617926    for (i = 0; i < infoPtr->nNumButtons; i++ )
    618927    {
    619     bWrap = FALSE;
    620     btnPtr[i].fsState &= ~TBSTATE_WRAP;
    621 
    622     if (btnPtr[i].fsState & TBSTATE_HIDDEN)
    623         continue;
    624 
    625     /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
    626     /* it is the actual width of the separator. This is used for */
    627     /* custom controls in toolbars.                              */
    628     if (btnPtr[i].fsStyle & TBSTYLE_SEP)
    629         cx = (btnPtr[i].iBitmap > 0) ?
    630             btnPtr[i].iBitmap : SEPARATOR_WIDTH;
    631     else
    632         cx = infoPtr->nButtonWidth;
    633 
    634     /* Two or more adjacent separators form a separator group.   */
    635     /* The first separator in a group should be wrapped to the   */
    636     /* next row if the previous wrapping is on a button.         */
    637     if( bButtonWrap &&
    638         (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
    639         (i + 1 < infoPtr->nNumButtons ) &&
    640         (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
    641     {
    642         btnPtr[i].fsState |= TBSTATE_WRAP;
    643         x = infoPtr->nIndent;
    644         i++;
    645         bButtonWrap = FALSE;
    646         continue;
    647     }
    648 
    649     /* The layout makes sure the bitmap is visible, but not the button. */
    650     if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
    651          > infoPtr->nWidth )
    652     {
    653         BOOL bFound = FALSE;
    654 
    655         /*  If the current button is a separator and not hidden,  */
    656         /*  go to the next until it reaches a non separator.      */
    657         /*  Wrap the last separator if it is before a button.     */
    658         while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
    659             (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
    660             i < infoPtr->nNumButtons )
    661         {
    662         i++;
    663         bFound = TRUE;
    664         }
    665 
    666         if( bFound && i < infoPtr->nNumButtons )
    667         {
    668         i--;
    669         btnPtr[i].fsState |= TBSTATE_WRAP;
    670         x = infoPtr->nIndent;
    671         bButtonWrap = FALSE;
    672         continue;
    673         }
    674         else if ( i >= infoPtr->nNumButtons)
    675         break;
    676 
    677         /*  If the current button is not a separator, find the last  */
    678         /*  separator and wrap it.                   */
    679         for ( j = i - 1; j >= 0  &&  !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
    680         {
    681         if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
    682             !(btnPtr[j].fsState & TBSTATE_HIDDEN))
    683         {
    684             bFound = TRUE;
    685             i = j;
    686             x = infoPtr->nIndent;
    687             btnPtr[j].fsState |= TBSTATE_WRAP;
    688             bButtonWrap = FALSE;
    689             break;
    690         }
    691         }
    692 
    693         /*  If no separator available for wrapping, wrap one of     */
    694         /*  non-hidden previous button.                     */
    695         if (!bFound)
    696         {
    697         for ( j = i - 1;
    698             j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
    699         {
    700             if (btnPtr[j].fsState & TBSTATE_HIDDEN)
    701             continue;
    702 
    703             bFound = TRUE;
    704             i = j;
    705             x = infoPtr->nIndent;
    706             btnPtr[j].fsState |= TBSTATE_WRAP;
    707             bButtonWrap = TRUE;
    708             break;
    709         }
    710         }
    711 
    712         /* If all above failed, wrap the current button. */
    713         if (!bFound)
    714         {
    715         btnPtr[i].fsState |= TBSTATE_WRAP;
    716         bFound = TRUE;
    717         x = infoPtr->nIndent;
    718         if (btnPtr[i].fsState & TBSTYLE_SEP )
    719             bButtonWrap = FALSE;
    720         else
    721             bButtonWrap = TRUE;
    722         }
    723     }
    724     else
    725         x += cx;
     928        bWrap = FALSE;
     929        btnPtr[i].fsState &= ~TBSTATE_WRAP;
     930       
     931        if (btnPtr[i].fsState & TBSTATE_HIDDEN)
     932            continue;
     933
     934        /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
     935        /* it is the actual width of the separator. This is used for */
     936        /* custom controls in toolbars.                              */
     937        /*                                                           */
     938        /* TBSTYLE_DROPDOWN separators are treated as buttons for    */
     939        /* width.  - GA 8/01                                         */
     940        if ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
     941            !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN))
     942            cx = (btnPtr[i].iBitmap > 0) ? 
     943                        btnPtr[i].iBitmap : SEPARATOR_WIDTH;
     944        else
     945            cx = infoPtr->nButtonWidth;
     946
     947        /* Two or more adjacent separators form a separator group.   */
     948        /* The first separator in a group should be wrapped to the   */
     949        /* next row if the previous wrapping is on a button.         */
     950        if( bButtonWrap &&
     951                (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
     952                (i + 1 < infoPtr->nNumButtons ) &&
     953                (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
     954        {
     955            TRACE("wrap point 1 btn %d style %02x\n", i, btnPtr[i].fsStyle);
     956            btnPtr[i].fsState |= TBSTATE_WRAP;
     957            x = infoPtr->nIndent;
     958            i++;
     959            bButtonWrap = FALSE;
     960            continue;
     961        }
     962
     963        /* The layout makes sure the bitmap is visible, but not the button. */
     964        /* Test added to also wrap after a button that starts a row but     */
     965        /* is bigger than the area.  - GA  8/01                             */
     966        if (( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
     967           > infoPtr->nWidth ) ||
     968            ((x == infoPtr->nIndent) && (cx > infoPtr->nWidth)))
     969        {
     970            BOOL bFound = FALSE;
     971
     972            /*  If the current button is a separator and not hidden,  */
     973            /*  go to the next until it reaches a non separator.      */
     974            /*  Wrap the last separator if it is before a button.     */
     975            while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
     976                        (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
     977                        i < infoPtr->nNumButtons )
     978            {
     979                i++;
     980                bFound = TRUE;
     981            }
     982   
     983            if( bFound && i < infoPtr->nNumButtons )
     984            {
     985                i--;
     986                TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
     987                      i, btnPtr[i].fsStyle, x, cx);
     988                btnPtr[i].fsState |= TBSTATE_WRAP;
     989                x = infoPtr->nIndent;
     990                bButtonWrap = FALSE;
     991                continue;
     992            }
     993            else if ( i >= infoPtr->nNumButtons)
     994                break;
     995
     996            /*  If the current button is not a separator, find the last  */
     997            /*  separator and wrap it.                                   */
     998            for ( j = i - 1; j >= 0  &&  !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
     999            {
     1000                if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
     1001                        !(btnPtr[j].fsState & TBSTATE_HIDDEN))
     1002                {
     1003                    bFound = TRUE;
     1004                    i = j;
     1005                    TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
     1006                          i, btnPtr[i].fsStyle, x, cx);
     1007                    x = infoPtr->nIndent;
     1008                    btnPtr[j].fsState |= TBSTATE_WRAP;
     1009                    bButtonWrap = FALSE;
     1010                    break;
     1011                }
     1012            }
     1013
     1014            /*  If no separator available for wrapping, wrap one of     */
     1015            /*  non-hidden previous button.                             */
     1016            if (!bFound)
     1017            {
     1018                for ( j = i - 1;
     1019                        j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
     1020                {
     1021                    if (btnPtr[j].fsState & TBSTATE_HIDDEN)
     1022                        continue;
     1023
     1024                    bFound = TRUE;
     1025                    i = j;
     1026                    TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
     1027                          i, btnPtr[i].fsStyle, x, cx);
     1028                    x = infoPtr->nIndent;
     1029                    btnPtr[j].fsState |= TBSTATE_WRAP;
     1030                    bButtonWrap = TRUE;
     1031                    break;
     1032                }
     1033            }
     1034
     1035            /* If all above failed, wrap the current button. */
     1036            if (!bFound) 
     1037            {
     1038                TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
     1039                      i, btnPtr[i].fsStyle, x, cx);
     1040                btnPtr[i].fsState |= TBSTATE_WRAP;
     1041                bFound = TRUE;
     1042                x = infoPtr->nIndent;
     1043                if (btnPtr[i].fsStyle & TBSTYLE_SEP )
     1044                    bButtonWrap = FALSE;
     1045                else
     1046                    bButtonWrap = TRUE;
     1047            }               
     1048        }
     1049        else {
     1050            TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
     1051                  i, btnPtr[i].fsStyle, x, cx);
     1052            x += cx;
     1053        }
    7261054    }
    7271055}
     
    7291057
    7301058/***********************************************************************
    731 *       TOOLBAR_CalcToolbar
     1059*               TOOLBAR_CalcToolbar
    7321060*
    733 * This function calculates button and separator placement. It first
    734 * calculates the button sizes, gets the toolbar window width and then
    735 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
     1061* This function calculates button and separator placement. It first 
     1062* calculates the button sizes, gets the toolbar window width and then 
     1063* calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap 
    7361064* on. It assigns a new location to each item and sends this location to
    737 * the tooltip window if appropriate. Finally, it updates the rcBound
    738 * rect and calculates the new required toolbar window height.
    739 */
     1065* the tooltip window if appropriate. Finally, it updates the rcBound 
     1066* rect and calculates the new required toolbar window height. 
     1067*/ 
    7401068
    7411069static void
     
    7561084    if (dwStyle & TBSTYLE_LIST)
    7571085    {
    758     infoPtr->nButtonHeight = max(infoPtr->nBitmapHeight, sizeString.cy) + 6;
    759     infoPtr->nButtonWidth = infoPtr->nBitmapWidth + sizeString.cx + 6;
     1086        for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
     1087        {
     1088            if (infoPtr->buttons[i].iBitmap >= 0)
     1089                usesBitmaps = TRUE;
     1090        }
     1091        infoPtr->nButtonHeight = max((usesBitmaps) ? infoPtr->nBitmapHeight :
     1092                                     0, sizeString.cy) + 6;
     1093        infoPtr->nButtonWidth = ((usesBitmaps) ? infoPtr->nBitmapWidth :
     1094                                 0) + sizeString.cx + 6;
     1095        TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n",
     1096              infoPtr->nButtonWidth, infoPtr->nButtonHeight, usesBitmaps,
     1097              infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
     1098        TOOLBAR_DumpToolbar (infoPtr, __LINE__);
    7601099    }
    7611100    else {
    7621101        for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
    7631102        {
    764         if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap))
    765             usesBitmaps = TRUE;
     1103            if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap))
     1104                usesBitmaps = TRUE;
    7661105        }
    7671106
     
    7691108        {
    7701109            if (usesBitmaps)
    771           infoPtr->nButtonHeight = sizeString.cy +
     1110                infoPtr->nButtonHeight = sizeString.cy +
     1111                    2 + /* this is the space to separate text from bitmap */
    7721112                  infoPtr->nBitmapHeight + 6;
    773             else
     1113            else 
    7741114                infoPtr->nButtonHeight = sizeString.cy + 6;
    7751115        }
    7761116        else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
    777         infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
     1117            infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
    7781118
    7791119        if (sizeString.cx > infoPtr->nBitmapWidth)
    780         infoPtr->nButtonWidth = sizeString.cx + 6;
     1120            infoPtr->nButtonWidth = sizeString.cx + 6;
    7811121        else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
    782         infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
     1122            infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
    7831123    }
    7841124
    7851125    if ( infoPtr->cxMin >= 0 && infoPtr->nButtonWidth < infoPtr->cxMin )
    7861126        infoPtr->nButtonWidth = infoPtr->cxMin;
    787     if ( infoPtr->cxMax >= 0 && infoPtr->nButtonWidth > infoPtr->cxMax )
     1127    if ( infoPtr->cxMax > 0 && infoPtr->nButtonWidth > infoPtr->cxMax )
    7881128        infoPtr->nButtonWidth = infoPtr->cxMax;
    7891129
     
    7911131
    7921132    x  = infoPtr->nIndent;
    793     y  = (dwStyle & TBSTYLE_FLAT) ? 0 : TOP_BORDER;
     1133    y  = 0;
    7941134
    7951135   /*
    796     * We will set the height below, and we set the width on entry
    797     * so we do not reset them here..
     1136    * We will set the height below, and we set the width on entry 
     1137    * so we do not reset them here.. 
    7981138    */
    7991139#if 0
     
    8281168/*    cy = rc.bottom - rc.top; */
    8291169
     1170    TRACE("cy=%d\n", cy);
     1171
    8301172    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
    8311173    {
    832     bWrap = FALSE;
    833     if (btnPtr->fsState & TBSTATE_HIDDEN)
    834     {
    835         SetRectEmpty (&btnPtr->rect);
    836         continue;
    837     }
    838 
    839         /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
    840         /* it is the actual width of the separator. This is used for */
    841         /* custom controls in toolbars.                              */
    842     if (btnPtr->fsStyle & TBSTYLE_SEP)
    843         cx = (btnPtr->iBitmap > 0) ?
    844              btnPtr->iBitmap : SEPARATOR_WIDTH;
    845     else
    846     {
    847             if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE)
     1174        bWrap = FALSE;
     1175        if (btnPtr->fsState & TBSTATE_HIDDEN)
     1176        {
     1177            SetRectEmpty (&btnPtr->rect);
     1178            continue;
     1179        }
     1180
     1181        cy = infoPtr->nHeight;
     1182
     1183        /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
     1184        /* it is the actual width of the separator. This is used for */
     1185        /* custom controls in toolbars.                              */
     1186        if (btnPtr->fsStyle & TBSTYLE_SEP) {
     1187            if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) {
     1188                cy = (btnPtr->iBitmap > 0) ?
     1189                     btnPtr->iBitmap : SEPARATOR_WIDTH;
     1190                cx = infoPtr->nButtonWidth;
     1191            }
     1192            else
     1193                cx = (btnPtr->iBitmap > 0) ?
     1194                     btnPtr->iBitmap : SEPARATOR_WIDTH;
     1195        }
     1196        else
     1197        {
     1198            if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE)
    8481199            {
    8491200              SIZE sz;
    850               TOOLBAR_MeasureString(hwnd,i,&sz);
    851               cx = sz.cx + 6;
     1201              HDC hdc;
     1202              HFONT hOldFont;
     1203
     1204              hdc = GetDC (hwnd);
     1205              hOldFont = SelectObject (hdc, infoPtr->hFont);
     1206
     1207              TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
     1208
     1209              SelectObject (hdc, hOldFont);
     1210              ReleaseDC (hwnd, hdc);
     1211
     1212              /* Fudge amount measured against IE4 "menu" and "Links" */
     1213              /* toolbars with native control (v4.71).  -  GA 8/01    */
     1214              cx = sz.cx + 6 + 5 + 5;
     1215              if ((dwStyle & TBSTYLE_LIST) &&
     1216                  (TOOLBAR_TestImageExist (infoPtr, btnPtr, infoPtr->himlDef)))
     1217                  cx += infoPtr->nBitmapWidth;
    8521218            }
    8531219            else
    854           cx = infoPtr->nButtonWidth;
    855 
    856         if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN))
    857           cx += DDARROW_WIDTH;
    858     }
    859     cy = infoPtr->nHeight;
    860 
    861     if (btnPtr->fsState & TBSTATE_WRAP )
    862             bWrap = TRUE;
    863 
    864     SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
    865 
    866     if (infoPtr->rcBound.left > x)
    867         infoPtr->rcBound.left = x;
    868     if (infoPtr->rcBound.right < x + cx)
    869         infoPtr->rcBound.right = x + cx;
    870     if (infoPtr->rcBound.bottom < y + cy)
    871         infoPtr->rcBound.bottom = y + cy;
    872 
    873     /* Set the toolTip only for non-hidden, non-separator button */
    874     if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
    875     {
    876         TTTOOLINFOA ti;
    877 
    878         ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    879         ti.cbSize = sizeof(TTTOOLINFOA);
    880         ti.hwnd = hwnd;
    881         ti.uId = btnPtr->idCommand;
    882         ti.rect = btnPtr->rect;
    883         SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
    884                 0, (LPARAM)&ti);
    885     }
    886 
    887     /* btnPtr->nRow is zero based. The space between the rows is    */
    888     /* also considered as a row.                    */
    889     btnPtr->nRow = nRows + nSepRows;
    890     if( bWrap )
    891     {
    892         if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
    893             y += cy;
    894         else
    895         {
    896         /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
    897         /* it is the actual width of the separator. This is used for */
    898         /* custom controls in toolbars.                  */
    899         y += cy + ( (btnPtr->iBitmap > 0 ) ?
    900             btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
    901 
    902         /* nSepRows is used to calculate the extra height follwoing  */
    903         /* the last row.                         */
    904         nSepRows++;
    905         }
    906         x = infoPtr->nIndent;
    907         nRows++;
    908     }
    909     else
    910         x += cx;
     1220              cx = infoPtr->nButtonWidth;
     1221
     1222            if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN))
     1223              cx += DDARROW_WIDTH;
     1224        }
     1225        if (btnPtr->fsState & TBSTATE_WRAP )
     1226                    bWrap = TRUE;
     1227
     1228        SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
     1229
     1230        if (infoPtr->rcBound.left > x)
     1231            infoPtr->rcBound.left = x;
     1232        if (infoPtr->rcBound.right < x + cx)
     1233            infoPtr->rcBound.right = x + cx;
     1234        if (infoPtr->rcBound.bottom < y + cy)
     1235            infoPtr->rcBound.bottom = y + cy;
     1236
     1237        /* Set the toolTip only for non-hidden, non-separator button */
     1238        if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
     1239        {
     1240            TTTOOLINFOA ti;
     1241
     1242            ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     1243            ti.cbSize = sizeof(TTTOOLINFOA);
     1244            ti.hwnd = hwnd;
     1245            ti.uId = btnPtr->idCommand;
     1246            ti.rect = btnPtr->rect;
     1247            SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
     1248                            0, (LPARAM)&ti);
     1249        }
     1250
     1251        /* btnPtr->nRow is zero based. The space between the rows is    */
     1252        /* also considered as a row.                                    */
     1253        btnPtr->nRow = nRows + nSepRows;
     1254
     1255        TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d\n",
     1256              i, btnPtr->fsStyle, bWrap, nRows, nSepRows, btnPtr->nRow);
     1257
     1258        if( bWrap )
     1259        {
     1260            if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
     1261                y += cy;
     1262            else
     1263            {   
     1264                /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
     1265                /* it is the actual width of the separator. This is used for */
     1266                /* custom controls in toolbars.                              */
     1267                if ( !(btnPtr->fsStyle & TBSTYLE_DROPDOWN))
     1268                    y += cy + ( (btnPtr->iBitmap > 0 ) ?
     1269                                btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
     1270                else
     1271                    y += cy;
     1272             
     1273                /* nSepRows is used to calculate the extra height follwoing  */
     1274                /* the last row.                                             */
     1275                nSepRows++;
     1276            }
     1277            x = infoPtr->nIndent;
     1278                nRows++;
     1279        }
     1280        else
     1281            x += cx;
    9111282    }
    9121283
     
    9141285    infoPtr->nRows = nRows + nSepRows + 1;
    9151286
    916     /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following   */
    917     /* the last row.                            */
    918     infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
    919                 nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
    920             nSepRows * (infoPtr->nBitmapHeight + 1) +
    921             BOTTOM_BORDER;
     1287    /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following   */
     1288    /* the last row.                                                    */
     1289    infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight + 
     1290                        nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
     1291                        nSepRows * (infoPtr->nBitmapHeight + 1) +
     1292                        BOTTOM_BORDER;
    9221293    TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth);
    9231294}
     
    9301301    TBUTTON_INFO *btnPtr;
    9311302    INT i;
    932 
     1303   
    9331304    btnPtr = infoPtr->buttons;
    9341305    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
    935     if (btnPtr->fsState & TBSTATE_HIDDEN)
    936         continue;
    937 
    938     if (btnPtr->fsStyle & TBSTYLE_SEP) {
    939         if (PtInRect (&btnPtr->rect, *lpPt)) {
    940         TRACE(" ON SEPARATOR %d!\n", i);
    941         return -i;
    942         }
    943     }
    944     else {
    945         if (PtInRect (&btnPtr->rect, *lpPt)) {
    946         TRACE(" ON BUTTON %d!\n", i);
    947         return i;
    948         }
    949     }
     1306        if (btnPtr->fsState & TBSTATE_HIDDEN)
     1307            continue;
     1308
     1309        if (btnPtr->fsStyle & TBSTYLE_SEP) {
     1310            if (PtInRect (&btnPtr->rect, *lpPt)) {
     1311                TRACE(" ON SEPARATOR %d!\n", i);
     1312                return -i;
     1313            }
     1314        }
     1315        else {
     1316            if (PtInRect (&btnPtr->rect, *lpPt)) {
     1317                TRACE(" ON BUTTON %d!\n", i);
     1318                return i;
     1319            }
     1320        }
    9501321    }
    9511322
     
    9631334    btnPtr = infoPtr->buttons;
    9641335    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
    965     if (btnPtr->idCommand == idCommand) {
    966         TRACE("command=%d index=%d\n", idCommand, i);
    967         return i;
    968     }
     1336        if (btnPtr->idCommand == idCommand) {
     1337            TRACE("command=%d index=%d\n", idCommand, i);
     1338            return i;
     1339        }
    9691340    }
    9701341    TRACE("no index found for command=%d\n", idCommand);
     
    9801351
    9811352    if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
    982     return -1;
     1353        return -1;
    9831354
    9841355    /* check index button */
    9851356    btnPtr = &infoPtr->buttons[nIndex];
    9861357    if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
    987     if (btnPtr->fsState & TBSTATE_CHECKED)
    988         return nIndex;
     1358        if (btnPtr->fsState & TBSTATE_CHECKED)
     1359            return nIndex;
    9891360    }
    9901361
     
    9921363    nRunIndex = nIndex - 1;
    9931364    while (nRunIndex >= 0) {
    994     btnPtr = &infoPtr->buttons[nRunIndex];
    995     if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
    996         if (btnPtr->fsState & TBSTATE_CHECKED)
    997         return nRunIndex;
    998     }
    999     else
    1000         break;
    1001     nRunIndex--;
     1365        btnPtr = &infoPtr->buttons[nRunIndex];
     1366        if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
     1367            if (btnPtr->fsState & TBSTATE_CHECKED)
     1368                return nRunIndex;
     1369        }
     1370        else
     1371            break;
     1372        nRunIndex--;
    10021373    }
    10031374
     
    10051376    nRunIndex = nIndex + 1;
    10061377    while (nRunIndex < infoPtr->nNumButtons) {
    1007     btnPtr = &infoPtr->buttons[nRunIndex];
    1008     if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
    1009         if (btnPtr->fsState & TBSTATE_CHECKED)
    1010         return nRunIndex;
    1011     }
    1012     else
    1013         break;
    1014     nRunIndex++;
     1378        btnPtr = &infoPtr->buttons[nRunIndex]; 
     1379        if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
     1380            if (btnPtr->fsState & TBSTATE_CHECKED)
     1381                return nRunIndex;
     1382        }
     1383        else
     1384            break;
     1385        nRunIndex++;
    10151386    }
    10161387
     
    10211392static VOID
    10221393TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
    1023             WPARAM wParam, LPARAM lParam)
     1394                    WPARAM wParam, LPARAM lParam)
    10241395{
    10251396    MSG msg;
     
    10471418    PCUSTOMBUTTON btnInfo;
    10481419    NMTOOLBARA nmtb;
     1420    TOOLBAR_INFO *infoPtr = custInfo->tbInfo;
    10491421
    10501422    switch (uMsg)
    10511423    {
    1052     case WM_INITDIALOG:
    1053         custInfo = (PCUSTDLG_INFO)lParam;
    1054         SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo);
    1055 
    1056         if (custInfo)
    1057         {
    1058         char Buffer[256];
    1059         int i = 0;
    1060         int index;
    1061 
    1062         /* send TBN_QUERYINSERT notification */
    1063         nmtb.hdr.hwndFrom = hwnd;
    1064         nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1065         nmtb.hdr.code     = TBN_QUERYINSERT;
    1066         nmtb.iItem = custInfo->tbInfo->nNumButtons;
    1067 
    1068         if (!SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1069                    (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1070             return FALSE;
    1071 
    1072         /* add items to 'toolbar buttons' list and check if removable */
    1073         for (i = 0; i < custInfo->tbInfo->nNumButtons; i++)
    1074         {
    1075             btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
    1076             memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
    1077             btnInfo->btn.fsStyle = TBSTYLE_SEP;
    1078             btnInfo->bVirtual = FALSE;
    1079             LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
    1080 
    1081             /* send TBN_QUERYDELETE notification */
    1082             nmtb.hdr.hwndFrom = hwnd;
    1083             nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1084             nmtb.hdr.code     = TBN_QUERYDELETE;
    1085             nmtb.iItem = i;
    1086 
    1087             btnInfo->bRemovable = SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1088                             (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
    1089 
    1090             index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0);
    1091             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1092         }
    1093 
    1094         /* insert separator button into 'available buttons' list */
    1095         btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
    1096         memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
    1097         btnInfo->btn.fsStyle = TBSTYLE_SEP;
    1098         btnInfo->bVirtual = FALSE;
    1099         btnInfo->bRemovable = TRUE;
    1100         LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
    1101         index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
    1102         SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1103 
    1104         /* insert all buttons into dsa */
    1105         for (i = 0;; i++)
    1106         {
    1107             /* send TBN_GETBUTTONINFO notification */
    1108             nmtb.hdr.hwndFrom = hwnd;
    1109             nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1110             nmtb.hdr.code     = TBN_GETBUTTONINFOA;
    1111             nmtb.iItem = i;
    1112             nmtb.pszText = Buffer;
    1113             nmtb.cchText = 256;
    1114 
    1115             if (!SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1116                        (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1117             break;
    1118 
    1119             TRACE("style: %x\n", nmtb.tbButton.fsStyle);
    1120 
    1121             /* insert button into the apropriate list */
    1122             index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand);
    1123             if (index == -1)
    1124             {
    1125             btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
    1126             memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
    1127             btnInfo->bVirtual = FALSE;
    1128             btnInfo->bRemovable = TRUE;
    1129             if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
    1130                 strcpy (btnInfo->text, nmtb.pszText);
    1131 
    1132             index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
    1133             SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1424        case WM_INITDIALOG:
     1425            custInfo = (PCUSTDLG_INFO)lParam;
     1426            SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo);
     1427
     1428            if (custInfo)
     1429            {
     1430                char Buffer[256];
     1431                int i = 0;
     1432                int index;
     1433
     1434                /* send TBN_QUERYINSERT notification */
     1435                nmtb.iItem = custInfo->tbInfo->nNumButtons;
     1436
     1437                if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_QUERYINSERT))
     1438                    return FALSE;
     1439
     1440                /* add items to 'toolbar buttons' list and check if removable */
     1441                for (i = 0; i < custInfo->tbInfo->nNumButtons; i++)
     1442                {
     1443                    btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
     1444                    memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
     1445                    btnInfo->btn.fsStyle = TBSTYLE_SEP;
     1446                    btnInfo->bVirtual = FALSE;
     1447                    LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
     1448
     1449                    /* send TBN_QUERYDELETE notification */
     1450                    nmtb.iItem = i;
     1451                    btnInfo->bRemovable = TOOLBAR_SendNotify ((NMHDR *) &nmtb,
     1452                                                      infoPtr,
     1453                                                      TBN_QUERYDELETE);
     1454
     1455                    index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0);
     1456                    SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1457                }
     1458
     1459                /* insert separator button into 'available buttons' list */
     1460                btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
     1461                memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
     1462                btnInfo->btn.fsStyle = TBSTYLE_SEP;
     1463                btnInfo->bVirtual = FALSE;
     1464                btnInfo->bRemovable = TRUE;
     1465                LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
     1466                index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
     1467                SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1468
     1469                /* insert all buttons into dsa */
     1470                for (i = 0;; i++)
     1471                {
     1472                    /* send TBN_GETBUTTONINFO notification */
     1473                    nmtb.iItem = i;
     1474                    nmtb.pszText = Buffer;
     1475                    nmtb.cchText = 256;
     1476
     1477                    if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_GETBUTTONINFOA))
     1478                        break;
     1479
     1480                    TRACE("style: %x\n", nmtb.tbButton.fsStyle);               
     1481
     1482                    /* insert button into the apropriate list */
     1483                    index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand);
     1484                    if (index == -1)
     1485                    {
     1486                        btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
     1487                        memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
     1488                        btnInfo->bVirtual = FALSE;
     1489                        btnInfo->bRemovable = TRUE;
     1490                        if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
     1491                            strcpy (btnInfo->text, nmtb.pszText);
     1492
     1493                        index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
     1494                        SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1495                    }
     1496                    else
     1497                    {
     1498                        btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
     1499                        memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
     1500                        if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
     1501                            strcpy (btnInfo->text, nmtb.pszText);
     1502
     1503                        SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1504                    }
     1505                }
     1506
     1507                /* select first item in the 'available' list */
     1508                SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0);
     1509
     1510                /* append 'virtual' separator button to the 'toolbar buttons' list */
     1511                btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
     1512                memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
     1513                btnInfo->btn.fsStyle = TBSTYLE_SEP;
     1514                btnInfo->bVirtual = TRUE;
     1515                btnInfo->bRemovable = FALSE;
     1516                LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
     1517                index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
     1518                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1519
     1520                /* select last item in the 'toolbar' list */
     1521                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0);
     1522                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0);
     1523
     1524                /* set focus and disable buttons */
     1525                PostMessageA (hwnd, WM_USER, 0, 0);
     1526            }
     1527            return TRUE;
     1528
     1529        case WM_USER:
     1530            EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
     1531            EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
     1532            EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE);
     1533            SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX));
     1534            return TRUE;
     1535
     1536        case WM_CLOSE:
     1537            EndDialog(hwnd, FALSE);
     1538            return TRUE;
     1539
     1540        case WM_COMMAND:
     1541            switch (LOWORD(wParam))
     1542            {
     1543                case IDC_TOOLBARBTN_LBOX:
     1544                    if (HIWORD(wParam) == LBN_SELCHANGE)
     1545                    {
     1546                        PCUSTOMBUTTON btnInfo;
     1547                        NMTOOLBARA nmtb;
     1548                        int count;
     1549                        int index;
     1550
     1551                        count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
     1552                        index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
     1553
     1554                        /* send TBN_QUERYINSERT notification */
     1555                        nmtb.iItem = index;
     1556                        TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
     1557                                        TBN_QUERYINSERT);
     1558
     1559                        /* get list box item */
     1560                        btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
     1561
     1562                        if (index == (count - 1))
     1563                        {
     1564                            /* last item (virtual separator) */
     1565                            EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
     1566                            EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
     1567                        }
     1568                        else if (index == (count - 2))
     1569                        {
     1570                            /* second last item (last non-virtual item) */
     1571                            EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
     1572                            EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
     1573                        }
     1574                        else if (index == 0)
     1575                        {
     1576                            /* first item */
     1577                            EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
     1578                            EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
     1579                        }
     1580                        else
     1581                        {
     1582                            EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
     1583                            EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
     1584                        }
     1585
     1586                        EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable);
     1587                    }
     1588                    break;
     1589
     1590                case IDC_MOVEUP_BTN:
     1591                    {
     1592                        PCUSTOMBUTTON btnInfo;
     1593                        int index;
     1594                        int count;
     1595
     1596                        count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
     1597                        index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
     1598                        TRACE("Move up: index %d\n", index);
     1599
     1600                        /* send TBN_QUERYINSERT notification */
     1601                        nmtb.iItem = index;
     1602
     1603                        if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
     1604                                            TBN_QUERYINSERT))
     1605                        {
     1606                            btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
     1607
     1608                            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
     1609                            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0);
     1610                            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo);
     1611                            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0);
     1612
     1613                            if (index <= 1)
     1614                                EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
     1615                            else if (index >= (count - 3))
     1616                                EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
     1617
     1618                            SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
     1619                            SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn));
     1620                        }
     1621                    }
     1622                    break;
     1623
     1624                case IDC_MOVEDN_BTN: /* move down */
     1625                    {
     1626                        PCUSTOMBUTTON btnInfo;
     1627                        int index;
     1628                        int count;
     1629
     1630                        count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
     1631                        index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
     1632                        TRACE("Move up: index %d\n", index);
     1633
     1634                        /* send TBN_QUERYINSERT notification */
     1635                        nmtb.iItem = index;
     1636                        if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
     1637                                            TBN_QUERYINSERT))
     1638                        {
     1639                            btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
     1640
     1641                            /* move button down */
     1642                            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
     1643                            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0);
     1644                            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo);
     1645                            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0);
     1646
     1647                            if (index == 0)
     1648                                EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
     1649                            else if (index >= (count - 3))
     1650                                EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
     1651
     1652                            SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
     1653                            SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn));
     1654                        }
     1655                    }
     1656                    break;
     1657
     1658                case IDC_REMOVE_BTN: /* remove button */
     1659                    {
     1660                        PCUSTOMBUTTON btnInfo;
     1661                        int index;
     1662
     1663                        index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
     1664                        TRACE("Remove: index %d\n", index);
     1665
     1666                        /* send TBN_QUERYDELETE notification */
     1667                        nmtb.iItem = index;
     1668                        if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
     1669                                            TBN_QUERYDELETE))
     1670                        {
     1671                            btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
     1672                            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
     1673                            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0);
     1674
     1675                            SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
     1676
     1677                            /* insert into 'available button' list */
     1678                            if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP))
     1679                            {
     1680                                index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
     1681                                SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1682                            }
     1683                            else
     1684                                COMCTL32_Free (btnInfo);
     1685                        }
     1686                    }
     1687                    break;
     1688
     1689                case IDOK: /* Add button */
     1690                    {
     1691                        int index;
     1692                        int count;
     1693
     1694                        count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
     1695                        index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0);
     1696                        TRACE("Add: index %d\n", index);
     1697
     1698                        /* send TBN_QUERYINSERT notification */
     1699                        nmtb.iItem = index;
     1700                        if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
     1701                                            TBN_QUERYINSERT))
     1702                        {
     1703                            btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0);
     1704
     1705                            if (index != 0)
     1706                            {
     1707                                /* remove from 'available buttons' list */
     1708                                SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0);
     1709                                if (index == count-1)
     1710                                    SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0);
     1711                                else
     1712                                    SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0);
     1713                            }
     1714                            else
     1715                            {
     1716                                PCUSTOMBUTTON btnNew;
     1717
     1718                                /* duplicate 'separator' button */
     1719                                btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON));
     1720                                memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON));
     1721                                btnInfo = btnNew;
     1722                            }
     1723
     1724                            /* insert into 'toolbar button' list */
     1725                            index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
     1726                            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0);
     1727                            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1728
     1729                            SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn));
     1730                        }
     1731                    }
     1732                    break;
     1733
     1734                case IDCANCEL:
     1735                    EndDialog(hwnd, FALSE);
     1736                    break;
     1737            }
     1738            return TRUE;
     1739
     1740        case WM_DESTROY:
     1741            {
     1742                int count;
     1743                int i;
     1744
     1745                /* delete items from 'toolbar buttons' listbox*/
     1746                count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
     1747                for (i = 0; i < count; i++)
     1748                {
     1749                    btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0);
     1750                    COMCTL32_Free(btnInfo);
     1751                    SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0);
     1752                }
     1753                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0);
     1754
     1755
     1756                /* delete items from 'available buttons' listbox*/
     1757                count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
     1758                for (i = 0; i < count; i++)
     1759                {
     1760                    btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0);
     1761                    COMCTL32_Free(btnInfo);
     1762                    SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0);
     1763                }
     1764                SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0);
    11341765            }
    1135             else
    1136             {
    1137             btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
    1138             memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
    1139             if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
    1140                 strcpy (btnInfo->text, nmtb.pszText);
    1141 
    1142             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1143             }
    1144         }
    1145 
    1146         /* select first item in the 'available' list */
    1147         SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0);
    1148 
    1149         /* append 'virtual' separator button to the 'toolbar buttons' list */
    1150         btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
    1151         memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
    1152         btnInfo->btn.fsStyle = TBSTYLE_SEP;
    1153         btnInfo->bVirtual = TRUE;
    1154         btnInfo->bRemovable = FALSE;
    1155         LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
    1156         index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
    1157         SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1158 
    1159         /* select last item in the 'toolbar' list */
    1160         SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0);
    1161         SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0);
    1162 
    1163         /* set focus and disable buttons */
    1164         PostMessageA (hwnd, WM_USER, 0, 0);
    1165         }
    1166         return TRUE;
    1167 
    1168     case WM_USER:
    1169         EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
    1170         EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
    1171         EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE);
    1172         SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX));
    1173         return TRUE;
    1174 
    1175     case WM_CLOSE:
    1176         EndDialog(hwnd, FALSE);
    1177         return TRUE;
    1178 
    1179     case WM_COMMAND:
    1180         switch (LOWORD(wParam))
    1181         {
    1182         case IDC_TOOLBARBTN_LBOX:
    1183             if (HIWORD(wParam) == LBN_SELCHANGE)
    1184             {
    1185             PCUSTOMBUTTON btnInfo;
    1186             NMTOOLBARA nmtb;
    1187             int count;
    1188             int index;
    1189 
    1190             count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
    1191             index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
    1192 
    1193             /* send TBN_QUERYINSERT notification */
    1194             nmtb.hdr.hwndFrom = hwnd;
    1195             nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1196             nmtb.hdr.code     = TBN_QUERYINSERT;
    1197             nmtb.iItem = index;
    1198 
    1199             SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1200                       (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
    1201 
    1202             /* get list box item */
    1203             btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
    1204 
    1205             if (index == (count - 1))
    1206             {
    1207                 /* last item (virtual separator) */
    1208                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
    1209                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
    1210             }
    1211             else if (index == (count - 2))
    1212             {
    1213                 /* second last item (last non-virtual item) */
    1214                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
    1215                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
    1216             }
    1217             else if (index == 0)
    1218             {
    1219                 /* first item */
    1220                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
    1221                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
    1222             }
    1223             else
    1224             {
    1225                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
    1226                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
    1227             }
    1228 
    1229             EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable);
    1230             }
    1231             break;
    1232 
    1233         case IDC_MOVEUP_BTN:
    1234             {
    1235             PCUSTOMBUTTON btnInfo;
    1236             int index;
    1237             int count;
    1238 
    1239             count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
    1240             index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
    1241             TRACE("Move up: index %d\n", index);
    1242 
    1243             /* send TBN_QUERYINSERT notification */
    1244             nmtb.hdr.hwndFrom = hwnd;
    1245             nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1246             nmtb.hdr.code     = TBN_QUERYINSERT;
    1247             nmtb.iItem = index;
    1248 
    1249             if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1250                       (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1251             {
    1252                 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
    1253 
    1254                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
    1255                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0);
    1256                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo);
    1257                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0);
    1258 
    1259                 if (index <= 1)
    1260                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
    1261                 else if (index >= (count - 3))
    1262                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
    1263 
    1264                 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
    1265                 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn));
    1266             }
    1267             }
    1268             break;
    1269 
    1270         case IDC_MOVEDN_BTN: /* move down */
    1271             {
    1272             PCUSTOMBUTTON btnInfo;
    1273             int index;
    1274             int count;
    1275 
    1276             count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
    1277             index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
    1278             TRACE("Move up: index %d\n", index);
    1279 
    1280             /* send TBN_QUERYINSERT notification */
    1281             nmtb.hdr.hwndFrom = hwnd;
    1282             nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1283             nmtb.hdr.code     = TBN_QUERYINSERT;
    1284             nmtb.iItem = index;
    1285 
    1286             if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1287                       (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1288             {
    1289                 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
    1290 
    1291                 /* move button down */
    1292                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
    1293                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0);
    1294                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo);
    1295                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0);
    1296 
    1297                 if (index == 0)
    1298                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
    1299                 else if (index >= (count - 3))
    1300                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
    1301 
    1302                 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
    1303                 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn));
    1304             }
    1305             }
    1306             break;
    1307 
    1308         case IDC_REMOVE_BTN: /* remove button */
    1309             {
    1310             PCUSTOMBUTTON btnInfo;
    1311             int index;
    1312 
    1313             index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
    1314             TRACE("Remove: index %d\n", index);
    1315 
    1316             /* send TBN_QUERYDELETE notification */
    1317             nmtb.hdr.hwndFrom = hwnd;
    1318             nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1319             nmtb.hdr.code     = TBN_QUERYDELETE;
    1320             nmtb.iItem = index;
    1321 
    1322             if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1323                       (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1324             {
    1325                 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
    1326                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
    1327                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0);
    1328 
    1329                 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
    1330 
    1331                 /* insert into 'available button' list */
    1332                 if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP))
    1333                 {
    1334                 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
    1335                 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1336                 }
    1337                 else
    1338                 COMCTL32_Free (btnInfo);
    1339             }
    1340             }
    1341             break;
    1342 
    1343         case IDOK: /* Add button */
    1344             {
    1345             int index;
    1346             int count;
    1347 
    1348             count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
    1349             index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0);
    1350             TRACE("Add: index %d\n", index);
    1351 
    1352             /* send TBN_QUERYINSERT notification */
    1353             nmtb.hdr.hwndFrom = hwnd;
    1354             nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1355             nmtb.hdr.code     = TBN_QUERYINSERT;
    1356             nmtb.iItem = index;
    1357 
    1358             if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1359                       (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1360             {
    1361                 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0);
    1362 
    1363                 if (index != 0)
    1364                 {
    1365                 /* remove from 'available buttons' list */
    1366                 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0);
    1367                 if (index == count-1)
    1368                     SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0);
    1369                 else
    1370                     SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0);
    1371                 }
    1372                 else
    1373                 {
    1374                 PCUSTOMBUTTON btnNew;
    1375 
    1376                 /* duplicate 'separator' button */
    1377                 btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON));
    1378                 memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON));
    1379                 btnInfo = btnNew;
    1380                 }
    1381 
    1382                 /* insert into 'toolbar button' list */
    1383                 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
    1384                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0);
    1385                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1386 
    1387                 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn));
    1388             }
    1389             }
    1390             break;
    1391 
    1392         case IDCANCEL:
    1393             EndDialog(hwnd, FALSE);
    1394             break;
    1395         }
    1396         return TRUE;
    1397 
    1398     case WM_DESTROY:
    1399         {
    1400         int count;
    1401         int i;
    1402 
    1403         /* delete items from 'toolbar buttons' listbox*/
    1404         count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
    1405         for (i = 0; i < count; i++)
    1406         {
    1407             btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0);
    1408             COMCTL32_Free(btnInfo);
    1409             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0);
    1410         }
    1411         SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0);
    1412 
    1413 
    1414         /* delete items from 'available buttons' listbox*/
    1415         count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
    1416         for (i = 0; i < count; i++)
    1417         {
    1418             btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0);
    1419             COMCTL32_Free(btnInfo);
    1420             SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0);
    1421         }
    1422         SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0);
    1423             }
    1424         return TRUE;
    1425 
    1426     case WM_DRAWITEM:
    1427         if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
    1428         {
    1429         LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
    1430         RECT rcButton;
    1431         RECT rcText;
    1432         HPEN hOldPen;
    1433         HBRUSH hOldBrush;
    1434         COLORREF oldText = 0;
    1435         COLORREF oldBk = 0;
    1436 
    1437         /* get item data */
    1438         btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0);
    1439         if (btnInfo == NULL)
    1440         {
    1441             FIXME("btnInfo invalid!\n");
    1442             return TRUE;
    1443         }
    1444 
    1445         /* set colors and select objects */
    1446         oldBk = SetBkColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
    1447         if (btnInfo->bVirtual)
    1448            oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_GRAYTEXT));
    1449         else
    1450            oldText = SetTextColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHTTEXT:COLOR_WINDOWTEXT));
    1451         hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
    1452         hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
    1453 
    1454         /* fill background rectangle */
    1455         Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
    1456                lpdis->rcItem.right, lpdis->rcItem.bottom);
    1457 
    1458         /* calculate button and text rectangles */
    1459         CopyRect (&rcButton, &lpdis->rcItem);
    1460         InflateRect (&rcButton, -1, -1);
    1461         CopyRect (&rcText, &rcButton);
    1462         rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6;
    1463         rcText.left = rcButton.right + 2;
    1464 
    1465         /* draw focus rectangle */
    1466         if (lpdis->itemState & ODS_FOCUS)
    1467             DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
    1468 
    1469         /* draw button */
    1470         DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
    1471 
    1472         /* draw image and text */
    1473         if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0)
    1474             ImageList_Draw (custInfo->tbInfo->himlDef, btnInfo->btn.iBitmap, lpdis->hDC,
    1475                     rcButton.left+3, rcButton.top+3, ILD_NORMAL);
    1476         DrawTextA (lpdis->hDC,  btnInfo->text, -1, &rcText,
    1477                    DT_LEFT | DT_VCENTER | DT_SINGLELINE);
    1478 
    1479         /* delete objects and reset colors */
    1480         SelectObject (lpdis->hDC, hOldBrush);
    1481         SelectObject (lpdis->hDC, hOldPen);
    1482         SetBkColor (lpdis->hDC, oldBk);
    1483         SetTextColor (lpdis->hDC, oldText);
    1484 
    1485         return TRUE;
    1486         }
    1487         return FALSE;
    1488 
    1489     case WM_MEASUREITEM:
    1490         if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
    1491         {
    1492         MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
    1493 
    1494         if (custInfo && custInfo->tbInfo)
    1495             lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8;
    1496         else
    1497             lpmis->itemHeight = 15 + 8; /* default height */
    1498 
    1499         return TRUE;
    1500         }
    1501         return FALSE;
    1502 
    1503     default:
    1504         return FALSE;
     1766            return TRUE;
     1767
     1768        case WM_DRAWITEM:
     1769            if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
     1770            {
     1771                LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
     1772                RECT rcButton;
     1773                RECT rcText;
     1774                HPEN hOldPen;
     1775                HBRUSH hOldBrush;
     1776                COLORREF oldText = 0;
     1777                COLORREF oldBk = 0;
     1778
     1779                /* get item data */
     1780                btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0);
     1781                if (btnInfo == NULL)
     1782                {
     1783                    FIXME("btnInfo invalid!\n");
     1784                    return TRUE;
     1785                }
     1786
     1787                /* set colors and select objects */
     1788                oldBk = SetBkColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
     1789                if (btnInfo->bVirtual)
     1790                   oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_GRAYTEXT));
     1791                else
     1792                   oldText = SetTextColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHTTEXT:COLOR_WINDOWTEXT));
     1793                hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
     1794                hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
     1795
     1796                /* fill background rectangle */
     1797                Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
     1798                           lpdis->rcItem.right, lpdis->rcItem.bottom);
     1799
     1800                /* calculate button and text rectangles */
     1801                CopyRect (&rcButton, &lpdis->rcItem);
     1802                InflateRect (&rcButton, -1, -1);
     1803                CopyRect (&rcText, &rcButton);
     1804                rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6;
     1805                rcText.left = rcButton.right + 2;
     1806
     1807                /* draw focus rectangle */
     1808                if (lpdis->itemState & ODS_FOCUS)
     1809                    DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
     1810
     1811                /* draw button */
     1812                DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
     1813
     1814                /* draw image and text */
     1815                if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0)
     1816                    ImageList_Draw (custInfo->tbInfo->himlDef, btnInfo->btn.iBitmap, lpdis->hDC,
     1817                                    rcButton.left+3, rcButton.top+3, ILD_NORMAL);
     1818                DrawTextA (lpdis->hDC,  btnInfo->text, -1, &rcText,
     1819                               DT_LEFT | DT_VCENTER | DT_SINGLELINE);
     1820
     1821                /* delete objects and reset colors */
     1822                SelectObject (lpdis->hDC, hOldBrush);
     1823                SelectObject (lpdis->hDC, hOldPen);
     1824                SetBkColor (lpdis->hDC, oldBk);
     1825                SetTextColor (lpdis->hDC, oldText);
     1826
     1827                return TRUE;
     1828            }
     1829            return FALSE;
     1830
     1831        case WM_MEASUREITEM:
     1832            if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
     1833            {
     1834                MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
     1835
     1836                if (custInfo && custInfo->tbInfo)
     1837                    lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8;
     1838                else
     1839                    lpmis->itemHeight = 15 + 8; /* default height */
     1840
     1841                return TRUE;
     1842            }
     1843            return FALSE;
     1844
     1845        default:
     1846            return FALSE;
    15051847    }
    15061848}
     
    15211863    TRACE("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam);
    15221864    if (!lpAddBmp)
    1523     return -1;
     1865        return -1;
    15241866
    15251867    if (lpAddBmp->hInst == HINST_COMMCTRL)
    15261868    {
    1527     if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
    1528         nButtons = 15;
    1529     else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
    1530         nButtons = 13;
    1531     else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
    1532         nButtons = 5;
    1533     else
    1534         return -1;
    1535 
    1536     TRACE ("adding %d internal bitmaps!\n", nButtons);
    1537 
    1538     /* Windows resize all the buttons to the size of a newly added standard image */
    1539     if (lpAddBmp->nID & 1)
    1540     {
    1541         /* large icons */
    1542         /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
    1543              * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
     1869        if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
     1870            nButtons = 15;
     1871        else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
     1872            nButtons = 13;
     1873        else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
     1874            nButtons = 5;
     1875        else
     1876            return -1;
     1877
     1878        TRACE ("adding %d internal bitmaps!\n", nButtons);
     1879
     1880        /* Windows resize all the buttons to the size of a newly added standard image */
     1881        if (lpAddBmp->nID & 1)
     1882        {
     1883            /* large icons */
     1884            /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
     1885             * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this 
    15441886             */
    1545         SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
    1546               MAKELPARAM((WORD)24, (WORD)24));
    1547         SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
    1548               MAKELPARAM((WORD)31, (WORD)30));
     1887            SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
     1888                          MAKELPARAM((WORD)24, (WORD)24));
     1889            SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
     1890                          MAKELPARAM((WORD)31, (WORD)30));
     1891        }       
     1892        else
     1893        {
     1894            /* small icons */
     1895            SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
     1896                          MAKELPARAM((WORD)16, (WORD)16));
     1897            SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
     1898                          MAKELPARAM((WORD)22, (WORD)22));
     1899        }
     1900       
     1901        TOOLBAR_CalcToolbar (hwnd);
    15491902    }
    15501903    else
    15511904    {
    1552         /* small icons */
    1553         SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
    1554               MAKELPARAM((WORD)16, (WORD)16));
    1555         SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
    1556               MAKELPARAM((WORD)22, (WORD)22));
    1557     }
    1558 
    1559     TOOLBAR_CalcToolbar (hwnd);
    1560     }
    1561     else
    1562     {
    1563     nButtons = (INT)wParam;
    1564     if (nButtons <= 0)
    1565         return -1;
    1566 
    1567     TRACE ("adding %d bitmaps!\n", nButtons);
    1568     }
    1569 
     1905        nButtons = (INT)wParam;
     1906        if (nButtons <= 0)
     1907            return -1;
     1908       
     1909        TRACE ("adding %d bitmaps!\n", nButtons);
     1910    }
     1911   
    15701912    if (!(infoPtr->himlDef)) {
    1571     /* create new default image list */
    1572     TRACE ("creating default image list!\n");
    1573 
    1574     infoPtr->himlDef =
    1575         ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
    1576                   ILC_COLOR | ILC_MASK, nButtons, 2);
    1577     infoPtr->himlInt = infoPtr->himlDef;
     1913        /* create new default image list */
     1914        TRACE ("creating default image list!\n");
     1915
     1916        infoPtr->himlDef =
     1917            ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
     1918                              ILC_COLOR | ILC_MASK, nButtons, 2);
     1919        infoPtr->himlInt = infoPtr->himlDef;
    15781920    }
    15791921
     
    15831925    if (lpAddBmp->hInst == (HINSTANCE)0)
    15841926    {
    1585     nIndex =
    1586         ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
    1587                 CLR_DEFAULT);
     1927        nIndex =
     1928            ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
     1929                                CLR_DEFAULT);
    15881930    }
    15891931    else if (lpAddBmp->hInst == HINST_COMMCTRL)
    15901932    {
    1591     /* Add system bitmaps */
    1592     switch (lpAddBmp->nID)
     1933        /* Add system bitmaps */
     1934        switch (lpAddBmp->nID)
    15931935    {
    1594         case IDB_STD_SMALL_COLOR:
    1595         hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1596                        MAKEINTRESOURCEA(IDB_STD_SMALL));
    1597         nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1598                           hbmLoad, CLR_DEFAULT);
    1599         DeleteObject (hbmLoad);
    1600         break;
    1601 
    1602         case IDB_STD_LARGE_COLOR:
    1603         hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1604                        MAKEINTRESOURCEA(IDB_STD_LARGE));
    1605         nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1606                           hbmLoad, CLR_DEFAULT);
    1607         DeleteObject (hbmLoad);
    1608         break;
    1609 
    1610         case IDB_VIEW_SMALL_COLOR:
    1611         hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1612                        MAKEINTRESOURCEA(IDB_VIEW_SMALL));
    1613         nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1614                           hbmLoad, CLR_DEFAULT);
    1615         DeleteObject (hbmLoad);
    1616         break;
    1617 
    1618         case IDB_VIEW_LARGE_COLOR:
    1619         hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1620                        MAKEINTRESOURCEA(IDB_VIEW_LARGE));
    1621         nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1622                           hbmLoad, CLR_DEFAULT);
    1623         DeleteObject (hbmLoad);
    1624         break;
    1625 
    1626         case IDB_HIST_SMALL_COLOR:
    1627         hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1628                        MAKEINTRESOURCEA(IDB_HIST_SMALL));
    1629         nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1630                           hbmLoad, CLR_DEFAULT);
    1631         DeleteObject (hbmLoad);
    1632         break;
    1633 
    1634         case IDB_HIST_LARGE_COLOR:
    1635         hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1636                        MAKEINTRESOURCEA(IDB_HIST_LARGE));
    1637         nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1638                           hbmLoad, CLR_DEFAULT);
    1639         DeleteObject (hbmLoad);
    1640         break;
    1641 
    1642         default:
    1643     nIndex = ImageList_GetImageCount (infoPtr->himlDef);
    1644         ERR ("invalid imagelist!\n");
    1645         break;
    1646     }
     1936            case IDB_STD_SMALL_COLOR:
     1937                hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1938                                       MAKEINTRESOURCEA(IDB_STD_SMALL));
     1939                nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1940                                              hbmLoad, CLR_DEFAULT);
     1941                DeleteObject (hbmLoad);
     1942                break;
     1943
     1944            case IDB_STD_LARGE_COLOR:
     1945                hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1946                                       MAKEINTRESOURCEA(IDB_STD_LARGE));
     1947                nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1948                                              hbmLoad, CLR_DEFAULT);
     1949                DeleteObject (hbmLoad);
     1950                break;
     1951
     1952            case IDB_VIEW_SMALL_COLOR:
     1953                hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1954                                       MAKEINTRESOURCEA(IDB_VIEW_SMALL));
     1955                nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1956                                              hbmLoad, CLR_DEFAULT);
     1957                DeleteObject (hbmLoad);
     1958                break;
     1959
     1960            case IDB_VIEW_LARGE_COLOR:
     1961                hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1962                                       MAKEINTRESOURCEA(IDB_VIEW_LARGE));
     1963                nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1964                                              hbmLoad, CLR_DEFAULT);
     1965                DeleteObject (hbmLoad);
     1966                break;
     1967
     1968            case IDB_HIST_SMALL_COLOR:
     1969                hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1970                                       MAKEINTRESOURCEA(IDB_HIST_SMALL));
     1971                nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1972                                              hbmLoad, CLR_DEFAULT);
     1973                DeleteObject (hbmLoad);
     1974                break;
     1975
     1976            case IDB_HIST_LARGE_COLOR:
     1977                hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1978                                       MAKEINTRESOURCEA(IDB_HIST_LARGE));
     1979                nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1980                                              hbmLoad, CLR_DEFAULT);
     1981                DeleteObject (hbmLoad);
     1982                break;
     1983
     1984            default:
     1985        nIndex = ImageList_GetImageCount (infoPtr->himlDef);
     1986                ERR ("invalid imagelist!\n");
     1987                break;
     1988        }
    16471989    }
    16481990    else
    16491991    {
    1650     hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
    1651     nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
    1652     DeleteObject (hbmLoad);
     1992        hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
     1993        nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
     1994        DeleteObject (hbmLoad);
    16531995    }
    16541996
     
    16602002       {
    16612003         WARN("Desired images do not match received images : Previous image number %i Previous images in list %i added %i expecting total %i, Images in list %i\n",
    1662           infoPtr->nNumBitmaps, nCount, imagecount - nCount,
    1663           infoPtr->nNumBitmaps+nButtons,imagecount);
    1664 
    1665     infoPtr->nNumBitmaps = imagecount;
     2004              infoPtr->nNumBitmaps, nCount, imagecount - nCount,
     2005              infoPtr->nNumBitmaps+nButtons,imagecount);
     2006
     2007        infoPtr->nNumBitmaps = imagecount;
    16662008       }
    16672009       else
     
    16892031
    16902032    if (infoPtr->nNumButtons == 0) {
    1691     infoPtr->buttons =
    1692         COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     2033        infoPtr->buttons =
     2034            COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    16932035    }
    16942036    else {
    1695     TBUTTON_INFO *oldButtons = infoPtr->buttons;
    1696     infoPtr->buttons =
    1697         COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    1698     memcpy (&infoPtr->buttons[0], &oldButtons[0],
    1699         nOldButtons * sizeof(TBUTTON_INFO));
     2037        TBUTTON_INFO *oldButtons = infoPtr->buttons;
     2038        infoPtr->buttons =
     2039            COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     2040        memcpy (&infoPtr->buttons[0], &oldButtons[0],
     2041                nOldButtons * sizeof(TBUTTON_INFO));
    17002042        COMCTL32_Free (oldButtons);
    17012043    }
     
    17052047    /* insert new button data */
    17062048    for (nCount = 0; nCount < nAddButtons; nCount++) {
    1707     TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
    1708     btnPtr->iBitmap   = lpTbb[nCount].iBitmap;
    1709     btnPtr->idCommand = lpTbb[nCount].idCommand;
    1710     btnPtr->fsState   = lpTbb[nCount].fsState;
    1711     btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
    1712     btnPtr->dwData    = lpTbb[nCount].dwData;
    1713     btnPtr->iString   = lpTbb[nCount].iString;
    1714     btnPtr->bHot      = FALSE;
    1715 
    1716     if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
    1717         TTTOOLINFOA ti;
    1718 
    1719         ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    1720         ti.cbSize   = sizeof (TTTOOLINFOA);
    1721         ti.hwnd     = hwnd;
    1722         ti.uId      = btnPtr->idCommand;
    1723         ti.hinst    = 0;
    1724         ti.lpszText = LPSTR_TEXTCALLBACKA;
    1725 
    1726         SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
    1727                 0, (LPARAM)&ti);
    1728     }
     2049        TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
     2050        btnPtr->iBitmap   = lpTbb[nCount].iBitmap;
     2051        btnPtr->idCommand = lpTbb[nCount].idCommand;
     2052        btnPtr->fsState   = lpTbb[nCount].fsState;
     2053        btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
     2054        btnPtr->dwData    = lpTbb[nCount].dwData;
     2055        btnPtr->iString   = lpTbb[nCount].iString;
     2056        btnPtr->bHot      = FALSE;
     2057
     2058        if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
     2059            TTTOOLINFOA ti;
     2060
     2061            ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     2062            ti.cbSize   = sizeof (TTTOOLINFOA);
     2063            ti.hwnd     = hwnd;
     2064            ti.uId      = btnPtr->idCommand;
     2065            ti.hinst    = 0;
     2066            ti.lpszText = LPSTR_TEXTCALLBACKA;
     2067
     2068            SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
     2069                            0, (LPARAM)&ti);
     2070        }
    17292071    }
    17302072
     
    17512093
    17522094    if (infoPtr->nNumButtons == 0) {
    1753     infoPtr->buttons =
    1754         COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     2095        infoPtr->buttons =
     2096            COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    17552097    }
    17562098    else {
    1757     TBUTTON_INFO *oldButtons = infoPtr->buttons;
    1758     infoPtr->buttons =
    1759         COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    1760     memcpy (&infoPtr->buttons[0], &oldButtons[0],
    1761         nOldButtons * sizeof(TBUTTON_INFO));
     2099        TBUTTON_INFO *oldButtons = infoPtr->buttons;
     2100        infoPtr->buttons =
     2101            COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     2102        memcpy (&infoPtr->buttons[0], &oldButtons[0],
     2103                nOldButtons * sizeof(TBUTTON_INFO));
    17622104        COMCTL32_Free (oldButtons);
    17632105    }
     
    17672109    /* insert new button data */
    17682110    for (nCount = 0; nCount < nAddButtons; nCount++) {
    1769     TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
    1770     btnPtr->iBitmap   = lpTbb[nCount].iBitmap;
    1771     btnPtr->idCommand = lpTbb[nCount].idCommand;
    1772     btnPtr->fsState   = lpTbb[nCount].fsState;
    1773     btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
    1774     btnPtr->dwData    = lpTbb[nCount].dwData;
    1775     btnPtr->iString   = lpTbb[nCount].iString;
    1776     btnPtr->bHot      = FALSE;
    1777 
    1778     if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
    1779         TTTOOLINFOW ti;
    1780 
    1781         ZeroMemory (&ti, sizeof(TTTOOLINFOW));
    1782         ti.cbSize   = sizeof (TTTOOLINFOW);
    1783         ti.hwnd     = hwnd;
    1784         ti.uId      = btnPtr->idCommand;
    1785         ti.hinst    = 0;
    1786         ti.lpszText = LPSTR_TEXTCALLBACKW;
    1787 
    1788         SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
    1789                 0, (LPARAM)&ti);
    1790     }
     2111        TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
     2112        btnPtr->iBitmap   = lpTbb[nCount].iBitmap;
     2113        btnPtr->idCommand = lpTbb[nCount].idCommand;
     2114        btnPtr->fsState   = lpTbb[nCount].fsState;
     2115        btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
     2116        btnPtr->dwData    = lpTbb[nCount].dwData;
     2117        btnPtr->iString   = lpTbb[nCount].iString;
     2118        btnPtr->bHot      = FALSE;
     2119
     2120        if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
     2121            TTTOOLINFOW ti;
     2122
     2123            ZeroMemory (&ti, sizeof(TTTOOLINFOW));
     2124            ti.cbSize   = sizeof (TTTOOLINFOW);
     2125            ti.hwnd     = hwnd;
     2126            ti.uId      = btnPtr->idCommand;
     2127            ti.hinst    = 0;
     2128            ti.lpszText = LPSTR_TEXTCALLBACKW;
     2129
     2130            SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
     2131                            0, (LPARAM)&ti);
     2132        }
    17912133    }
    17922134
     
    18062148
    18072149    if ((wParam) && (HIWORD(lParam) == 0)) {
    1808     char szString[256];
    1809     INT len, lenW;
    1810     TRACE("adding string from resource!\n");
    1811 
    1812     len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
    1813                  szString, 256);
    1814 
    1815     TRACE("len=%d \"%s\"\n", len, szString);
    1816     nIndex = infoPtr->nNumStrings;
    1817     if (infoPtr->nNumStrings == 0) {
    1818         infoPtr->strings =
    1819         COMCTL32_Alloc (sizeof(LPWSTR));
    1820     }
    1821     else {
    1822         LPWSTR *oldStrings = infoPtr->strings;
    1823         infoPtr->strings =
    1824         COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    1825         memcpy (&infoPtr->strings[0], &oldStrings[0],
    1826             sizeof(LPWSTR) * infoPtr->nNumStrings);
    1827         COMCTL32_Free (oldStrings);
    1828     }
     2150        char szString[256];
     2151        INT len, lenW;
     2152        TRACE("adding string from resource!\n");
     2153
     2154        len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
     2155                             szString, 256);
     2156
     2157        TRACE("len=%d \"%s\"\n", len, szString);
     2158        nIndex = infoPtr->nNumStrings;
     2159        if (infoPtr->nNumStrings == 0) {
     2160            infoPtr->strings =
     2161                COMCTL32_Alloc (sizeof(LPWSTR));
     2162        }
     2163        else {
     2164            LPWSTR *oldStrings = infoPtr->strings;
     2165            infoPtr->strings =
     2166                COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     2167            memcpy (&infoPtr->strings[0], &oldStrings[0],
     2168                    sizeof(LPWSTR) * infoPtr->nNumStrings);
     2169            COMCTL32_Free (oldStrings);
     2170        }
    18292171
    18302172        lenW = MultiByteToWideChar( CP_ACP, 0, szString, -1, NULL, 0 );
     
    18322174        MultiByteToWideChar( CP_ACP, 0, szString, -1,
    18332175                             infoPtr->strings[infoPtr->nNumStrings], lenW );
    1834     infoPtr->nNumStrings++;
     2176        infoPtr->nNumStrings++;
    18352177    }
    18362178    else {
    1837     LPSTR p = (LPSTR)lParam;
    1838     INT len, lenW;
    1839 
    1840     if (p == NULL)
    1841         return -1;
    1842     TRACE("adding string(s) from array!\n");
    1843 
    1844     nIndex = infoPtr->nNumStrings;
    1845     while (*p) {
    1846         len = strlen (p);
    1847         TRACE("len=%d \"%s\"\n", len, p);
    1848 
    1849         if (infoPtr->nNumStrings == 0) {
    1850         infoPtr->strings =
    1851             COMCTL32_Alloc (sizeof(LPWSTR));
    1852         }
    1853         else {
    1854         LPWSTR *oldStrings = infoPtr->strings;
    1855         infoPtr->strings =
    1856             COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    1857         memcpy (&infoPtr->strings[0], &oldStrings[0],
    1858             sizeof(LPWSTR) * infoPtr->nNumStrings);
    1859         COMCTL32_Free (oldStrings);
    1860         }
     2179        LPSTR p = (LPSTR)lParam;
     2180        INT len, lenW;
     2181
     2182        if (p == NULL)
     2183            return -1;
     2184        TRACE("adding string(s) from array!\n");
     2185
     2186        nIndex = infoPtr->nNumStrings;
     2187        while (*p) {
     2188            len = strlen (p);
     2189            TRACE("len=%d \"%s\"\n", len, p);
     2190
     2191            if (infoPtr->nNumStrings == 0) {
     2192                infoPtr->strings =
     2193                    COMCTL32_Alloc (sizeof(LPWSTR));
     2194            }
     2195            else {
     2196                LPWSTR *oldStrings = infoPtr->strings;
     2197                infoPtr->strings =
     2198                    COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     2199                memcpy (&infoPtr->strings[0], &oldStrings[0],
     2200                        sizeof(LPWSTR) * infoPtr->nNumStrings);
     2201                COMCTL32_Free (oldStrings);
     2202            }
    18612203
    18622204            lenW = MultiByteToWideChar( CP_ACP, 0, p, -1, NULL, 0 );
     
    18642206            MultiByteToWideChar( CP_ACP, 0, p, -1,
    18652207                                 infoPtr->strings[infoPtr->nNumStrings], lenW );
    1866         infoPtr->nNumStrings++;
    1867 
    1868         p += (len+1);
    1869     }
     2208            infoPtr->nNumStrings++;
     2209
     2210            p += (len+1);
     2211        }
    18702212    }
    18712213
     
    18822224
    18832225    if ((wParam) && (HIWORD(lParam) == 0)) {
    1884     WCHAR szString[MAX_RESOURCE_STRING_LENGTH];
    1885     INT len;
    1886     TRACE("adding string from resource!\n");
    1887 
    1888     len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
    1889                  szString, MAX_RESOURCE_STRING_LENGTH);
    1890 
    1891     TRACE("len=%d %s\n", len, debugstr_w(szString));
    1892     TRACE("First char: 0x%x\n", *szString);
    1893     if (szString[0] == L'|')
    1894     {
    1895         PWSTR p = szString + 1;
    1896 
    1897         nIndex = infoPtr->nNumStrings;
    1898         while (*p != L'|') {
    1899 
    1900         if (infoPtr->nNumStrings == 0) {
    1901         infoPtr->strings =
    1902             COMCTL32_Alloc (sizeof(LPWSTR));
    1903         }
    1904         else {
    1905         LPWSTR *oldStrings = infoPtr->strings;
    1906         infoPtr->strings =
    1907             COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    1908         memcpy (&infoPtr->strings[0], &oldStrings[0],
    1909             sizeof(LPWSTR) * infoPtr->nNumStrings);
    1910         COMCTL32_Free (oldStrings);
    1911         }
    1912 
    1913         len = COMCTL32_StrChrW (p, L'|') - p;
    1914         TRACE("len=%d %s\n", len, debugstr_w(p));
    1915         infoPtr->strings[infoPtr->nNumStrings] =
    1916         COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
    1917         lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len);
    1918         infoPtr->nNumStrings++;
    1919 
    1920         p += (len+1);
    1921         }
    1922     }
    1923     else
    1924     {
     2226        WCHAR szString[MAX_RESOURCE_STRING_LENGTH];
     2227        INT len;
     2228        TRACE("adding string from resource!\n");
     2229
     2230        len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
     2231                             szString, MAX_RESOURCE_STRING_LENGTH);
     2232
     2233        TRACE("len=%d %s\n", len, debugstr_w(szString));
     2234        TRACE("First char: 0x%x\n", *szString);
     2235        if (szString[0] == L'|')
     2236        {
     2237            PWSTR p = szString + 1;
     2238               
     2239            nIndex = infoPtr->nNumStrings;
     2240            while (*p != L'|') {
     2241
     2242            if (infoPtr->nNumStrings == 0) {
     2243                infoPtr->strings =
     2244                    COMCTL32_Alloc (sizeof(LPWSTR));
     2245            }
     2246            else {
     2247                LPWSTR *oldStrings = infoPtr->strings;
     2248                infoPtr->strings =
     2249                    COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     2250                memcpy (&infoPtr->strings[0], &oldStrings[0],
     2251                        sizeof(LPWSTR) * infoPtr->nNumStrings);
     2252                COMCTL32_Free (oldStrings);
     2253            }
     2254
     2255            len = COMCTL32_StrChrW (p, L'|') - p;
     2256            TRACE("len=%d %s\n", len, debugstr_w(p));
     2257            infoPtr->strings[infoPtr->nNumStrings] =
     2258                COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
     2259            lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len);
     2260            infoPtr->nNumStrings++;
     2261
     2262                p += (len+1);
     2263            }
     2264        }
     2265        else
     2266        {
    19252267            nIndex = infoPtr->nNumStrings;
    19262268            if (infoPtr->nNumStrings == 0) {
     
    19442286    }
    19452287    else {
    1946     LPWSTR p = (LPWSTR)lParam;
    1947     INT len;
    1948 
    1949     if (p == NULL)
    1950         return -1;
    1951     TRACE("adding string(s) from array!\n");
    1952     nIndex = infoPtr->nNumStrings;
    1953     while (*p) {
    1954         len = strlenW (p);
    1955 
    1956         TRACE("len=%d %s\n", len, debugstr_w(p));
    1957         if (infoPtr->nNumStrings == 0) {
    1958         infoPtr->strings =
    1959             COMCTL32_Alloc (sizeof(LPWSTR));
    1960         }
    1961         else {
    1962         LPWSTR *oldStrings = infoPtr->strings;
    1963         infoPtr->strings =
    1964             COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    1965         memcpy (&infoPtr->strings[0], &oldStrings[0],
    1966             sizeof(LPWSTR) * infoPtr->nNumStrings);
    1967         COMCTL32_Free (oldStrings);
    1968         }
    1969 
    1970         infoPtr->strings[infoPtr->nNumStrings] =
    1971         COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
    1972         strcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
    1973         infoPtr->nNumStrings++;
    1974 
    1975         p += (len+1);
    1976     }
     2288        LPWSTR p = (LPWSTR)lParam;
     2289        INT len;
     2290
     2291        if (p == NULL)
     2292            return -1;
     2293        TRACE("adding string(s) from array!\n");
     2294        nIndex = infoPtr->nNumStrings;
     2295        while (*p) {
     2296            len = strlenW (p);
     2297
     2298            TRACE("len=%d %s\n", len, debugstr_w(p));
     2299            if (infoPtr->nNumStrings == 0) {
     2300                infoPtr->strings =
     2301                    COMCTL32_Alloc (sizeof(LPWSTR));
     2302            }
     2303            else {
     2304                LPWSTR *oldStrings = infoPtr->strings;
     2305                infoPtr->strings =
     2306                    COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     2307                memcpy (&infoPtr->strings[0], &oldStrings[0],
     2308                        sizeof(LPWSTR) * infoPtr->nNumStrings);
     2309                COMCTL32_Free (oldStrings);
     2310            }
     2311
     2312            infoPtr->strings[infoPtr->nNumStrings] =
     2313                COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
     2314            strcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
     2315            infoPtr->nNumStrings++;
     2316
     2317            p += (len+1);
     2318        }
    19772319    }
    19782320
     
    20052347
    20062348    if (dwStyle & CCS_NORESIZE) {
    2007     uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
    2008     cx = 0;
    2009     cy = 0;
     2349        uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
     2350        cx = 0;
     2351        cy = 0;
    20102352    }
    20112353    else {
    2012     infoPtr->nWidth = parent_rect.right - parent_rect.left;
    2013     TOOLBAR_CalcToolbar (hwnd);
    2014     InvalidateRect( hwnd, NULL, TRUE );
    2015     cy = infoPtr->nHeight;
    2016     cx = infoPtr->nWidth;
    2017 
    2018     if (dwStyle & CCS_NOMOVEY) {
    2019         GetWindowRect(hwnd, &window_rect);
    2020         ScreenToClient(parent, (LPPOINT)&window_rect.left);
    2021         y = window_rect.top;
    2022     }
     2354        infoPtr->nWidth = parent_rect.right - parent_rect.left;
     2355        TOOLBAR_CalcToolbar (hwnd);
     2356        InvalidateRect( hwnd, NULL, TRUE );
     2357        cy = infoPtr->nHeight;
     2358        cx = infoPtr->nWidth;
     2359
     2360        if (dwStyle & CCS_NOMOVEY) {
     2361                GetWindowRect(hwnd, &window_rect);
     2362                ScreenToClient(parent, (LPPOINT)&window_rect.left);
     2363                y = window_rect.top;
     2364        }
    20232365    }
    20242366
    20252367    if (dwStyle & CCS_NOPARENTALIGN)
    2026     uPosFlags |= SWP_NOMOVE;
     2368        uPosFlags |= SWP_NOMOVE;
    20272369
    20282370    if (!(dwStyle & CCS_NODIVIDER))
    2029     cy += GetSystemMetrics(SM_CYEDGE);
     2371        cy += GetSystemMetrics(SM_CYEDGE);
    20302372
    20312373    if (dwStyle & WS_BORDER)
     
    20622404
    20632405    if (infoPtr == NULL) {
    2064     ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
    2065     ERR("infoPtr == NULL!\n");
    2066     return 0;
     2406        ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
     2407        ERR("infoPtr == NULL!\n");
     2408        return 0;
    20672409    }
    20682410
     
    20822424    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    20832425    if (nIndex == -1)
    2084     return FALSE;
     2426        return FALSE;
    20852427
    20862428    btnPtr = &infoPtr->buttons[nIndex];
     
    21062448    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    21072449    if (nIndex == -1)
    2108     return FALSE;
     2450        return FALSE;
    21092451
    21102452    btnPtr = &infoPtr->buttons[nIndex];
    21112453
    21122454    if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
    2113     return FALSE;
     2455        return FALSE;
    21142456
    21152457    bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE;
    21162458
    21172459    if (LOWORD(lParam) == FALSE)
    2118     btnPtr->fsState &= ~TBSTATE_CHECKED;
     2460        btnPtr->fsState &= ~TBSTATE_CHECKED;
    21192461    else {
    2120     if (btnPtr->fsStyle & TBSTYLE_GROUP) {
    2121         nOldIndex =
    2122         TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
    2123         if (nOldIndex == nIndex)
    2124         return 0;
    2125         if (nOldIndex != -1)
    2126         infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
    2127     }
    2128     btnPtr->fsState |= TBSTATE_CHECKED;
     2462        if (btnPtr->fsStyle & TBSTYLE_GROUP) {
     2463            nOldIndex =
     2464                TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
     2465            if (nOldIndex == nIndex)
     2466                return 0;
     2467            if (nOldIndex != -1)
     2468                infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
     2469        }
     2470        btnPtr->fsState |= TBSTATE_CHECKED;
    21292471    }
    21302472
    21312473    if( bChecked != LOWORD(lParam) )
    21322474    {
    2133     if (nOldIndex != -1)
     2475        if (nOldIndex != -1)
    21342476        {
    21352477            InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
     
    21572499TOOLBAR_Customize (HWND hwnd)
    21582500{
     2501    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    21592502    CUSTDLG_INFO custInfo;
    21602503    LRESULT ret;
     
    21632506    NMHDR nmhdr;
    21642507
    2165     custInfo.tbInfo = TOOLBAR_GetInfoPtr (hwnd);
     2508    custInfo.tbInfo = infoPtr;
    21662509    custInfo.tbHwnd = hwnd;
    21672510
    21682511    /* send TBN_BEGINADJUST notification */
    2169     nmhdr.hwndFrom = hwnd;
    2170     nmhdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    2171     nmhdr.code     = TBN_BEGINADJUST;
    2172 
    2173     SendMessageA (custInfo.tbInfo->hwndNotify, WM_NOTIFY,
    2174           (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
     2512    TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
     2513                    TBN_BEGINADJUST);
    21752514
    21762515    if (!(hRes = FindResourceA (COMCTL32_hModule,
    21772516                                MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
    21782517                                RT_DIALOGA)))
    2179     return FALSE;
     2518        return FALSE;
    21802519
    21812520    if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
    2182     return FALSE;
     2521        return FALSE;
    21832522
    21842523    ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
     
    21892528
    21902529    /* send TBN_ENDADJUST notification */
    2191     nmhdr.code = TBN_ENDADJUST;
    2192     SendMessageA (custInfo.tbInfo->hwndNotify, WM_NOTIFY,
    2193           (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
     2530    TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
     2531                    TBN_ENDADJUST);
    21942532
    21952533    return ret;
     
    22042542
    22052543    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    2206     return FALSE;
    2207 
    2208     if ((infoPtr->hwndToolTip) &&
    2209     !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
    2210     TTTOOLINFOA ti;
    2211 
    2212     ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    2213     ti.cbSize   = sizeof (TTTOOLINFOA);
    2214     ti.hwnd     = hwnd;
    2215     ti.uId      = infoPtr->buttons[nIndex].idCommand;
    2216 
    2217     SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
     2544        return FALSE;
     2545
     2546    if ((infoPtr->hwndToolTip) && 
     2547        !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
     2548        TTTOOLINFOA ti;
     2549
     2550        ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     2551        ti.cbSize   = sizeof (TTTOOLINFOA);
     2552        ti.hwnd     = hwnd;
     2553        ti.uId      = infoPtr->buttons[nIndex].idCommand;
     2554
     2555        SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
    22182556    }
    22192557
    22202558    if (infoPtr->nNumButtons == 1) {
    2221     TRACE(" simple delete!\n");
    2222     COMCTL32_Free (infoPtr->buttons);
    2223     infoPtr->buttons = NULL;
    2224     infoPtr->nNumButtons = 0;
     2559        TRACE(" simple delete!\n");
     2560        COMCTL32_Free (infoPtr->buttons);
     2561        infoPtr->buttons = NULL;
     2562        infoPtr->nNumButtons = 0;
    22252563    }
    22262564    else {
    2227     TBUTTON_INFO *oldButtons = infoPtr->buttons;
     2565        TBUTTON_INFO *oldButtons = infoPtr->buttons;
    22282566        TRACE("complex delete! [nIndex=%d]\n", nIndex);
    22292567
    2230     infoPtr->nNumButtons--;
    2231     infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
     2568        infoPtr->nNumButtons--;
     2569        infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
    22322570        if (nIndex > 0) {
    22332571            memcpy (&infoPtr->buttons[0], &oldButtons[0],
     
    22402578        }
    22412579
    2242     COMCTL32_Free (oldButtons);
     2580        COMCTL32_Free (oldButtons);
    22432581    }
    22442582
     
    22612599    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    22622600    if (nIndex == -1)
    2263     return FALSE;
     2601        return FALSE;
    22642602
    22652603    btnPtr = &infoPtr->buttons[nIndex];
     
    22692607    /* update the toolbar button state */
    22702608    if(LOWORD(lParam) == FALSE) {
    2271     btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
     2609        btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
    22722610    } else {
    2273     btnPtr->fsState |= TBSTATE_ENABLED;
     2611        btnPtr->fsState |= TBSTATE_ENABLED;
    22742612    }
    22752613
     
    23022640    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    23032641    if (nIndex == -1)
    2304     return -1;
     2642        return -1;
    23052643
    23062644    return infoPtr->buttons[nIndex].iBitmap;
     
    23242662
    23252663    if (infoPtr == NULL)
    2326     return FALSE;
     2664        return FALSE;
    23272665
    23282666    if (lpTbb == NULL)
    2329     return FALSE;
     2667        return FALSE;
    23302668
    23312669    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    2332     return FALSE;
     2670        return FALSE;
    23332671
    23342672    btnPtr = &infoPtr->buttons[nIndex];
     
    23532691
    23542692    if (infoPtr == NULL)
    2355     return -1;
     2693        return -1;
    23562694    if (lpTbInfo == NULL)
    2357     return -1;
     2695        return -1;
    23582696    if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
    2359     return -1;
     2697        return -1;
    23602698
    23612699    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    23622700    if (nIndex == -1)
    2363     return -1;
     2701        return -1;
    23642702
    23652703    btnPtr = &infoPtr->buttons[nIndex];
    23662704
    23672705    if (lpTbInfo->dwMask & TBIF_COMMAND)
    2368     lpTbInfo->idCommand = btnPtr->idCommand;
     2706        lpTbInfo->idCommand = btnPtr->idCommand;
    23692707    if (lpTbInfo->dwMask & TBIF_IMAGE)
    2370     lpTbInfo->iImage = btnPtr->iBitmap;
     2708        lpTbInfo->iImage = btnPtr->iBitmap;
    23712709    if (lpTbInfo->dwMask & TBIF_LPARAM)
    2372     lpTbInfo->lParam = btnPtr->dwData;
     2710        lpTbInfo->lParam = btnPtr->dwData;
    23732711    if (lpTbInfo->dwMask & TBIF_SIZE)
    2374     lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
     2712        lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
    23752713    if (lpTbInfo->dwMask & TBIF_STATE)
    2376     lpTbInfo->fsState = btnPtr->fsState;
     2714        lpTbInfo->fsState = btnPtr->fsState;
    23772715    if (lpTbInfo->dwMask & TBIF_STYLE)
    2378     lpTbInfo->fsStyle = btnPtr->fsStyle;
     2716        lpTbInfo->fsStyle = btnPtr->fsStyle;
    23792717     if (lpTbInfo->dwMask & TBIF_TEXT) {
    23802718         if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
    2381          {
     2719         {     
    23822720             if (!WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[btnPtr->iString], -1,
    23832721                                       lpTbInfo->pszText, lpTbInfo->cchText, NULL, NULL ))
     
    23992737
    24002738    if (infoPtr == NULL)
    2401     return -1;
     2739        return -1;
    24022740    if (lpTbInfo == NULL)
    2403     return -1;
     2741        return -1;
    24042742    if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
    2405     return -1;
     2743        return -1;
    24062744
    24072745    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    24082746    if (nIndex == -1)
    2409     return -1;
     2747        return -1;
    24102748
    24112749    btnPtr = &infoPtr->buttons[nIndex];
    24122750
    24132751    if (lpTbInfo->dwMask & TBIF_COMMAND)
    2414     lpTbInfo->idCommand = btnPtr->idCommand;
     2752        lpTbInfo->idCommand = btnPtr->idCommand;
    24152753    if (lpTbInfo->dwMask & TBIF_IMAGE)
    2416     lpTbInfo->iImage = btnPtr->iBitmap;
     2754        lpTbInfo->iImage = btnPtr->iBitmap;
    24172755    if (lpTbInfo->dwMask & TBIF_LPARAM)
    2418     lpTbInfo->lParam = btnPtr->dwData;
     2756        lpTbInfo->lParam = btnPtr->dwData;
    24192757    if (lpTbInfo->dwMask & TBIF_SIZE)
    2420     lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
     2758        lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
    24212759    if (lpTbInfo->dwMask & TBIF_STATE)
    2422     lpTbInfo->fsState = btnPtr->fsState;
     2760        lpTbInfo->fsState = btnPtr->fsState;
    24232761    if (lpTbInfo->dwMask & TBIF_STYLE)
    2424     lpTbInfo->fsStyle = btnPtr->fsStyle;
     2762        lpTbInfo->fsStyle = btnPtr->fsStyle;
    24252763    if (lpTbInfo->dwMask & TBIF_TEXT) {
    2426     if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
    2427         lstrcpynW (lpTbInfo->pszText,
    2428                (LPWSTR)infoPtr->strings[btnPtr->iString],
    2429                lpTbInfo->cchText);
     2764        if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
     2765            lstrcpynW (lpTbInfo->pszText,
     2766                       (LPWSTR)infoPtr->strings[btnPtr->iString],
     2767                       lpTbInfo->cchText);
    24302768    }
    24312769
     
    24392777    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    24402778
    2441     return MAKELONG((WORD)infoPtr->nButtonWidth,
    2442             (WORD)infoPtr->nButtonHeight);
     2779    if (infoPtr->nNumButtons > 0)
     2780        return MAKELONG((WORD)infoPtr->nButtonWidth,
     2781                        (WORD)infoPtr->nButtonHeight);
     2782    else
     2783        return MAKELONG(8,7);
    24432784}
    24442785
     
    24522793    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    24532794    if (nIndex == -1)
    2454     return -1;
     2795        return -1;
    24552796
    24562797    nStringIndex = infoPtr->buttons[nIndex].iString;
     
    24592800
    24602801    if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
    2461     return -1;
     2802        return -1;
    24622803
    24632804    if (lParam == 0)
    2464     return -1;
     2805        return -1;
    24652806
    24662807    return WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[nStringIndex], -1,
     
    24772818    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    24782819    if (nIndex == -1)
    2479     return -1;
     2820        return -1;
    24802821
    24812822    nStringIndex = infoPtr->buttons[nIndex].iString;
     
    24842825
    24852826    if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
    2486     return -1;
     2827        return -1;
    24872828
    24882829    if (lParam == 0)
    2489     return -1;
     2830        return -1;
    24902831
    24912832    strcpyW ((LPWSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]);
     
    25312872
    25322873    if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
    2533     return -1;
     2874        return -1;
    25342875
    25352876    if (infoPtr->nHotItem < 0)
    2536     return -1;
     2877        return -1;
    25372878
    25382879    return (LRESULT)infoPtr->nHotItem;
     
    25622903
    25632904    if (infoPtr == NULL)
    2564     return FALSE;
     2905        return FALSE;
    25652906    nIndex = (INT)wParam;
    25662907    btnPtr = &infoPtr->buttons[nIndex];
    25672908    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    2568     return FALSE;
     2909        return FALSE;
    25692910    lpRect = (LPRECT)lParam;
    25702911    if (lpRect == NULL)
    2571     return FALSE;
     2912        return FALSE;
    25722913    if (btnPtr->fsState & TBSTATE_HIDDEN)
    2573     return FALSE;
    2574 
     2914        return FALSE;
     2915   
    25752916    lpRect->left   = btnPtr->rect.left;
    25762917    lpRect->right  = btnPtr->rect.right;
     
    25892930
    25902931    if (lpSize == NULL)
    2591     return FALSE;
     2932        return FALSE;
    25922933
    25932934    lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
     
    25952936
    25962937    TRACE("maximum size %d x %d\n",
    2597        infoPtr->rcBound.right - infoPtr->rcBound.left,
    2598        infoPtr->rcBound.bottom - infoPtr->rcBound.top);
     2938           infoPtr->rcBound.right - infoPtr->rcBound.left,
     2939           infoPtr->rcBound.bottom - infoPtr->rcBound.top);
    25992940
    26002941    return TRUE;
     
    26152956
    26162957    if (infoPtr == NULL)
    2617     return FALSE;
     2958        return FALSE;
    26182959    nIndex = (INT)wParam;
    26192960    btnPtr = &infoPtr->buttons[nIndex];
    26202961    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    2621     return FALSE;
     2962        return FALSE;
    26222963    lpRect = (LPRECT)lParam;
    26232964    if (lpRect == NULL)
    2624     return FALSE;
    2625 
     2965        return FALSE;
     2966   
    26262967    lpRect->left   = btnPtr->rect.left;
    26272968    lpRect->right  = btnPtr->rect.right;
     
    26392980
    26402981    if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
    2641     return infoPtr->nRows;
     2982        return infoPtr->nRows;
    26422983    else
    2643     return 1;
     2984        return 1;
    26442985}
    26452986
     
    26532994    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    26542995    if (nIndex == -1)
    2655     return -1;
     2996        return -1;
    26562997
    26572998    return infoPtr->buttons[nIndex].fsState;
     
    26673008    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    26683009    if (nIndex == -1)
    2669     return -1;
     3010        return -1;
    26703011
    26713012    return infoPtr->buttons[nIndex].fsStyle;
     
    26793020
    26803021    if (infoPtr == NULL)
    2681     return 0;
     3022        return 0;
    26823023
    26833024    return infoPtr->nMaxTextRows;
     
    26913032
    26923033    if (infoPtr == NULL)
    2693     return 0;
     3034        return 0;
    26943035    return infoPtr->hwndToolTip;
    26953036}
     
    27013042    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    27023043
    2703     TRACE("%s hwnd=0x%x stub!\n",
    2704        infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
     3044    TRACE("%s hwnd=0x%x stub!\n", 
     3045           infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
    27053046
    27063047    return infoPtr->bUnicode;
     
    27273068    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    27283069    if (nIndex == -1)
    2729     return FALSE;
     3070        return FALSE;
    27303071
    27313072    btnPtr = &infoPtr->buttons[nIndex];
    27323073    if (LOWORD(lParam) == FALSE)
    2733     btnPtr->fsState &= ~TBSTATE_HIDDEN;
     3074        btnPtr->fsState &= ~TBSTATE_HIDDEN;
    27343075    else
    2735     btnPtr->fsState |= TBSTATE_HIDDEN;
     3076        btnPtr->fsState |= TBSTATE_HIDDEN;
    27363077
    27373078    TOOLBAR_CalcToolbar (hwnd);
     
    27593100    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    27603101    if (nIndex == -1)
    2761     return FALSE;
     3102        return FALSE;
    27623103
    27633104    btnPtr = &infoPtr->buttons[nIndex];
    27643105    if (LOWORD(lParam) == FALSE)
    2765     btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
     3106        btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
    27663107    else
    2767     btnPtr->fsState |= TBSTATE_INDETERMINATE;
     3108        btnPtr->fsState |= TBSTATE_INDETERMINATE;
    27683109
    27693110    InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
     
    27823123
    27833124    if (lpTbb == NULL)
    2784     return FALSE;
     3125        return FALSE;
     3126
     3127    TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE);
    27853128
    27863129    if (nIndex == -1) {
    27873130       /* EPP: this seems to be an undocumented call (from my IE4)
    2788     * I assume in that case that:
    2789     * - lpTbb->iString is a string pointer (not a string index in strings[] table
    2790     * - index of insertion is at the end of existing buttons
    2791     * I only see this happen with nIndex == -1, but it could have a special
    2792     * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
    2793     */
    2794        int  len;
    2795        LPSTR    ptr;
     3131        * I assume in that case that:
     3132        * - lpTbb->iString is a string pointer (not a string index in strings[] table
     3133        * - index of insertion is at the end of existing buttons
     3134        * I only see this happen with nIndex == -1, but it could have a special
     3135        * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
     3136        */
     3137       int      len;
     3138       LPSTR    ptr;
    27963139
    27973140       /* FIXME: iString == -1 is undocumented */
     
    28153158    TRACE("inserting button index=%d\n", nIndex);
    28163159    if (nIndex > infoPtr->nNumButtons) {
    2817     nIndex = infoPtr->nNumButtons;
    2818     TRACE("adjust index=%d\n", nIndex);
     3160        nIndex = infoPtr->nNumButtons;
     3161        TRACE("adjust index=%d\n", nIndex);
    28193162    }
    28203163
     
    28243167    /* pre insert copy */
    28253168    if (nIndex > 0) {
    2826     memcpy (&infoPtr->buttons[0], &oldButtons[0],
    2827         nIndex * sizeof(TBUTTON_INFO));
     3169        memcpy (&infoPtr->buttons[0], &oldButtons[0],
     3170                nIndex * sizeof(TBUTTON_INFO));
    28283171    }
    28293172
     
    28373180
    28383181    if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
    2839     TTTOOLINFOA ti;
    2840 
    2841     ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    2842     ti.cbSize   = sizeof (TTTOOLINFOA);
    2843     ti.hwnd     = hwnd;
    2844     ti.uId      = lpTbb->idCommand;
    2845     ti.hinst    = 0;
    2846     ti.lpszText = LPSTR_TEXTCALLBACKA;
    2847 
    2848     SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
    2849             0, (LPARAM)&ti);
     3182        TTTOOLINFOA ti;
     3183
     3184        ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     3185        ti.cbSize   = sizeof (TTTOOLINFOA);
     3186        ti.hwnd     = hwnd;
     3187        ti.uId      = lpTbb->idCommand;
     3188        ti.hinst    = 0;
     3189        ti.lpszText = LPSTR_TEXTCALLBACKA;
     3190
     3191        SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
     3192                        0, (LPARAM)&ti);
    28503193    }
    28513194
    28523195    /* post insert copy */
    28533196    if (nIndex < infoPtr->nNumButtons - 1) {
    2854     memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
    2855         (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
     3197        memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
     3198                (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
    28563199    }
    28573200
     
    28753218
    28763219    if (lpTbb == NULL)
    2877     return FALSE;
     3220        return FALSE;
    28783221    if (nIndex < 0)
    2879     return FALSE;
     3222        return FALSE;
    28803223
    28813224    TRACE("inserting button index=%d\n", nIndex);
    28823225    if (nIndex > infoPtr->nNumButtons) {
    2883     nIndex = infoPtr->nNumButtons;
    2884     TRACE("adjust index=%d\n", nIndex);
     3226        nIndex = infoPtr->nNumButtons;
     3227        TRACE("adjust index=%d\n", nIndex);
    28853228    }
    28863229
     
    28903233    /* pre insert copy */
    28913234    if (nIndex > 0) {
    2892     memcpy (&infoPtr->buttons[0], &oldButtons[0],
    2893         nIndex * sizeof(TBUTTON_INFO));
     3235        memcpy (&infoPtr->buttons[0], &oldButtons[0],
     3236                nIndex * sizeof(TBUTTON_INFO));
    28943237    }
    28953238
     
    29033246
    29043247    if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
    2905     TTTOOLINFOW ti;
    2906 
    2907     ZeroMemory (&ti, sizeof(TTTOOLINFOW));
    2908     ti.cbSize   = sizeof (TTTOOLINFOW);
    2909     ti.hwnd     = hwnd;
    2910     ti.uId      = lpTbb->idCommand;
    2911     ti.hinst    = 0;
    2912     ti.lpszText = LPSTR_TEXTCALLBACKW;
    2913 
    2914     SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
    2915             0, (LPARAM)&ti);
     3248        TTTOOLINFOW ti;
     3249
     3250        ZeroMemory (&ti, sizeof(TTTOOLINFOW));
     3251        ti.cbSize   = sizeof (TTTOOLINFOW);
     3252        ti.hwnd     = hwnd;
     3253        ti.uId      = lpTbb->idCommand;
     3254        ti.hinst    = 0;
     3255        ti.lpszText = LPSTR_TEXTCALLBACKW;
     3256
     3257        SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
     3258                        0, (LPARAM)&ti);
    29163259    }
    29173260
    29183261    /* post insert copy */
    29193262    if (nIndex < infoPtr->nNumButtons - 1) {
    2920     memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
    2921         (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
     3263        memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
     3264                (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
    29223265    }
    29233266
     
    29413284    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    29423285    if (nIndex == -1)
    2943     return FALSE;
     3286        return FALSE;
    29443287
    29453288    return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
     
    29553298    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    29563299    if (nIndex == -1)
    2957     return FALSE;
     3300        return FALSE;
    29583301
    29593302    return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
     
    29693312    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    29703313    if (nIndex == -1)
    2971     return TRUE;
     3314        return TRUE;
    29723315
    29733316    return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
     
    29833326    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    29843327    if (nIndex == -1)
    2985     return FALSE;
     3328        return FALSE;
    29863329
    29873330    return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
     
    29973340    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    29983341    if (nIndex == -1)
    2999     return FALSE;
     3342        return FALSE;
    30003343
    30013344    return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
     
    30113354    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    30123355    if (nIndex == -1)
    3013     return FALSE;
     3356        return FALSE;
    30143357
    30153358    return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
     
    30323375    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    30333376    if (nIndex == -1)
    3034     return FALSE;
     3377        return FALSE;
    30353378
    30363379    btnPtr = &infoPtr->buttons[nIndex];
    30373380    if (LOWORD(lParam) == FALSE)
    3038     btnPtr->fsState &= ~TBSTATE_PRESSED;
     3381        btnPtr->fsState &= ~TBSTATE_PRESSED;
    30393382    else
    3040     btnPtr->fsState |= TBSTATE_PRESSED;
     3383        btnPtr->fsState |= TBSTATE_PRESSED;
    30413384
    30423385    InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
     
    30593402
    30603403    if ((BOOL)wParam) {
    3061     /* save toolbar information */
    3062     FIXME("save to \"%s\" \"%s\"\n",
    3063            lpSave->pszSubKey, lpSave->pszValueName);
     3404        /* save toolbar information */
     3405        FIXME("save to \"%s\" \"%s\"\n",
     3406               lpSave->pszSubKey, lpSave->pszValueName);
    30643407
    30653408
    30663409    }
    30673410    else {
    3068     /* restore toolbar information */
    3069 
    3070     FIXME("restore from \"%s\" \"%s\"\n",
    3071            lpSave->pszSubKey, lpSave->pszValueName);
     3411        /* restore toolbar information */
     3412
     3413        FIXME("restore from \"%s\" \"%s\"\n",
     3414               lpSave->pszSubKey, lpSave->pszValueName);
    30723415
    30733416
     
    30873430
    30883431    if (lpSave == NULL)
     3432        return 0;
     3433
     3434    if ((BOOL)wParam) {
     3435        /* save toolbar information */
     3436        FIXME("save to \"%s\" \"%s\"\n",
     3437               lpSave->pszSubKey, lpSave->pszValueName);
     3438
     3439
     3440    }
     3441    else {
     3442        /* restore toolbar information */
     3443
     3444        FIXME("restore from \"%s\" \"%s\"\n",
     3445               lpSave->pszSubKey, lpSave->pszValueName);
     3446
     3447
     3448    }
     3449#endif
     3450
    30893451    return 0;
    3090 
    3091     if ((BOOL)wParam) {
    3092     /* save toolbar information */
    3093     FIXME("save to \"%s\" \"%s\"\n",
    3094            lpSave->pszSubKey, lpSave->pszValueName);
    3095 
    3096 
    3097     }
    3098     else {
    3099     /* restore toolbar information */
    3100 
    3101     FIXME("restore from \"%s\" \"%s\"\n",
    3102            lpSave->pszSubKey, lpSave->pszValueName);
    3103 
    3104 
    3105     }
    3106 #endif
    3107 
    3108     return 0;
    31093452}
    31103453
     
    31283471
    31293472    if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
    3130     return FALSE;
     3473        return FALSE;
    31313474
    31323475    if (infoPtr->nNumButtons > 0)
     
    31583501
    31593502    if (lptbbi == NULL)
    3160     return FALSE;
     3503        return FALSE;
    31613504    if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
    3162     return FALSE;
    3163 
     3505        return FALSE;
     3506   
    31643507    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    31653508    if (nIndex == -1)
    3166     return FALSE;
     3509        return FALSE;
    31673510
    31683511    btnPtr = &infoPtr->buttons[nIndex];
    31693512    if (lptbbi->dwMask & TBIF_COMMAND)
    3170     btnPtr->idCommand = lptbbi->idCommand;
     3513        btnPtr->idCommand = lptbbi->idCommand;
    31713514    if (lptbbi->dwMask & TBIF_IMAGE)
    3172     btnPtr->iBitmap = lptbbi->iImage;
     3515        btnPtr->iBitmap = lptbbi->iImage;
    31733516    if (lptbbi->dwMask & TBIF_LPARAM)
    3174     btnPtr->dwData = lptbbi->lParam;
     3517        btnPtr->dwData = lptbbi->lParam;
    31753518/*    if (lptbbi->dwMask & TBIF_SIZE) */
    3176 /*  btnPtr->cx = lptbbi->cx; */
     3519/*      btnPtr->cx = lptbbi->cx; */
    31773520    if (lptbbi->dwMask & TBIF_STATE)
    3178     btnPtr->fsState = lptbbi->fsState;
     3521        btnPtr->fsState = lptbbi->fsState;
    31793522    if (lptbbi->dwMask & TBIF_STYLE)
    3180     btnPtr->fsStyle = lptbbi->fsStyle;
     3523        btnPtr->fsStyle = lptbbi->fsStyle;
    31813524
    31823525    if (lptbbi->dwMask & TBIF_TEXT) {
    3183     if ((btnPtr->iString >= 0) ||
    3184         (btnPtr->iString < infoPtr->nNumStrings)) {
    3185        TRACE("Ooooooch\n");
     3526        if ((btnPtr->iString >= 0) ||
     3527            (btnPtr->iString < infoPtr->nNumStrings)) {
     3528           TRACE("Ooooooch\n");
    31863529#if 0
    3187         WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
    3188         INT len = lstrlenA (lptbbi->pszText);
    3189         *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
     3530            WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
     3531            INT len = lstrlenA (lptbbi->pszText);
     3532            *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
    31903533#endif
    31913534
    3192         /* this is the ultimate sollution */
    3193 /*      Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
    3194     }
     3535            /* this is the ultimate sollution */
     3536/*          Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
     3537        }
    31953538    }
    31963539
     
    32083551
    32093552    if (lptbbi == NULL)
    3210     return FALSE;
     3553        return FALSE;
    32113554    if (lptbbi->cbSize < sizeof(TBBUTTONINFOW))
    3212     return FALSE;
     3555        return FALSE;
    32133556
    32143557    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    32153558    if (nIndex == -1)
    3216     return FALSE;
     3559        return FALSE;
    32173560
    32183561    btnPtr = &infoPtr->buttons[nIndex];
    32193562    if (lptbbi->dwMask & TBIF_COMMAND)
    3220     btnPtr->idCommand = lptbbi->idCommand;
     3563        btnPtr->idCommand = lptbbi->idCommand;
    32213564    if (lptbbi->dwMask & TBIF_IMAGE)
    3222     btnPtr->iBitmap = lptbbi->iImage;
     3565        btnPtr->iBitmap = lptbbi->iImage;
    32233566    if (lptbbi->dwMask & TBIF_LPARAM)
    3224     btnPtr->dwData = lptbbi->lParam;
     3567        btnPtr->dwData = lptbbi->lParam;
    32253568/*    if (lptbbi->dwMask & TBIF_SIZE) */
    3226 /*  btnPtr->cx = lptbbi->cx; */
     3569/*      btnPtr->cx = lptbbi->cx; */
    32273570    if (lptbbi->dwMask & TBIF_STATE)
    3228     btnPtr->fsState = lptbbi->fsState;
     3571        btnPtr->fsState = lptbbi->fsState;
    32293572    if (lptbbi->dwMask & TBIF_STYLE)
    3230     btnPtr->fsStyle = lptbbi->fsStyle;
     3573        btnPtr->fsStyle = lptbbi->fsStyle;
    32313574
    32323575    if (lptbbi->dwMask & TBIF_TEXT) {
    3233     if ((btnPtr->iString >= 0) ||
    3234         (btnPtr->iString < infoPtr->nNumStrings)) {
     3576        if ((btnPtr->iString >= 0) ||
     3577            (btnPtr->iString < infoPtr->nNumStrings)) {
    32353578#if 0
    3236         WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
    3237         INT len = lstrlenW (lptbbi->pszText);
    3238         *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
     3579            WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
     3580            INT len = lstrlenW (lptbbi->pszText);
     3581            *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
    32393582#endif
    32403583
    3241         /* this is the ultimate solution */
    3242 /*      Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
    3243     }
     3584            /* this is the ultimate solution */
     3585/*          Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
     3586        }
    32443587    }
    32453588
     
    32563599    {
    32573600        ERR("invalid parameter\n");
    3258     return FALSE;
     3601        return FALSE;
    32593602    }
    32603603
    32613604    /* The documentation claims you can only change the button size before
    3262      * any button has been added. But this is wrong.
    3263      * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
     3605     * any button has been added. But this is wrong. 
     3606     * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding 
    32643607     * it to the toolbar, and it checks that the return value is nonzero - mjm
    32653608     * Further testing shows that we must actually perform the change too.
     
    32773620
    32783621    if (infoPtr == NULL) {
    3279     TRACE("Toolbar not initialized yet?????\n");
    3280     return FALSE;
     3622        TRACE("Toolbar not initialized yet?????\n");
     3623        return FALSE;
    32813624    }
    32823625
    32833626    /* if setting to current values, ignore */
    32843627    if ((infoPtr->cxMin == (INT)LOWORD(lParam)) &&
    3285     (infoPtr->cxMax == (INT)HIWORD(lParam))) {
    3286     TRACE("matches current width, min=%d, max=%d, no recalc\n",
    3287           infoPtr->cxMin, infoPtr->cxMax);
    3288     return TRUE;
     3628        (infoPtr->cxMax == (INT)HIWORD(lParam))) {
     3629        TRACE("matches current width, min=%d, max=%d, no recalc\n",
     3630              infoPtr->cxMin, infoPtr->cxMax);
     3631        return TRUE;
    32893632    }
    32903633
     
    32953638    /* if both values are 0 then we are done */
    32963639    if (lParam == 0) {
    3297     TRACE("setting both min and max to 0, norecalc\n");
    3298     return TRUE;
     3640        TRACE("setting both min and max to 0, norecalc\n");
     3641        return TRUE;
    32993642    }
    33003643
     
    33023645       recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
    33033646       which doesn't actually draw - GA). */
    3304     TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
    3305     infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax);
     3647    TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n", 
     3648        infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax);
    33063649
    33073650    TOOLBAR_CalcToolbar (hwnd);
     
    33203663
    33213664    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    3322     return FALSE;
     3665        return FALSE;
    33233666
    33243667    infoPtr->buttons[nIndex].idCommand = (INT)lParam;
     
    33263669    if (infoPtr->hwndToolTip) {
    33273670
    3328     FIXME("change tool tip!\n");
     3671        FIXME("change tool tip!\n");
    33293672
    33303673    }
     
    33493692    /* FIXME: redraw ? */
    33503693
    3351     return (LRESULT)himlTemp;
     3694    return (LRESULT)himlTemp; 
    33523695}
    33533696
     
    33613704    dwTemp = infoPtr->dwDTFlags;
    33623705    infoPtr->dwDTFlags =
    3363     (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
     3706        (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
    33643707
    33653708    return (LRESULT)dwTemp;
     
    33763719    infoPtr->dwExStyle = (DWORD)lParam;
    33773720
    3378     return (LRESULT)dwTemp;
     3721    return (LRESULT)dwTemp; 
    33793722}
    33803723
     
    33913734    /* FIXME: redraw ? */
    33923735
    3393     return (LRESULT)himlTemp;
     3736    return (LRESULT)himlTemp; 
    33943737}
    33953738
     
    34083751    {
    34093752
    3410         infoPtr->nHotItem = (INT)wParam;
     3753        infoPtr->nHotItem = (INT)wParam;
    34113754        if ((INT)wParam >=0)
    34123755        {
    34133756            btnPtr = &infoPtr->buttons[(INT)wParam];
    34143757            btnPtr->bHot = TRUE;
    3415             InvalidateRect (hwnd, &btnPtr->rect,
     3758                InvalidateRect (hwnd, &btnPtr->rect,
    34163759                    TOOLBAR_HasText(infoPtr, btnPtr));
    34173760        }
     
    34203763            btnPtr = &infoPtr->buttons[nOldHotItem];
    34213764            btnPtr->bHot = FALSE;
    3422             InvalidateRect (hwnd, &btnPtr->rect,
     3765                InvalidateRect (hwnd, &btnPtr->rect,
    34233766                    TOOLBAR_HasText(infoPtr, btnPtr));
    34243767        }
     
    34263769
    34273770    if (nOldHotItem < 0)
    3428     return -1;
     3771        return -1;
    34293772
    34303773    return (LRESULT)nOldHotItem;
     
    34413784    infoPtr->himlDef = (HIMAGELIST)lParam;
    34423785
    3443      infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef);
     3786    infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef);
     3787
     3788    ImageList_GetIconSize(infoPtr->himlDef, &infoPtr->nBitmapWidth,
     3789                          &infoPtr->nBitmapHeight);
     3790    TRACE("hwnd %08x, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
     3791          hwnd, (INT)infoPtr->himlDef, infoPtr->nNumBitmaps,
     3792          infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
     3793
    34443794    /* FIXME: redraw ? */
    34453795
    3446     return (LRESULT)himlTemp;
     3796    return (LRESULT)himlTemp; 
    34473797}
    34483798
     
    34913841
    34923842    if (infoPtr == NULL)
    3493     return FALSE;
     3843        return FALSE;
    34943844
    34953845    infoPtr->nMaxTextRows = (INT)wParam;
     
    35113861
    35123862    if (infoPtr == NULL)
    3513     return 0;
     3863        return 0;
    35143864    hwndOldNotify = infoPtr->hwndNotify;
    35153865    infoPtr->hwndNotify = (HWND)wParam;
     
    35283878
    35293879    if (LOWORD(wParam) > 1) {
    3530     FIXME("multiple rows not supported!\n");
     3880        FIXME("multiple rows not supported!\n");
    35313881    }
    35323882
     
    35443894    /* return bounding rectangle */
    35453895    if (lprc) {
    3546     lprc->left   = infoPtr->rcBound.left;
    3547     lprc->right  = infoPtr->rcBound.right;
    3548     lprc->top    = infoPtr->rcBound.top;
    3549     lprc->bottom = infoPtr->rcBound.bottom;
     3896        lprc->left   = infoPtr->rcBound.left;
     3897        lprc->right  = infoPtr->rcBound.right;
     3898        lprc->top    = infoPtr->rcBound.top;
     3899        lprc->bottom = infoPtr->rcBound.bottom;
    35503900    }
    35513901
     
    35633913    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    35643914    if (nIndex == -1)
    3565     return FALSE;
     3915        return FALSE;
    35663916
    35673917    btnPtr = &infoPtr->buttons[nIndex];
     3918
     3919    /* if hidden state has changed the invalidate entire window and recalc */
     3920    if ((btnPtr->fsState & TBSTATE_HIDDEN) != (LOWORD(lParam) & TBSTATE_HIDDEN)) {
     3921        btnPtr->fsState = LOWORD(lParam);
     3922        TOOLBAR_CalcToolbar (hwnd);
     3923        InvalidateRect(hwnd, 0, TOOLBAR_HasText(infoPtr, btnPtr));
     3924        return TRUE;
     3925    }
    35683926
    35693927    /* process state changing if current state doesn't match new state */
     
    35883946    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    35893947    if (nIndex == -1)
    3590     return FALSE;
     3948        return FALSE;
    35913949
    35923950    btnPtr = &infoPtr->buttons[nIndex];
     
    36003958
    36013959        if (infoPtr->hwndToolTip) {
    3602         FIXME("change tool tip!\n");
     3960            FIXME("change tool tip!\n");
    36033961        }
    36043962    }
     
    36143972
    36153973    if (infoPtr == NULL)
    3616     return 0;
     3974        return 0;
    36173975    infoPtr->hwndToolTip = (HWND)wParam;
    36183976    return 0;
     
    36263984    BOOL bTemp;
    36273985
    3628     TRACE("%s hwnd=0x%04x stub!\n",
    3629        ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
     3986    TRACE("%s hwnd=0x%04x stub!\n", 
     3987           ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
    36303988
    36313989    bTemp = infoPtr->bUnicode;
     
    36754033    infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
    36764034    infoPtr->hwndNotify = GetParent (hwnd);
    3677     infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT);
     4035    infoPtr->bTransparent = (dwStyle & TBSTYLE_TRANSPARENT);
     4036    infoPtr->bBtnTranspnt = (dwStyle & (TBSTYLE_FLAT | TBSTYLE_LIST));
    36784037    infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE : DT_CENTER;
    36794038    infoPtr->bAnchor = FALSE; /* no anchor highlighting */
    36804039    infoPtr->iVersion = 0;
     4040    infoPtr->bNtfUnicode = FALSE;
     4041    infoPtr->hwndSelf = hwnd;
    36814042
    36824043    SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
     
    36844045
    36854046    if (dwStyle & TBSTYLE_TOOLTIPS) {
    3686     /* Create tooltip control */
    3687     infoPtr->hwndToolTip =
    3688         CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    3689                    CW_USEDEFAULT, CW_USEDEFAULT,
    3690                    CW_USEDEFAULT, CW_USEDEFAULT,
    3691                    hwnd, 0, 0, 0);
    3692 
    3693     /* Send NM_TOOLTIPSCREATED notification */
    3694     if (infoPtr->hwndToolTip) {
    3695         NMTOOLTIPSCREATED nmttc;
    3696 
    3697         nmttc.hdr.hwndFrom = hwnd;
    3698         nmttc.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    3699         nmttc.hdr.code = NM_TOOLTIPSCREATED;
    3700         nmttc.hwndToolTips = infoPtr->hwndToolTip;
    3701 
    3702         SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
    3703               (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
    3704     }
    3705     }
     4047        /* Create tooltip control */
     4048        infoPtr->hwndToolTip =
     4049            CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
     4050                               CW_USEDEFAULT, CW_USEDEFAULT,
     4051                               CW_USEDEFAULT, CW_USEDEFAULT,
     4052                               hwnd, 0, 0, 0);
     4053
     4054        /* Send NM_TOOLTIPSCREATED notification */
     4055        if (infoPtr->hwndToolTip) {
     4056            NMTOOLTIPSCREATED nmttc;
     4057
     4058            nmttc.hwndToolTips = infoPtr->hwndToolTip;
     4059
     4060            TOOLBAR_SendNotify ((NMHDR *) &nmttc, infoPtr,
     4061                            NM_TOOLTIPSCREATED);
     4062        }
     4063    }
     4064
     4065    TOOLBAR_CheckStyle (hwnd, dwStyle);
    37064066
    37074067    TOOLBAR_CalcToolbar(hwnd);
     
    37184078    /* delete tooltip control */
    37194079    if (infoPtr->hwndToolTip)
    3720     DestroyWindow (infoPtr->hwndToolTip);
     4080        DestroyWindow (infoPtr->hwndToolTip);
    37214081
    37224082    /* delete button data */
    37234083    if (infoPtr->buttons)
    3724     COMCTL32_Free (infoPtr->buttons);
     4084        COMCTL32_Free (infoPtr->buttons);
    37254085
    37264086    /* delete strings */
    37274087    if (infoPtr->strings) {
    3728     INT i;
    3729     for (i = 0; i < infoPtr->nNumStrings; i++)
    3730         if (infoPtr->strings[i])
    3731         COMCTL32_Free (infoPtr->strings[i]);
    3732 
    3733     COMCTL32_Free (infoPtr->strings);
     4088        INT i;
     4089        for (i = 0; i < infoPtr->nNumStrings; i++)
     4090            if (infoPtr->strings[i])
     4091                COMCTL32_Free (infoPtr->strings[i]);
     4092
     4093        COMCTL32_Free (infoPtr->strings);
    37344094    }
    37354095
    37364096    /* destroy internal image list */
    37374097    if (infoPtr->himlInt)
    3738     ImageList_Destroy (infoPtr->himlInt);
     4098        ImageList_Destroy (infoPtr->himlInt);
    37394099
    37404100    /* delete default font */
    37414101    if (infoPtr->hFont)
    3742     DeleteObject (infoPtr->hFont);
     4102        DeleteObject (infoPtr->hFont);
    37434103
    37444104    /* free toolbar info data */
     
    37544114{
    37554115    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    3756 
    3757     if (infoPtr->bTransparent)
    3758     return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
    3759 
    3760     return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
     4116    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     4117    NMTBCUSTOMDRAW tbcd;
     4118    INT ret, ntfret;
     4119
     4120    if (dwStyle & TBSTYLE_CUSTOMERASE) {
     4121        ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
     4122        tbcd.nmcd.dwDrawStage = CDDS_PREERASE;
     4123        tbcd.nmcd.hdc = (HDC)wParam;
     4124        ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
     4125        /* FIXME: in general the return flags *can* be or'ed together */
     4126        switch (ntfret)
     4127            {
     4128            case CDRF_DODEFAULT:
     4129                break;
     4130            case CDRF_SKIPDEFAULT:
     4131                return TRUE;
     4132            default:
     4133                FIXME("[%04x] response %d not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
     4134                      hwnd, ntfret);
     4135            }
     4136    }
     4137
     4138    /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
     4139     * to my parent for processing.
     4140     */
     4141    if (infoPtr->bTransparent) {
     4142        POINT pt, ptorig;
     4143        HDC hdc = (HDC)wParam;
     4144        HWND parent;
     4145
     4146        pt.x = 0;
     4147        pt.y = 0;
     4148        parent = GetParent(hwnd);
     4149        MapWindowPoints(hwnd, parent, &pt, 1);
     4150        OffsetWindowOrgEx (hdc, pt.x, pt.y, &ptorig);
     4151        SendMessageA (parent, WM_ERASEBKGND, wParam, lParam);
     4152        SetWindowOrgEx (hdc, ptorig.x, ptorig.y, 0);
     4153        return TRUE;
     4154    }
     4155    ret = DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
     4156
     4157    if (dwStyle & TBSTYLE_CUSTOMERASE) {
     4158        ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
     4159        tbcd.nmcd.dwDrawStage = CDDS_POSTERASE;
     4160        tbcd.nmcd.hdc = (HDC)wParam;
     4161        ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
     4162        switch (ntfret)
     4163            {
     4164            case CDRF_DODEFAULT:
     4165                break;
     4166            case CDRF_SKIPDEFAULT:
     4167                return TRUE;
     4168            default:
     4169                FIXME("[%04x] response %d not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
     4170                      hwnd, ntfret);
     4171            }
     4172    }
     4173    return ret;
    37614174}
    37624175
     
    37844197
    37854198    if (nHit >= 0) {
    3786     btnPtr = &infoPtr->buttons[nHit];
    3787     if (!(btnPtr->fsState & TBSTATE_ENABLED))
    3788         return 0;
    3789     SetCapture (hwnd);
    3790     infoPtr->bCaptured = TRUE;
    3791     infoPtr->nButtonDown = nHit;
    3792 
    3793     btnPtr->fsState |= TBSTATE_PRESSED;
     4199        btnPtr = &infoPtr->buttons[nHit];
     4200        if (!(btnPtr->fsState & TBSTATE_ENABLED))
     4201            return 0;
     4202        SetCapture (hwnd);
     4203        infoPtr->bCaptured = TRUE;
     4204        infoPtr->nButtonDown = nHit;
     4205
     4206        btnPtr->fsState |= TBSTATE_PRESSED;
    37944207
    37954208        InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
     
    37974210    }
    37984211    else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
    3799     TOOLBAR_Customize (hwnd);
     4212        TOOLBAR_Customize (hwnd);
    38004213
    38014214    return 0;
     
    38104223    POINT pt;
    38114224    INT   nHit;
     4225    NMTOOLBARA nmtb;
    38124226
    38134227    if (infoPtr->hwndToolTip)
    3814     TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
    3815                 WM_LBUTTONDOWN, wParam, lParam);
     4228        TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
     4229                            WM_LBUTTONDOWN, wParam, lParam);
    38164230
    38174231    pt.x = (INT)LOWORD(lParam);
     
    38204234
    38214235    if (nHit >= 0) {
    3822     RECT arrowRect;
    3823     btnPtr = &infoPtr->buttons[nHit];
    3824     if (!(btnPtr->fsState & TBSTATE_ENABLED))
    3825         return 0;
    3826 
    3827     infoPtr->nOldHit = nHit;
    3828 
    3829     CopyRect(&arrowRect, &btnPtr->rect);
    3830     arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH);
    3831 
    3832     /* for EX_DRAWDDARROWS style,  click must be in the drop-down arrow rect */
    3833     if ((btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
    3834          ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
    3835           (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
    3836     {
    3837         NMTOOLBARA nmtb;
    3838         /*
    3839          * this time we must force a Redraw, so the btn is
    3840          * painted down before CaptureChanged repaints it up
    3841          */
    3842         RedrawWindow(hwnd,&btnPtr->rect,0,
    3843             RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
    3844 
    3845         nmtb.hdr.hwndFrom = hwnd;
    3846         nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
    3847         nmtb.hdr.code = TBN_DROPDOWN;
    3848         nmtb.iItem = btnPtr->idCommand;
    3849 
    3850         SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
    3851               (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
    3852     }
    3853     else
    3854     {
    3855         SetCapture (hwnd);
    3856         infoPtr->bCaptured = TRUE;
    3857         infoPtr->nButtonDown = nHit;
    3858 
    3859         btnPtr->fsState |= TBSTATE_PRESSED;
    3860         btnPtr->bHot = FALSE;
    3861 
    3862         InvalidateRect(hwnd, &btnPtr->rect,
    3863                TOOLBAR_HasText(infoPtr, btnPtr));
    3864     }
     4236        RECT arrowRect;
     4237        btnPtr = &infoPtr->buttons[nHit];
     4238        if (!(btnPtr->fsState & TBSTATE_ENABLED))
     4239            return 0;
     4240
     4241        infoPtr->nOldHit = nHit;
     4242
     4243        CopyRect(&arrowRect, &btnPtr->rect);
     4244        arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH);
     4245
     4246        /* for EX_DRAWDDARROWS style,  click must be in the drop-down arrow rect */
     4247        if ((btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
     4248             ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
     4249              (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
     4250        {
     4251            LRESULT res;
     4252            /*
     4253             * this time we must force a Redraw, so the btn is
     4254             * painted down before CaptureChanged repaints it up
     4255             */
     4256            RedrawWindow(hwnd,&btnPtr->rect,0,
     4257                        RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
     4258
     4259            nmtb.iItem = btnPtr->idCommand;
     4260            memset(&nmtb.tbButton, 0, sizeof(TBBUTTON));
     4261            nmtb.cchText = 0;
     4262            nmtb.pszText = 0;
     4263            memset(&nmtb.rcButton, 0, sizeof(RECT));
     4264            res = TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
     4265                                  TBN_DROPDOWN);
     4266            if (res != TBDDRET_TREATPRESSED)
     4267                /* ??? guess  (GA)  */
     4268                return 0;
     4269            /* otherwise drop through and process as pushed */
     4270        }
     4271        /* SetCapture (hwnd); */
     4272        infoPtr->bCaptured = TRUE;
     4273        infoPtr->nButtonDown = nHit;
     4274
     4275        btnPtr->fsState |= TBSTATE_PRESSED;
     4276        btnPtr->bHot = FALSE;
     4277
     4278        InvalidateRect(hwnd, &btnPtr->rect,
     4279                       TOOLBAR_HasText(infoPtr, btnPtr));
     4280        UpdateWindow(hwnd);
     4281        SetCapture (hwnd);
     4282
     4283        /* native issues the TBN_BEGINDRAG here */
     4284        nmtb.iItem = btnPtr->idCommand;
     4285        nmtb.tbButton.iBitmap = btnPtr->iBitmap;
     4286        nmtb.tbButton.idCommand = btnPtr->idCommand;
     4287        nmtb.tbButton.fsState = btnPtr->fsState;
     4288        nmtb.tbButton.fsStyle = btnPtr->fsStyle;
     4289        nmtb.tbButton.dwData = btnPtr->dwData;
     4290        nmtb.tbButton.iString = btnPtr->iString;
     4291        nmtb.cchText = 0;  /* !!! not correct */
     4292        nmtb.pszText = 0;  /* !!! not correct */
     4293        TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
     4294                        TBN_BEGINDRAG);
    38654295    }
    38664296
     
    38774307    INT   nOldIndex = -1;
    38784308    BOOL  bSendMessage = TRUE;
     4309    NMHDR hdr;
     4310    NMMOUSE nmmouse;
     4311    NMTOOLBARA nmtb;
    38794312
    38804313    if (infoPtr->hwndToolTip)
    3881     TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
    3882                 WM_LBUTTONUP, wParam, lParam);
     4314        TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
     4315                            WM_LBUTTONUP, wParam, lParam);
    38834316
    38844317    pt.x = (INT)LOWORD(lParam);
     
    38924325
    38934326    if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
    3894     btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
    3895     btnPtr->fsState &= ~TBSTATE_PRESSED;
    3896 
    3897     if (nHit == infoPtr->nButtonDown) {
    3898         if (btnPtr->fsStyle & TBSTYLE_CHECK) {
    3899         if (btnPtr->fsStyle & TBSTYLE_GROUP) {
    3900             nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
    3901             infoPtr->nButtonDown);
    3902             if (nOldIndex == infoPtr->nButtonDown)
    3903             bSendMessage = FALSE;
    3904             if ((nOldIndex != infoPtr->nButtonDown) &&
    3905             (nOldIndex != -1))
    3906             infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
    3907             btnPtr->fsState |= TBSTATE_CHECKED;
    3908         }
    3909         else {
    3910             if (btnPtr->fsState & TBSTATE_CHECKED)
    3911             btnPtr->fsState &= ~TBSTATE_CHECKED;
    3912             else
    3913             btnPtr->fsState |= TBSTATE_CHECKED;
    3914         }
    3915         }
    3916     }
    3917     else
    3918         bSendMessage = FALSE;
    3919 
    3920     if (nOldIndex != -1)
     4327        btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
     4328        btnPtr->fsState &= ~TBSTATE_PRESSED;
     4329
     4330        if (nHit == infoPtr->nButtonDown) {
     4331            if (btnPtr->fsStyle & TBSTYLE_CHECK) {
     4332                if (btnPtr->fsStyle & TBSTYLE_GROUP) {
     4333                    nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
     4334                        infoPtr->nButtonDown);
     4335                    if (nOldIndex == infoPtr->nButtonDown)
     4336                        bSendMessage = FALSE;
     4337                    if ((nOldIndex != infoPtr->nButtonDown) &&
     4338                        (nOldIndex != -1))
     4339                        infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
     4340                    btnPtr->fsState |= TBSTATE_CHECKED;
     4341                }
     4342                else {
     4343                    if (btnPtr->fsState & TBSTATE_CHECKED)
     4344                        btnPtr->fsState &= ~TBSTATE_CHECKED;
     4345                    else
     4346                        btnPtr->fsState |= TBSTATE_CHECKED;
     4347                }
     4348            }
     4349        }
     4350        else
     4351            bSendMessage = FALSE;
     4352
     4353        if (nOldIndex != -1)
    39214354        {
    39224355            InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
     
    39244357        }
    39254358
    3926     /*
    3927      * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
    3928      * that resets bCaptured and btn TBSTATE_PRESSED flags,
    3929      * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
    3930      */
    3931     ReleaseCapture ();
    3932 
    3933     if (bSendMessage)
    3934         SendMessageA (GetParent(hwnd), WM_COMMAND,
    3935               MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
     4359        /*
     4360         * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
     4361         * that resets bCaptured and btn TBSTATE_PRESSED flags,
     4362         * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
     4363         */
     4364        ReleaseCapture ();
     4365
     4366        /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
     4367        TOOLBAR_SendNotify ((NMHDR *) &hdr, infoPtr,
     4368                        NM_RELEASEDCAPTURE);
     4369
     4370        /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
     4371         * TBN_BEGINDRAG
     4372         */
     4373        nmtb.iItem = btnPtr->idCommand;
     4374        nmtb.tbButton.iBitmap = btnPtr->iBitmap;
     4375        nmtb.tbButton.idCommand = btnPtr->idCommand;
     4376        nmtb.tbButton.fsState = btnPtr->fsState;
     4377        nmtb.tbButton.fsStyle = btnPtr->fsStyle;
     4378        nmtb.tbButton.dwData = btnPtr->dwData;
     4379        nmtb.tbButton.iString = btnPtr->iString;
     4380        nmtb.cchText = 0;  /* !!! not correct */
     4381        nmtb.pszText = 0;  /* !!! not correct */
     4382        TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
     4383                        TBN_ENDDRAG);
     4384
     4385        if (bSendMessage)
     4386            SendMessageA (GetParent(hwnd), WM_COMMAND,
     4387                          MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
     4388
     4389        /* !!! Undocumented - toolbar at 4.71 level and above sends
     4390         * either NMRCLICK or NM_CLICK with the NMMOUSE structure.
     4391         * Only NM_RCLICK is documented.
     4392         */
     4393        nmmouse.dwItemSpec = btnPtr->idCommand;
     4394        nmmouse.dwItemData = btnPtr->dwData;
     4395        TOOLBAR_SendNotify ((NMHDR *) &nmmouse, infoPtr,
     4396                        NM_CLICK);
    39364397    }
    39374398
     
    39504411    {
    39514412        btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
    3952         btnPtr->fsState &= ~TBSTATE_PRESSED;
     4413        btnPtr->fsState &= ~TBSTATE_PRESSED;
    39534414
    39544415        infoPtr->nButtonDown = -1;
     
    39664427    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    39674428    TBUTTON_INFO *hotBtnPtr, *btnPtr;
     4429    RECT rc1;
    39684430
    39694431    if (infoPtr->nOldHit < 0)
     
    39764438    if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED))
    39774439    {
    3978     hotBtnPtr->bHot = FALSE;
    3979 
    3980         InvalidateRect (hwnd, &hotBtnPtr->rect, TOOLBAR_HasText(infoPtr,
     4440        hotBtnPtr->bHot = FALSE;
     4441        rc1 = hotBtnPtr->rect;
     4442        InflateRect (&rc1, 1, 1);
     4443        InvalidateRect (hwnd, &rc1, TOOLBAR_HasText(infoPtr,
    39814444            hotBtnPtr));
    39824445    }
     
    39904453      btnPtr->fsState &= ~TBSTATE_PRESSED;
    39914454
    3992       InvalidateRect (hwnd, &(btnPtr->rect), TRUE);
     4455      rc1 = hotBtnPtr->rect;
     4456      InflateRect (&rc1, 1, 1);
     4457      InvalidateRect (hwnd, &rc1, TRUE);
    39934458    }
    39944459
     
    40204485    if(!(trackinfo.dwFlags & TME_LEAVE)) {
    40214486        trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
    4022 
     4487 
    40234488        /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
    40244489        /* and can properly deactivate the hot toolbar button */
     
    40274492
    40284493    if (infoPtr->hwndToolTip)
    4029     TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
    4030                 WM_MOUSEMOVE, wParam, lParam);
     4494        TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
     4495                            WM_MOUSEMOVE, wParam, lParam);
    40314496
    40324497    pt.x = (INT)LOWORD(lParam);
     
    40374502    if (infoPtr->nOldHit != nHit)
    40384503    {
    4039     /* Remove the effect of an old hot button if the button was enabled and was
    4040        drawn with the hot button effect */
    4041     if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
    4042         (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
    4043     {
    4044         oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
    4045         oldBtnPtr->bHot = FALSE;
    4046 
    4047         InvalidateRect (hwnd, &oldBtnPtr->rect,
     4504        /* Remove the effect of an old hot button if the button was enabled and was
     4505           drawn with the hot button effect */
     4506        if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
     4507                (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
     4508        {
     4509            oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
     4510            oldBtnPtr->bHot = FALSE;
     4511                   
     4512            InvalidateRect (hwnd, &oldBtnPtr->rect,
    40484513                TOOLBAR_HasText(infoPtr, oldBtnPtr));
    4049     }
    4050 
    4051     /* It's not a separator or in nowhere. It's a hot button. */
    4052     if (nHit >= 0)
    4053     {
    4054         btnPtr = &infoPtr->buttons[nHit];
    4055         btnPtr->bHot = TRUE;
    4056 
    4057         infoPtr->nHotItem = nHit;
    4058 
    4059             /* only enabled buttons show hot effect */
     4514        }
     4515
     4516        /* It's not a separator or in nowhere. It's a hot button. */
     4517        if (nHit >= 0)
     4518        {
     4519            btnPtr = &infoPtr->buttons[nHit];
     4520
     4521            infoPtr->nHotItem = nHit;
     4522
     4523            /* only enabled buttons show hot effect */           
    40604524            if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED)
    40614525            {
     4526                btnPtr->bHot = TRUE;
    40624527                InvalidateRect(hwnd, &btnPtr->rect,
    40634528                    TOOLBAR_HasText(infoPtr, btnPtr));
    40644529            }
    40654530
    4066     }
     4531        }
    40674532
    40684533    if (infoPtr->bCaptured) {
    4069         btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
    4070         if (infoPtr->nOldHit == infoPtr->nButtonDown) {
    4071         btnPtr->fsState &= ~TBSTATE_PRESSED;
     4534            btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
     4535            if (infoPtr->nOldHit == infoPtr->nButtonDown) {
     4536                btnPtr->fsState &= ~TBSTATE_PRESSED;
    40724537                InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    4073         }
    4074         else if (nHit == infoPtr->nButtonDown) {
    4075         btnPtr->fsState |= TBSTATE_PRESSED;
     4538            }
     4539            else if (nHit == infoPtr->nButtonDown) {
     4540                btnPtr->fsState |= TBSTATE_PRESSED;
    40764541                InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    4077         }
    4078     }
    4079     infoPtr->nOldHit = nHit;
     4542            }
     4543        }
     4544        infoPtr->nOldHit = nHit;
    40804545    }
    40814546    return 0;
     
    40874552{
    40884553/*    if (wndPtr->dwStyle & CCS_NODIVIDER) */
    4089     return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
     4554        return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
    40904555/*    else */
    4091 /*  return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
     4556/*      return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
    40924557}
    40934558
     
    40974562{
    40984563    if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
    4099     ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
     4564        ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
    41004565
    41014566    return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
     
    41074572{
    41084573    TOOLBAR_INFO *infoPtr;
     4574    LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam;
     4575    DWORD styleadd = 0;
    41094576
    41104577    /* allocate memory for info structure */
     
    41184585    if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
    41194586        HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
    4120     SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
     4587        SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
     4588    }
     4589
     4590    /* native control does:
     4591     *    Get a lot of colors and brushes
     4592     *    WM_NOTIFYFORMAT
     4593     *    SystemParametersInfoA(0x1f, 0x3c, adr1, 0)
     4594     *    CreateFontIndirectA(adr1)
     4595     *    CreateBitmap(0x27, 0x24, 1, 1, 0)
     4596     *    hdc = GetDC(toolbar)
     4597     *    GetSystemMetrics(0x48)
     4598     *    fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
     4599     *                     0, 0, 0, 0, "MARLETT")
     4600     *    oldfnt = SelectObject(hdc, fnt2)
     4601     *    GetCharWidthA(hdc, 0x36, 0x36, adr2)
     4602     *    GetTextMetricsA(hdc, adr3)
     4603     *    SelectObject(hdc, oldfnt)
     4604     *    DeleteObject(fnt2)
     4605     *    ReleaseDC(hdc)
     4606     *    InvalidateRect(toolbar, 0, 1)
     4607     *    SetWindowLongA(toolbar, 0, addr)
     4608     *    SetWindowLongA(toolbar, -16, xxx)  **sometimes**
     4609     *                                          WM_STYLECHANGING
     4610     *                             CallWinEx   old         new
     4611     *                       ie 1  0x56000a4c  0x46000a4c  0x56008a4d
     4612     *                       ie 2  0x4600094c  0x4600094c  0x4600894d
     4613     *                       ie 3  0x56000b4c  0x46000b4c  0x56008b4d
     4614     *                      rebar  0x50008844  0x40008844  0x50008845
     4615     *                      pager  0x50000844  0x40000844  0x50008845
     4616     *                    IC35mgr  0x5400084e  **nochange**
     4617     *           on entry to _NCCREATE         0x5400084e
     4618     *                    rowlist  0x5400004e  **nochange**
     4619     *           on entry to _NCCREATE         0x5400004e
     4620     *
     4621     */
     4622
     4623    /* I think the code below is a bug, but it is the way that the native
     4624     * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
     4625     * forgets to specify TBSTYLE_TRANSPARENT but does specify either
     4626     * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
     4627     * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
     4628     * Some how, the only cases of this seem to be MFC programs.
     4629     *
     4630     * Note also that the addition of _TRANSPARENT occurs *only* here. It
     4631     * does not occur in the WM_STYLECHANGING routine.
     4632     *    (Guy Albertelli   9/2001)
     4633     *
     4634     */
     4635    if ((cs->style & TBSTYLE_FLAT) && !(cs->style & TBSTYLE_TRANSPARENT))
     4636        styleadd |= TBSTYLE_TRANSPARENT;
     4637    if (!(cs->style & (CCS_TOP | CCS_NOMOVEY))) {
     4638        styleadd |= CCS_TOP;   /* default to top */
     4639        SetWindowLongA (hwnd, GWL_STYLE, cs->style | styleadd);
    41214640    }
    41224641
     
    41334652
    41344653    if (dwStyle & WS_MINIMIZE)
    4135     return 0; /* Nothing to do */
     4654        return 0; /* Nothing to do */
    41364655
    41374656    DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
    41384657
    41394658    if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
    4140     return 0;
     4659        return 0;
    41414660
    41424661    if (!(dwStyle & CCS_NODIVIDER))
    41434662    {
    4144     GetWindowRect (hwnd, &rcWindow);
    4145     OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
    4146     if( dwStyle & WS_BORDER )
    4147         OffsetRect (&rcWindow, 1, 1);
    4148     DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
     4663        GetWindowRect (hwnd, &rcWindow);
     4664        OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
     4665        if( dwStyle & WS_BORDER )
     4666            OffsetRect (&rcWindow, 1, 1);
     4667        DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
    41494668    }
    41504669
     
    41614680    LPNMHDR lpnmh = (LPNMHDR)lParam;
    41624681
     4682    if (lpnmh->code == PGN_CALCSIZE) {
     4683        LPNMPGCALCSIZE lppgc = (LPNMPGCALCSIZE)lParam;
     4684
     4685        if (lppgc->dwFlag == PGF_CALCWIDTH) {
     4686            lppgc->iWidth = infoPtr->nWidth;
     4687            TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
     4688                  infoPtr->nWidth);
     4689        }
     4690        else {
     4691            lppgc->iHeight = infoPtr->nHeight;
     4692            TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
     4693                  infoPtr->nHeight);
     4694        }
     4695        return 0;
     4696    }
     4697
     4698
    41634699    TRACE("passing WM_NOTIFY!\n");
    41644700
    41654701    if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
    4166     SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,   wParam, lParam);
     4702        SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,   wParam, lParam);
    41674703
    41684704#if 0
    4169     if (lpnmh->code == TTN_GETDISPINFOA) {
    4170         LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
    4171 
    4172         FIXME("retrieving ASCII string\n");
    4173 
    4174     }
    4175     else if (lpnmh->code == TTN_GETDISPINFOW) {
    4176         LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
    4177 
    4178         FIXME("retrieving UNICODE string\n");
    4179 
    4180     }
     4705        if (lpnmh->code == TTN_GETDISPINFOA) {
     4706            LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
     4707
     4708            FIXME("retrieving ASCII string\n");
     4709
     4710        }
     4711        else if (lpnmh->code == TTN_GETDISPINFOW) {
     4712            LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
     4713
     4714            FIXME("retrieving UNICODE string\n");
     4715
     4716        }
    41814717#endif
    41824718    }
     
    41944730
    41954731    /* fill ps.rcPaint with a default rect */
    4196     memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound));
     4732    memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound)); 
    41974733
    41984734    hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam;
    41994735
    42004736    TRACE("psrect=(%d,%d)-(%d,%d)\n",
    4201       ps.rcPaint.left, ps.rcPaint.top,
    4202       ps.rcPaint.right, ps.rcPaint.bottom);
     4737          ps.rcPaint.left, ps.rcPaint.top,
     4738          ps.rcPaint.right, ps.rcPaint.bottom);
    42034739
    42044740    TOOLBAR_Refresh (hwnd, hdc, &ps);
     
    42244760    /* Resize deadlock check */
    42254761    if (infoPtr->bAutoSize) {
    4226     infoPtr->bAutoSize = FALSE;
    4227     return 0;
     4762        infoPtr->bAutoSize = FALSE;
     4763        return 0;
    42284764    }
    42294765
     
    42404776
    42414777    if (flags == SIZE_RESTORED) {
    4242     /* width and height don't apply */
    4243     parent = GetParent (hwnd);
    4244     GetClientRect(parent, &parent_rect);
    4245     x = parent_rect.left;
    4246     y = parent_rect.top;
    4247 
    4248     if (dwStyle & CCS_NORESIZE) {
    4249         uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
    4250 
    4251         /*
     4778        /* width and height don't apply */
     4779        parent = GetParent (hwnd);
     4780        GetClientRect(parent, &parent_rect);
     4781        x = parent_rect.left;
     4782        y = parent_rect.top;
     4783
     4784        if (dwStyle & CCS_NORESIZE) {
     4785            uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
     4786
     4787            /*
    42524788             * this sets the working width of the toolbar, and
    42534789             * Calc Toolbar will not adjust it, only the height
    42544790             */
    4255         infoPtr->nWidth = parent_rect.right - parent_rect.left;
    4256         cy = infoPtr->nHeight;
    4257         cx = infoPtr->nWidth;
    4258         TOOLBAR_CalcToolbar (hwnd);
    4259         infoPtr->nWidth = cx;
    4260         infoPtr->nHeight = cy;
    4261     }
    4262     else {
    4263         infoPtr->nWidth = parent_rect.right - parent_rect.left;
    4264         TOOLBAR_CalcToolbar (hwnd);
    4265         cy = infoPtr->nHeight;
    4266         cx = infoPtr->nWidth;
    4267 
    4268         if (dwStyle & CCS_NOMOVEY) {
    4269         GetWindowRect(hwnd, &window_rect);
    4270         ScreenToClient(parent, (LPPOINT)&window_rect.left);
    4271         y = window_rect.top;
    4272         }
    4273     }
    4274 
    4275     if (dwStyle & CCS_NOPARENTALIGN) {
    4276         uPosFlags |= SWP_NOMOVE;
    4277         cy = infoPtr->nHeight;
    4278         cx = infoPtr->nWidth;
    4279     }
    4280 
    4281     if (!(dwStyle & CCS_NODIVIDER))
    4282         cy += GetSystemMetrics(SM_CYEDGE);
    4283 
    4284     if (dwStyle & WS_BORDER)
    4285     {
    4286         x = y = 1;
    4287         cy += GetSystemMetrics(SM_CYEDGE);
    4288         cx += GetSystemMetrics(SM_CYEDGE);
    4289     }
    4290 
    4291     SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
    4292             cx, cy, uPosFlags | SWP_NOZORDER);
     4791            infoPtr->nWidth = parent_rect.right - parent_rect.left;
     4792            cy = infoPtr->nHeight;
     4793            cx = infoPtr->nWidth;
     4794            TOOLBAR_CalcToolbar (hwnd);
     4795            infoPtr->nWidth = cx;
     4796            infoPtr->nHeight = cy;
     4797        }
     4798        else {
     4799            infoPtr->nWidth = parent_rect.right - parent_rect.left;
     4800            TOOLBAR_CalcToolbar (hwnd);
     4801            cy = infoPtr->nHeight;
     4802            cx = infoPtr->nWidth;
     4803
     4804            if (dwStyle & CCS_NOMOVEY) {
     4805                GetWindowRect(hwnd, &window_rect);
     4806                ScreenToClient(parent, (LPPOINT)&window_rect.left);
     4807                y = window_rect.top;
     4808            }
     4809        }
     4810
     4811        if (dwStyle & CCS_NOPARENTALIGN) {
     4812            uPosFlags |= SWP_NOMOVE;
     4813            cy = infoPtr->nHeight;
     4814            cx = infoPtr->nWidth;
     4815        }
     4816
     4817        if (!(dwStyle & CCS_NODIVIDER))
     4818            cy += GetSystemMetrics(SM_CYEDGE);
     4819
     4820        if (dwStyle & WS_BORDER)
     4821        {
     4822            x = y = 1;
     4823            cy += GetSystemMetrics(SM_CYEDGE);
     4824            cx += GetSystemMetrics(SM_CYEDGE);
     4825        }
     4826
     4827        SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
     4828                        cx, cy, uPosFlags | SWP_NOZORDER);
    42934829    }
    42944830    return 0;
     
    43024838
    43034839    if (nType == GWL_STYLE) {
    4304     if (lpStyle->styleNew & TBSTYLE_LIST) {
    4305         infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
    4306     }
    4307     else {
    4308         infoPtr->dwDTFlags = DT_CENTER;
    4309     }
     4840        if (lpStyle->styleNew & TBSTYLE_LIST) {
     4841            infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
     4842        }
     4843        else {
     4844            infoPtr->dwDTFlags = DT_CENTER;
     4845        }
     4846        infoPtr->bTransparent = (lpStyle->styleNew & TBSTYLE_TRANSPARENT);
     4847        infoPtr->bBtnTranspnt = (lpStyle->styleNew &
     4848                                 (TBSTYLE_FLAT | TBSTYLE_LIST));
     4849        TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew);
    43104850    }
    43114851
     
    43224862ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    43234863{
     4864    TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
     4865          hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
     4866
    43244867    if (!TOOLBAR_GetInfoPtr(hwnd) && (uMsg != WM_NCCREATE))
    4325     return DefWindowProcA( hwnd, uMsg, wParam, lParam );
     4868        return DefWindowProcA( hwnd, uMsg, wParam, lParam );
    43264869
    43274870    switch (uMsg)
    43284871    {
    4329     case TB_ADDBITMAP:
    4330         return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
    4331 
    4332     case TB_ADDBUTTONSA:
    4333         return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
    4334 
    4335     case TB_ADDBUTTONSW:
    4336         return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
    4337 
    4338     case TB_ADDSTRINGA:
    4339         return TOOLBAR_AddStringA (hwnd, wParam, lParam);
    4340 
    4341     case TB_ADDSTRINGW:
    4342         return TOOLBAR_AddStringW (hwnd, wParam, lParam);
    4343 
    4344     case TB_AUTOSIZE:
    4345         return TOOLBAR_AutoSize (hwnd);
    4346 
    4347     case TB_BUTTONCOUNT:
    4348         return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
    4349 
    4350     case TB_BUTTONSTRUCTSIZE:
    4351         return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
    4352 
    4353     case TB_CHANGEBITMAP:
    4354         return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
    4355 
    4356     case TB_CHECKBUTTON:
    4357         return TOOLBAR_CheckButton (hwnd, wParam, lParam);
    4358 
    4359     case TB_COMMANDTOINDEX:
    4360         return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
    4361 
    4362     case TB_CUSTOMIZE:
    4363         return TOOLBAR_Customize (hwnd);
    4364 
    4365     case TB_DELETEBUTTON:
    4366         return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
    4367 
    4368     case TB_ENABLEBUTTON:
    4369         return TOOLBAR_EnableButton (hwnd, wParam, lParam);
    4370 
    4371     case TB_GETANCHORHIGHLIGHT:
    4372         return TOOLBAR_GetAnchorHighlight (hwnd);
    4373 
    4374     case TB_GETBITMAP:
    4375         return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
    4376 
    4377     case TB_GETBITMAPFLAGS:
    4378         return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
    4379 
    4380     case TB_GETBUTTON:
    4381         return TOOLBAR_GetButton (hwnd, wParam, lParam);
    4382 
    4383     case TB_GETBUTTONINFOA:
    4384         return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
    4385 
    4386     case TB_GETBUTTONINFOW:
    4387         return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
    4388 
    4389     case TB_GETBUTTONSIZE:
    4390         return TOOLBAR_GetButtonSize (hwnd);
    4391 
    4392     case TB_GETBUTTONTEXTA:
    4393         return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
    4394 
    4395     case TB_GETBUTTONTEXTW:
    4396         return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
    4397 
    4398 /*  case TB_GETCOLORSCHEME:         */ /* 4.71 */
    4399 
    4400     case TB_GETDISABLEDIMAGELIST:
    4401         return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
    4402 
    4403     case TB_GETEXTENDEDSTYLE:
    4404         return TOOLBAR_GetExtendedStyle (hwnd);
    4405 
    4406     case TB_GETHOTIMAGELIST:
    4407         return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
    4408 
    4409     case TB_GETHOTITEM:
    4410         return TOOLBAR_GetHotItem (hwnd);
    4411 
    4412     case TB_GETIMAGELIST:
    4413         return TOOLBAR_GetImageList (hwnd, wParam, lParam);
    4414 
    4415 /*  case TB_GETINSERTMARK:          */ /* 4.71 */
    4416 /*  case TB_GETINSERTMARKCOLOR:     */ /* 4.71 */
    4417 
    4418     case TB_GETITEMRECT:
    4419         return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
    4420 
    4421     case TB_GETMAXSIZE:
    4422         return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
    4423 
    4424 /*  case TB_GETOBJECT:          */ /* 4.71 */
    4425 /*  case TB_GETPADDING:         */ /* 4.71 */
    4426 
    4427     case TB_GETRECT:
    4428         return TOOLBAR_GetRect (hwnd, wParam, lParam);
    4429 
    4430     case TB_GETROWS:
    4431         return TOOLBAR_GetRows (hwnd, wParam, lParam);
    4432 
    4433     case TB_GETSTATE:
    4434         return TOOLBAR_GetState (hwnd, wParam, lParam);
    4435 
    4436     case TB_GETSTYLE:
    4437         return TOOLBAR_GetStyle (hwnd, wParam, lParam);
    4438 
    4439     case TB_GETTEXTROWS:
    4440         return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
    4441 
    4442     case TB_GETTOOLTIPS:
    4443         return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
    4444 
    4445     case TB_GETUNICODEFORMAT:
    4446         return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
    4447 
    4448     case CCM_GETVERSION:
    4449         return TOOLBAR_GetVersion (hwnd);
    4450 
    4451     case TB_HIDEBUTTON:
    4452         return TOOLBAR_HideButton (hwnd, wParam, lParam);
    4453 
    4454     case TB_HITTEST:
    4455         return TOOLBAR_HitTest (hwnd, wParam, lParam);
    4456 
    4457     case TB_INDETERMINATE:
    4458         return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
    4459 
    4460     case TB_INSERTBUTTONA:
    4461         return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
    4462 
    4463     case TB_INSERTBUTTONW:
    4464         return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
    4465 
    4466 /*  case TB_INSERTMARKHITTEST:      */ /* 4.71 */
    4467 
    4468     case TB_ISBUTTONCHECKED:
    4469         return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
    4470 
    4471     case TB_ISBUTTONENABLED:
    4472         return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
    4473 
    4474     case TB_ISBUTTONHIDDEN:
    4475         return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
    4476 
    4477     case TB_ISBUTTONHIGHLIGHTED:
    4478         return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
    4479 
    4480     case TB_ISBUTTONINDETERMINATE:
    4481         return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
    4482 
    4483     case TB_ISBUTTONPRESSED:
    4484         return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
    4485 
    4486     case TB_LOADIMAGES:            /* 4.70 */
    4487         FIXME("missing standard imagelists\n");
    4488         return 0;
    4489 
    4490 /*  case TB_MAPACCELERATORA:        */ /* 4.71 */
    4491 /*  case TB_MAPACCELERATORW:        */ /* 4.71 */
    4492 /*  case TB_MARKBUTTON:         */ /* 4.71 */
    4493 /*  case TB_MOVEBUTTON:         */ /* 4.71 */
    4494 
    4495     case TB_PRESSBUTTON:
    4496         return TOOLBAR_PressButton (hwnd, wParam, lParam);
    4497 
    4498 /*  case TB_REPLACEBITMAP: */
    4499 
    4500     case TB_SAVERESTOREA:
    4501         return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
    4502 
    4503     case TB_SAVERESTOREW:
    4504         return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
    4505 
    4506     case TB_SETANCHORHIGHLIGHT:
    4507         return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
    4508 
    4509     case TB_SETBITMAPSIZE:
    4510         return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
    4511 
    4512     case TB_SETBUTTONINFOA:
    4513         return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
    4514 
    4515     case TB_SETBUTTONINFOW:
    4516         return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
    4517 
    4518     case TB_SETBUTTONSIZE:
    4519         return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
    4520 
    4521     case TB_SETBUTTONWIDTH:
    4522         return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
    4523 
    4524     case TB_SETCMDID:
    4525         return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
    4526 
    4527 /*  case TB_SETCOLORSCHEME:         */ /* 4.71 */
    4528 
    4529     case TB_SETDISABLEDIMAGELIST:
    4530         return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
    4531 
    4532     case TB_SETDRAWTEXTFLAGS:
    4533         return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
    4534 
    4535     case TB_SETEXTENDEDSTYLE:
    4536         return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
    4537 
    4538     case TB_SETHOTIMAGELIST:
    4539         return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
    4540 
    4541     case TB_SETHOTITEM:
    4542         return TOOLBAR_SetHotItem (hwnd, wParam);
    4543 
    4544     case TB_SETIMAGELIST:
    4545         return TOOLBAR_SetImageList (hwnd, wParam, lParam);
    4546 
    4547     case TB_SETINDENT:
    4548         return TOOLBAR_SetIndent (hwnd, wParam, lParam);
    4549 
    4550 /*  case TB_SETINSERTMARK:          */ /* 4.71 */
    4551 
    4552     case TB_SETINSERTMARKCOLOR:
    4553         return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
    4554 
    4555     case TB_SETMAXTEXTROWS:
    4556         return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
    4557 
    4558 /*  case TB_SETPADDING:         */ /* 4.71 */
    4559 
    4560     case TB_SETPARENT:
    4561         return TOOLBAR_SetParent (hwnd, wParam, lParam);
    4562 
    4563     case TB_SETROWS:
    4564         return TOOLBAR_SetRows (hwnd, wParam, lParam);
    4565 
    4566     case TB_SETSTATE:
    4567         return TOOLBAR_SetState (hwnd, wParam, lParam);
    4568 
    4569     case TB_SETSTYLE:
    4570         return TOOLBAR_SetStyle (hwnd, wParam, lParam);
    4571 
    4572     case TB_SETTOOLTIPS:
    4573         return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
    4574 
    4575     case TB_SETUNICODEFORMAT:
    4576         return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
    4577 
    4578     case CCM_SETVERSION:
    4579         return TOOLBAR_SetVersion (hwnd, (INT)wParam);
    4580 
    4581 
    4582 /*  case WM_CHAR: */
    4583 
    4584     case WM_CREATE:
    4585         return TOOLBAR_Create (hwnd, wParam, lParam);
    4586 
    4587     case WM_DESTROY:
    4588       return TOOLBAR_Destroy (hwnd, wParam, lParam);
    4589 
    4590     case WM_ERASEBKGND:
    4591         return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
    4592 
    4593     case WM_GETFONT:
    4594         return TOOLBAR_GetFont (hwnd, wParam, lParam);
    4595 
    4596 /*  case WM_KEYDOWN: */
    4597 /*  case WM_KILLFOCUS: */
    4598 
    4599     case WM_LBUTTONDBLCLK:
    4600         return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
    4601 
    4602     case WM_LBUTTONDOWN:
    4603         return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
    4604 
    4605     case WM_LBUTTONUP:
    4606         return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
    4607 
    4608     case WM_MOUSEMOVE:
    4609         return TOOLBAR_MouseMove (hwnd, wParam, lParam);
    4610 
    4611     case WM_MOUSELEAVE:
    4612         return TOOLBAR_MouseLeave (hwnd, wParam, lParam);
    4613 
    4614     case WM_CAPTURECHANGED:
    4615         return TOOLBAR_CaptureChanged(hwnd);
    4616 
    4617     case WM_NCACTIVATE:
    4618         return TOOLBAR_NCActivate (hwnd, wParam, lParam);
    4619 
    4620     case WM_NCCALCSIZE:
    4621         return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
    4622 
    4623     case WM_NCCREATE:
    4624         return TOOLBAR_NCCreate (hwnd, wParam, lParam);
    4625 
    4626     case WM_NCPAINT:
    4627         return TOOLBAR_NCPaint (hwnd, wParam, lParam);
    4628 
    4629     case WM_NOTIFY:
    4630         return TOOLBAR_Notify (hwnd, wParam, lParam);
    4631 
    4632 /*  case WM_NOTIFYFORMAT: */
    4633 
    4634     case WM_PAINT:
    4635         return TOOLBAR_Paint (hwnd, wParam);
    4636 
    4637     case WM_SIZE:
    4638         return TOOLBAR_Size (hwnd, wParam, lParam);
    4639 
    4640     case WM_STYLECHANGED:
    4641         return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
    4642 
    4643 /*  case WM_SYSCOLORCHANGE: */
    4644 
    4645 /*  case WM_WININICHANGE: */
    4646 
    4647     case WM_CHARTOITEM:
    4648     case WM_COMMAND:
    4649     case WM_DRAWITEM:
    4650     case WM_MEASUREITEM:
    4651     case WM_VKEYTOITEM:
    4652         return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
    4653 
    4654     default:
    4655         if (uMsg >= WM_USER)
    4656         ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    4657              uMsg, wParam, lParam);
    4658         return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     4872        case TB_ADDBITMAP:
     4873            return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
     4874
     4875        case TB_ADDBUTTONSA:
     4876            return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
     4877
     4878        case TB_ADDBUTTONSW:
     4879            return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
     4880
     4881        case TB_ADDSTRINGA:
     4882            return TOOLBAR_AddStringA (hwnd, wParam, lParam);
     4883
     4884        case TB_ADDSTRINGW:
     4885            return TOOLBAR_AddStringW (hwnd, wParam, lParam);
     4886
     4887        case TB_AUTOSIZE:
     4888            return TOOLBAR_AutoSize (hwnd);
     4889
     4890        case TB_BUTTONCOUNT:
     4891            return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
     4892
     4893        case TB_BUTTONSTRUCTSIZE:
     4894            return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
     4895
     4896        case TB_CHANGEBITMAP:
     4897            return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
     4898
     4899        case TB_CHECKBUTTON:
     4900            return TOOLBAR_CheckButton (hwnd, wParam, lParam);
     4901
     4902        case TB_COMMANDTOINDEX:
     4903            return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
     4904
     4905        case TB_CUSTOMIZE:
     4906            return TOOLBAR_Customize (hwnd);
     4907
     4908        case TB_DELETEBUTTON:
     4909            return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
     4910
     4911        case TB_ENABLEBUTTON:
     4912            return TOOLBAR_EnableButton (hwnd, wParam, lParam);
     4913
     4914        case TB_GETANCHORHIGHLIGHT:
     4915            return TOOLBAR_GetAnchorHighlight (hwnd);
     4916
     4917        case TB_GETBITMAP:
     4918            return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
     4919
     4920        case TB_GETBITMAPFLAGS:
     4921            return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
     4922
     4923        case TB_GETBUTTON:
     4924            return TOOLBAR_GetButton (hwnd, wParam, lParam);
     4925
     4926        case TB_GETBUTTONINFOA:
     4927            return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
     4928
     4929        case TB_GETBUTTONINFOW:
     4930            return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
     4931
     4932        case TB_GETBUTTONSIZE:
     4933            return TOOLBAR_GetButtonSize (hwnd);
     4934
     4935        case TB_GETBUTTONTEXTA:
     4936            return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
     4937
     4938        case TB_GETBUTTONTEXTW:
     4939            return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
     4940
     4941/*      case TB_GETCOLORSCHEME:                 */ /* 4.71 */
     4942
     4943        case TB_GETDISABLEDIMAGELIST:
     4944            return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
     4945
     4946        case TB_GETEXTENDEDSTYLE:
     4947            return TOOLBAR_GetExtendedStyle (hwnd);
     4948
     4949        case TB_GETHOTIMAGELIST:
     4950            return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
     4951
     4952        case TB_GETHOTITEM:
     4953            return TOOLBAR_GetHotItem (hwnd);
     4954
     4955        case TB_GETIMAGELIST:
     4956            return TOOLBAR_GetImageList (hwnd, wParam, lParam);
     4957
     4958/*      case TB_GETINSERTMARK:                  */ /* 4.71 */
     4959/*      case TB_GETINSERTMARKCOLOR:             */ /* 4.71 */
     4960
     4961        case TB_GETITEMRECT:
     4962            return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
     4963
     4964        case TB_GETMAXSIZE:
     4965            return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
     4966
     4967/*      case TB_GETOBJECT:                      */ /* 4.71 */
     4968/*      case TB_GETPADDING:                     */ /* 4.71 */
     4969
     4970        case TB_GETRECT:
     4971            return TOOLBAR_GetRect (hwnd, wParam, lParam);
     4972
     4973        case TB_GETROWS:
     4974            return TOOLBAR_GetRows (hwnd, wParam, lParam);
     4975
     4976        case TB_GETSTATE:
     4977            return TOOLBAR_GetState (hwnd, wParam, lParam);
     4978
     4979        case TB_GETSTYLE:
     4980            return TOOLBAR_GetStyle (hwnd, wParam, lParam);
     4981
     4982        case TB_GETTEXTROWS:
     4983            return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
     4984
     4985        case TB_GETTOOLTIPS:
     4986            return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
     4987
     4988        case TB_GETUNICODEFORMAT:
     4989            return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
     4990
     4991        case CCM_GETVERSION:
     4992            return TOOLBAR_GetVersion (hwnd);
     4993
     4994        case TB_HIDEBUTTON:
     4995            return TOOLBAR_HideButton (hwnd, wParam, lParam);
     4996
     4997        case TB_HITTEST:
     4998            return TOOLBAR_HitTest (hwnd, wParam, lParam);
     4999
     5000        case TB_INDETERMINATE:
     5001            return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
     5002
     5003        case TB_INSERTBUTTONA:
     5004            return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
     5005
     5006        case TB_INSERTBUTTONW:
     5007            return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
     5008
     5009/*      case TB_INSERTMARKHITTEST:              */ /* 4.71 */
     5010
     5011        case TB_ISBUTTONCHECKED:
     5012            return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
     5013
     5014        case TB_ISBUTTONENABLED:
     5015            return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
     5016
     5017        case TB_ISBUTTONHIDDEN:
     5018            return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
     5019
     5020        case TB_ISBUTTONHIGHLIGHTED:
     5021            return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
     5022
     5023        case TB_ISBUTTONINDETERMINATE:
     5024            return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
     5025
     5026        case TB_ISBUTTONPRESSED:
     5027            return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
     5028
     5029        case TB_LOADIMAGES:                        /* 4.70 */
     5030            FIXME("missing standard imagelists\n");
     5031            return 0;
     5032
     5033/*      case TB_MAPACCELERATORA:                */ /* 4.71 */
     5034/*      case TB_MAPACCELERATORW:                */ /* 4.71 */
     5035/*      case TB_MARKBUTTON:                     */ /* 4.71 */
     5036/*      case TB_MOVEBUTTON:                     */ /* 4.71 */
     5037
     5038        case TB_PRESSBUTTON:
     5039            return TOOLBAR_PressButton (hwnd, wParam, lParam);
     5040
     5041/*      case TB_REPLACEBITMAP: */
     5042
     5043        case TB_SAVERESTOREA:
     5044            return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
     5045
     5046        case TB_SAVERESTOREW:
     5047            return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
     5048
     5049        case TB_SETANCHORHIGHLIGHT:
     5050            return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
     5051
     5052        case TB_SETBITMAPSIZE:
     5053            return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
     5054
     5055        case TB_SETBUTTONINFOA:
     5056            return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
     5057
     5058        case TB_SETBUTTONINFOW:
     5059            return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
     5060
     5061        case TB_SETBUTTONSIZE:
     5062            return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
     5063
     5064        case TB_SETBUTTONWIDTH:
     5065            return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
     5066
     5067        case TB_SETCMDID:
     5068            return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
     5069
     5070/*      case TB_SETCOLORSCHEME:                 */ /* 4.71 */
     5071
     5072        case TB_SETDISABLEDIMAGELIST:
     5073            return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
     5074
     5075        case TB_SETDRAWTEXTFLAGS:
     5076            return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
     5077
     5078        case TB_SETEXTENDEDSTYLE:
     5079            return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
     5080
     5081        case TB_SETHOTIMAGELIST:
     5082            return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
     5083
     5084        case TB_SETHOTITEM:
     5085            return TOOLBAR_SetHotItem (hwnd, wParam);
     5086
     5087        case TB_SETIMAGELIST:
     5088            return TOOLBAR_SetImageList (hwnd, wParam, lParam);
     5089
     5090        case TB_SETINDENT:
     5091            return TOOLBAR_SetIndent (hwnd, wParam, lParam);
     5092
     5093/*      case TB_SETINSERTMARK:                  */ /* 4.71 */
     5094
     5095        case TB_SETINSERTMARKCOLOR:
     5096            return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
     5097
     5098        case TB_SETMAXTEXTROWS:
     5099            return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
     5100
     5101/*      case TB_SETPADDING:                     */ /* 4.71 */
     5102
     5103        case TB_SETPARENT:
     5104            return TOOLBAR_SetParent (hwnd, wParam, lParam);
     5105
     5106        case TB_SETROWS:
     5107            return TOOLBAR_SetRows (hwnd, wParam, lParam);
     5108
     5109        case TB_SETSTATE:
     5110            return TOOLBAR_SetState (hwnd, wParam, lParam);
     5111
     5112        case TB_SETSTYLE:
     5113            return TOOLBAR_SetStyle (hwnd, wParam, lParam);
     5114
     5115        case TB_SETTOOLTIPS:
     5116            return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
     5117
     5118        case TB_SETUNICODEFORMAT:
     5119            return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
     5120
     5121        case CCM_SETVERSION:
     5122            return TOOLBAR_SetVersion (hwnd, (INT)wParam);
     5123
     5124
     5125/*      case WM_CHAR: */
     5126
     5127        case WM_CREATE:
     5128            return TOOLBAR_Create (hwnd, wParam, lParam);
     5129
     5130        case WM_DESTROY:
     5131          return TOOLBAR_Destroy (hwnd, wParam, lParam);
     5132
     5133        case WM_ERASEBKGND:
     5134            return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
     5135
     5136        case WM_GETFONT:
     5137                return TOOLBAR_GetFont (hwnd, wParam, lParam);
     5138
     5139/*      case WM_KEYDOWN: */
     5140/*      case WM_KILLFOCUS: */
     5141
     5142        case WM_LBUTTONDBLCLK:
     5143            return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
     5144
     5145        case WM_LBUTTONDOWN:
     5146            return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
     5147
     5148        case WM_LBUTTONUP:
     5149            return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
     5150
     5151        case WM_MOUSEMOVE:
     5152            return TOOLBAR_MouseMove (hwnd, wParam, lParam);
     5153
     5154        case WM_MOUSELEAVE:
     5155            return TOOLBAR_MouseLeave (hwnd, wParam, lParam);   
     5156
     5157        case WM_CAPTURECHANGED:
     5158            return TOOLBAR_CaptureChanged(hwnd);       
     5159
     5160        case WM_NCACTIVATE:
     5161            return TOOLBAR_NCActivate (hwnd, wParam, lParam);
     5162
     5163        case WM_NCCALCSIZE:
     5164            return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
     5165
     5166        case WM_NCCREATE:
     5167            return TOOLBAR_NCCreate (hwnd, wParam, lParam);
     5168
     5169        case WM_NCPAINT:
     5170            return TOOLBAR_NCPaint (hwnd, wParam, lParam);
     5171
     5172        case WM_NOTIFY:
     5173            return TOOLBAR_Notify (hwnd, wParam, lParam);
     5174
     5175/*      case WM_NOTIFYFORMAT: */
     5176
     5177        case WM_PAINT:
     5178            return TOOLBAR_Paint (hwnd, wParam);
     5179
     5180        case WM_SIZE:
     5181            return TOOLBAR_Size (hwnd, wParam, lParam);
     5182
     5183        case WM_STYLECHANGED:
     5184            return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
     5185
     5186/*      case WM_SYSCOLORCHANGE: */
     5187
     5188/*      case WM_WININICHANGE: */
     5189
     5190        case WM_CHARTOITEM:
     5191        case WM_COMMAND:
     5192        case WM_DRAWITEM:
     5193        case WM_MEASUREITEM:
     5194        case WM_VKEYTOITEM:
     5195            return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
     5196
     5197        default:
     5198            if (uMsg >= WM_USER)
     5199                ERR("unknown msg %04x wp=%08x lp=%08lx\n",
     5200                     uMsg, wParam, lParam);
     5201            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    46595202    }
    46605203    return 0;
     
    46755218    wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
    46765219    wndClass.lpszClassName = TOOLBARCLASSNAMEA;
    4677 
     5220 
    46785221    RegisterClassA (&wndClass);
    46795222}
     
    46855228    UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);
    46865229}
    4687 
  • trunk/src/comctl32/treeview.cpp

    r4019 r6705  
    1 /* $Id: treeview.cpp,v 1.18 2000-08-15 17:04:39 cbratschi Exp $ */
     1/* $Id: treeview.cpp,v 1.19 2001-09-15 09:13:31 sandervl Exp $ */
    22/* Treeview control
    33 *
     
    13351335    if (oldSelection == infoPtr->selectedItem)
    13361336    {
     1337#ifdef __WIN32OS2__
     1338      //Crash in UltraEdit when opening file, because the old selected
     1339      //item is already freed
     1340      if (oldSelection == (TREEVIEW_ITEM *)lParam) {
     1341          infoPtr->selectedItem = 0;
     1342      }
     1343#endif
    13371344      if (TREEVIEW_ValidItem(infoPtr, newSelection))
    13381345        TREEVIEW_DoSelectItem(infoPtr, TVGN_CARET, newSelection, TVC_UNKNOWN);
Note: See TracChangeset for help on using the changeset viewer.