Changeset 236 for trunk/src


Ignore:
Timestamp:
Jun 28, 1999, 5:46:28 PM (26 years ago)
Author:
cbratschi
Message:

bug fixes (unicode) and improvements

Location:
trunk/src/comctl32
Files:
10 edited

Legend:

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

    r94 r236  
    1 /* $Id: header.c,v 1.5 1999-06-10 16:21:58 achimha Exp $ */
     1/* $Id: header.c,v 1.6 1999-06-28 15:46:24 cbratschi Exp $ */
    22/*
    33 *  Header control
     
    55 *  Copyright 1998 Eric Kohl
    66 *  Copyright 1999 Achim Hasenmueller
     7 *  Copyright 1999 Christoph Bratschi
    78 *
    89 *  TODO:
     
    4950    r = phdi->rect;
    5051    if (r.right - r.left == 0)
    51         return phdi->rect.right;
     52        return phdi->rect.right;
    5253
    5354    if (GetWindowLongA (hwnd, GWL_STYLE) & HDS_BUTTONS) {
    54         if (phdi->bDown) {
    55             DrawEdge (hdc, &r, BDR_RAISEDOUTER,
    56                         BF_RECT | BF_FLAT | BF_MIDDLE | BF_ADJUST);
    57             r.left += 2;
     55        if (phdi->bDown) {
     56            DrawEdge (hdc, &r, BDR_RAISEDOUTER,
     57                        BF_RECT | BF_FLAT | BF_MIDDLE | BF_ADJUST);
     58            r.left += 2;
    5859            r.top  += 2;
    59         }
    60         else
    61             DrawEdge (hdc, &r, EDGE_RAISED,
    62                         BF_RECT | BF_SOFT | BF_MIDDLE | BF_ADJUST);
     60        }
     61        else
     62            DrawEdge (hdc, &r, EDGE_RAISED,
     63                        BF_RECT | BF_SOFT | BF_MIDDLE | BF_ADJUST);
    6364    }
    6465    else
     
    6667
    6768    if (phdi->fmt & HDF_OWNERDRAW) {
    68         DRAWITEMSTRUCT dis;
    69         dis.CtlType    = ODT_HEADER;
    70         dis.CtlID      = GetWindowLongA (hwnd, GWL_ID);
    71         dis.itemID     = iItem;
    72         dis.itemAction = ODA_DRAWENTIRE;
    73         dis.itemState  = phdi->bDown ? ODS_SELECTED : 0;
    74         dis.hwndItem   = hwnd;
    75         dis.hDC        = hdc;
    76         dis.rcItem     = r;
    77         dis.itemData   = phdi->lParam;
    78         SendMessageA (GetParent (hwnd), WM_DRAWITEM,
    79                         (WPARAM)dis.CtlID, (LPARAM)&dis);
     69        DRAWITEMSTRUCT dis;
     70        dis.CtlType    = ODT_HEADER;
     71        dis.CtlID      = GetWindowLongA (hwnd, GWL_ID);
     72        dis.itemID     = iItem;
     73        dis.itemAction = ODA_DRAWENTIRE;
     74        dis.itemState  = phdi->bDown ? ODS_SELECTED : 0;
     75        dis.hwndItem   = hwnd;
     76        dis.hDC        = hdc;
     77        dis.rcItem     = r;
     78        dis.itemData   = phdi->lParam;
     79        SendMessageA (GetParent (hwnd), WM_DRAWITEM,
     80                        (WPARAM)dis.CtlID, (LPARAM)&dis);
    8081    }
    8182    else {
     
    8788            uTextJustify = DT_RIGHT;
    8889
    89         if ((phdi->fmt & HDF_BITMAP) && (phdi->hbm)) {
    90             BITMAP bmp;
    91             HDC    hdcBitmap;
    92             INT    yD, yS, cx, cy, rx, ry;
    93 
    94             GetObjectA (phdi->hbm, sizeof(BITMAP), (LPVOID)&bmp);
    95 
    96             ry = r.bottom - r.top;
    97             rx = r.right - r.left;
    98 
    99             if (ry >= bmp.bmHeight) {
    100                 cy = bmp.bmHeight;
    101                 yD = r.top + (ry - bmp.bmHeight) / 2;
    102                 yS = 0;
    103             }
    104             else {
    105                 cy = ry;
    106                 yD = r.top;
    107                 yS = (bmp.bmHeight - ry) / 2;
    108 
    109             }
    110 
    111             if (rx >= bmp.bmWidth + 6) {
    112                 cx = bmp.bmWidth;
    113             }
    114             else {
    115                 cx = rx - 6;
    116             }
    117 
    118             hdcBitmap = CreateCompatibleDC (hdc);
    119             SelectObject (hdcBitmap, phdi->hbm);
    120             BitBlt (hdc, r.left + 3, yD, cx, cy, hdcBitmap, 0, yS, SRCCOPY);
    121             DeleteDC (hdcBitmap);
    122 
    123             r.left += (bmp.bmWidth + 3);
    124         }
    125 
    126 
    127         if ((phdi->fmt & HDF_BITMAP_ON_RIGHT) && (phdi->hbm)) {
    128             BITMAP bmp;
    129             HDC    hdcBitmap;
    130             INT    xD, yD, yS, cx, cy, rx, ry, tx;
    131             RECT   textRect;
    132 
    133             GetObjectA (phdi->hbm, sizeof(BITMAP), (LPVOID)&bmp);
    134 
    135             textRect = r;
     90        if ((phdi->fmt & HDF_BITMAP) && (phdi->hbm)) {
     91            BITMAP bmp;
     92            HDC    hdcBitmap;
     93            INT    yD, yS, cx, cy, rx, ry;
     94
     95            GetObjectA (phdi->hbm, sizeof(BITMAP), (LPVOID)&bmp);
     96
     97            ry = r.bottom - r.top;
     98            rx = r.right - r.left;
     99
     100            if (ry >= bmp.bmHeight) {
     101                cy = bmp.bmHeight;
     102                yD = r.top + (ry - bmp.bmHeight) / 2;
     103                yS = 0;
     104            }
     105            else {
     106                cy = ry;
     107                yD = r.top;
     108                yS = (bmp.bmHeight - ry) / 2;
     109
     110            }
     111
     112            if (rx >= bmp.bmWidth + 6) {
     113                cx = bmp.bmWidth;
     114            }
     115            else {
     116                cx = rx - 6;
     117            }
     118
     119            hdcBitmap = CreateCompatibleDC (hdc);
     120            SelectObject (hdcBitmap, phdi->hbm);
     121            BitBlt (hdc, r.left + 3, yD, cx, cy, hdcBitmap, 0, yS, SRCCOPY);
     122            DeleteDC (hdcBitmap);
     123
     124            r.left += (bmp.bmWidth + 3);
     125        }
     126
     127
     128        if ((phdi->fmt & HDF_BITMAP_ON_RIGHT) && (phdi->hbm)) {
     129            BITMAP bmp;
     130            HDC    hdcBitmap;
     131            INT    xD, yD, yS, cx, cy, rx, ry, tx;
     132            RECT   textRect;
     133
     134            GetObjectA (phdi->hbm, sizeof(BITMAP), (LPVOID)&bmp);
     135
     136            textRect = r;
    136137            DrawTextW (hdc, phdi->pszText, lstrlenW (phdi->pszText),
    137                   &textRect, DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_CALCRECT);
    138             tx = textRect.right - textRect.left;
    139             ry = r.bottom - r.top;
    140             rx = r.right - r.left;
    141 
    142             if (ry >= bmp.bmHeight) {
    143                 cy = bmp.bmHeight;
    144                 yD = r.top + (ry - bmp.bmHeight) / 2;
    145                 yS = 0;
    146             }
    147             else {
    148                 cy = ry;
    149                 yD = r.top;
    150                 yS = (bmp.bmHeight - ry) / 2;
    151 
    152             }
    153 
    154             if (r.left + tx + bmp.bmWidth + 9 <= r.right) {
    155                 cx = bmp.bmWidth;
    156                 xD = r.left + tx + 6;
    157             }
    158             else {
    159                 if (rx >= bmp.bmWidth + 6) {
    160                     cx = bmp.bmWidth;
    161                     xD = r.right - bmp.bmWidth - 3;
    162                     r.right = xD - 3;
    163                 }
    164                 else {
    165                     cx = rx - 3;
    166                     xD = r.left;
    167                     r.right = r.left;
    168                 }
    169             }
    170 
    171             hdcBitmap = CreateCompatibleDC (hdc);
    172             SelectObject (hdcBitmap, phdi->hbm);
    173             BitBlt (hdc, xD, yD, cx, cy, hdcBitmap, 0, yS, SRCCOPY);
    174             DeleteDC (hdcBitmap);
    175         }
    176 
    177         if (phdi->fmt & HDF_IMAGE) {
    178 
    179 
    180 /*          ImageList_Draw (infoPtr->himl, phdi->iImage,...); */
    181         }
     138                  &textRect, DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_CALCRECT);
     139            tx = textRect.right - textRect.left;
     140            ry = r.bottom - r.top;
     141            rx = r.right - r.left;
     142
     143            if (ry >= bmp.bmHeight) {
     144                cy = bmp.bmHeight;
     145                yD = r.top + (ry - bmp.bmHeight) / 2;
     146                yS = 0;
     147            }
     148            else {
     149                cy = ry;
     150                yD = r.top;
     151                yS = (bmp.bmHeight - ry) / 2;
     152
     153            }
     154
     155            if (r.left + tx + bmp.bmWidth + 9 <= r.right) {
     156                cx = bmp.bmWidth;
     157                xD = r.left + tx + 6;
     158            }
     159            else {
     160                if (rx >= bmp.bmWidth + 6) {
     161                    cx = bmp.bmWidth;
     162                    xD = r.right - bmp.bmWidth - 3;
     163                    r.right = xD - 3;
     164                }
     165                else {
     166                    cx = rx - 3;
     167                    xD = r.left;
     168                    r.right = r.left;
     169                }
     170            }
     171
     172            hdcBitmap = CreateCompatibleDC (hdc);
     173            SelectObject (hdcBitmap, phdi->hbm);
     174            BitBlt (hdc, xD, yD, cx, cy, hdcBitmap, 0, yS, SRCCOPY);
     175            DeleteDC (hdcBitmap);
     176        }
     177
     178        if (phdi->fmt & HDF_IMAGE) {
     179
     180
     181/*          ImageList_Draw (infoPtr->himl, phdi->iImage,...); */
     182        }
    182183
    183184        if ((phdi->fmt & HDF_STRING) && (phdi->pszText)) {
    184185            oldBkMode = SetBkMode(hdc, TRANSPARENT);
    185186            r.left += 3;
    186             r.right -= 3;
    187             SetTextColor (hdc, bHotTrack ? COLOR_HIGHLIGHT : COLOR_BTNTEXT);
     187            r.right -= 3;
     188            SetTextColor (hdc, bHotTrack ? COLOR_HIGHLIGHT : COLOR_BTNTEXT);
    188189            DrawTextW (hdc, phdi->pszText, lstrlenW (phdi->pszText),
    189                   &r, uTextJustify|DT_VCENTER|DT_SINGLELINE);
     190                  &r, uTextJustify|DT_VCENTER|DT_SINGLELINE);
    190191            if (oldBkMode != TRANSPARENT)
    191192                SetBkMode(hdc, oldBkMode);
     
    197198
    198199
    199 static void 
     200static void
    200201HEADER_Refresh (HWND hwnd, HDC hdc)
    201202{
     
    279280
    280281    if (infoPtr->uNumItem == 0)
    281         return;
     282        return;
    282283
    283284    x = 0;
    284285    for (i = 0; i < infoPtr->uNumItem; i++) {
    285         phdi = &infoPtr->items[i];
    286         phdi->rect.top = 0;
    287         phdi->rect.bottom = cy;
    288         phdi->rect.left = x;
    289         phdi->rect.right = phdi->rect.left + phdi->cxy;
    290         x = phdi->rect.right;
     286        phdi = &infoPtr->items[i];
     287        phdi->rect.top = 0;
     288        phdi->rect.bottom = cy;
     289        phdi->rect.left = x;
     290        phdi->rect.right = phdi->rect.left + phdi->cxy;
     291        x = phdi->rect.right;
    291292    }
    292293}
     
    307308    if (PtInRect (&rect, *lpPt))
    308309    {
    309         if (infoPtr->uNumItem == 0) {
    310             *pFlags |= HHT_NOWHERE;
    311             *pItem = 1;
    312 //          TRACE (header, "NOWHERE\n");
    313             return;
    314         }
    315         else {
    316             /* somewhere inside */
    317             for (iCount = 0; iCount < infoPtr->uNumItem; iCount++) {
    318                 rect = infoPtr->items[iCount].rect;
    319                 width = rect.right - rect.left;
    320                 if (width == 0) {
    321                     bNoWidth = TRUE;
    322                     continue;
    323                 }
    324                 if (PtInRect (&rect, *lpPt)) {
    325                     if (width <= 2 * DIVIDER_WIDTH) {
    326                         *pFlags |= HHT_ONHEADER;
    327                         *pItem = iCount;
    328 //                      TRACE (header, "ON HEADER %d\n", iCount);
    329                         return;
    330                     }
    331                     if (iCount > 0) {
    332                         rcTest = rect;
    333                         rcTest.right = rcTest.left + DIVIDER_WIDTH;
    334                         if (PtInRect (&rcTest, *lpPt)) {
    335                             if (bNoWidth) {
    336                                 *pFlags |= HHT_ONDIVOPEN;
    337                                 *pItem = iCount - 1;
    338 //                              TRACE (header, "ON DIVOPEN %d\n", *pItem);
    339                                 return;
    340                             }
    341                             else {
    342                                 *pFlags |= HHT_ONDIVIDER;
    343                                 *pItem = iCount - 1;
    344 //                              TRACE (header, "ON DIVIDER %d\n", *pItem);
    345                                 return;
    346                             }
    347                         }
    348                     }
    349                     rcTest = rect;
    350                     rcTest.left = rcTest.right - DIVIDER_WIDTH;
    351                     if (PtInRect (&rcTest, *lpPt)) {
    352                         *pFlags |= HHT_ONDIVIDER;
    353                         *pItem = iCount;
    354 //                      TRACE (header, "ON DIVIDER %d\n", *pItem);
    355                         return;
    356                     }
    357 
    358                     *pFlags |= HHT_ONHEADER;
    359                     *pItem = iCount;
    360 //                  TRACE (header, "ON HEADER %d\n", iCount);
    361                     return;
    362                 }
    363             }
    364 
    365             /* check for last divider part (on nowhere) */
    366             rect = infoPtr->items[infoPtr->uNumItem-1].rect;
    367             rect.left = rect.right;
    368             rect.right += DIVIDER_WIDTH;
    369             if (PtInRect (&rect, *lpPt)) {
    370                 if (bNoWidth) {
    371                     *pFlags |= HHT_ONDIVOPEN;
    372                     *pItem = infoPtr->uNumItem - 1;
    373 //                  TRACE (header, "ON DIVOPEN %d\n", *pItem);
    374                     return;
    375                 }
    376                 else {
    377                     *pFlags |= HHT_ONDIVIDER;
    378                     *pItem = infoPtr->uNumItem-1;
    379 //                  TRACE (header, "ON DIVIDER %d\n", *pItem);
    380                     return;
    381                 }
    382             }
    383 
    384             *pFlags |= HHT_NOWHERE;
    385             *pItem = 1;
    386 //          TRACE (header, "NOWHERE\n");
    387             return;
    388         }
     310        if (infoPtr->uNumItem == 0) {
     311            *pFlags |= HHT_NOWHERE;
     312            *pItem = 1;
     313//          TRACE (header, "NOWHERE\n");
     314            return;
     315        }
     316        else {
     317            /* somewhere inside */
     318            for (iCount = 0; iCount < infoPtr->uNumItem; iCount++) {
     319                rect = infoPtr->items[iCount].rect;
     320                width = rect.right - rect.left;
     321                if (width == 0) {
     322                    bNoWidth = TRUE;
     323                    continue;
     324                }
     325                if (PtInRect (&rect, *lpPt)) {
     326                    if (width <= 2 * DIVIDER_WIDTH) {
     327                        *pFlags |= HHT_ONHEADER;
     328                        *pItem = iCount;
     329//                      TRACE (header, "ON HEADER %d\n", iCount);
     330                        return;
     331                    }
     332                    if (iCount > 0) {
     333                        rcTest = rect;
     334                        rcTest.right = rcTest.left + DIVIDER_WIDTH;
     335                        if (PtInRect (&rcTest, *lpPt)) {
     336                            if (bNoWidth) {
     337                                *pFlags |= HHT_ONDIVOPEN;
     338                                *pItem = iCount - 1;
     339//                              TRACE (header, "ON DIVOPEN %d\n", *pItem);
     340                                return;
     341                            }
     342                            else {
     343                                *pFlags |= HHT_ONDIVIDER;
     344                                *pItem = iCount - 1;
     345//                              TRACE (header, "ON DIVIDER %d\n", *pItem);
     346                                return;
     347                            }
     348                        }
     349                    }
     350                    rcTest = rect;
     351                    rcTest.left = rcTest.right - DIVIDER_WIDTH;
     352                    if (PtInRect (&rcTest, *lpPt)) {
     353                        *pFlags |= HHT_ONDIVIDER;
     354                        *pItem = iCount;
     355//                      TRACE (header, "ON DIVIDER %d\n", *pItem);
     356                        return;
     357                    }
     358
     359                    *pFlags |= HHT_ONHEADER;
     360                    *pItem = iCount;
     361//                  TRACE (header, "ON HEADER %d\n", iCount);
     362                    return;
     363                }
     364            }
     365
     366            /* check for last divider part (on nowhere) */
     367            rect = infoPtr->items[infoPtr->uNumItem-1].rect;
     368            rect.left = rect.right;
     369            rect.right += DIVIDER_WIDTH;
     370            if (PtInRect (&rect, *lpPt)) {
     371                if (bNoWidth) {
     372                    *pFlags |= HHT_ONDIVOPEN;
     373                    *pItem = infoPtr->uNumItem - 1;
     374//                  TRACE (header, "ON DIVOPEN %d\n", *pItem);
     375                    return;
     376                }
     377                else {
     378                    *pFlags |= HHT_ONDIVIDER;
     379                    *pItem = infoPtr->uNumItem-1;
     380//                  TRACE (header, "ON DIVIDER %d\n", *pItem);
     381                    return;
     382                }
     383            }
     384
     385            *pFlags |= HHT_NOWHERE;
     386            *pItem = 1;
     387//          TRACE (header, "NOWHERE\n");
     388            return;
     389        }
    389390    }
    390391    else {
    391         if (lpPt->x < rect.left) {
    392 //         TRACE (header, "TO LEFT\n");
    393            *pFlags |= HHT_TOLEFT;
    394         }
    395         else if (lpPt->x > rect.right) {
    396 //          TRACE (header, "TO LEFT\n");
    397             *pFlags |= HHT_TORIGHT;
    398         }
    399 
    400         if (lpPt->y < rect.top) {
    401 //          TRACE (header, "ABOVE\n");
    402             *pFlags |= HHT_ABOVE;
    403         }
    404         else if (lpPt->y > rect.bottom) {
    405 //          TRACE (header, "BELOW\n");
    406             *pFlags |= HHT_BELOW;
    407         }
     392        if (lpPt->x < rect.left) {
     393//         TRACE (header, "TO LEFT\n");
     394           *pFlags |= HHT_TOLEFT;
     395        }
     396        else if (lpPt->x > rect.right) {
     397//          TRACE (header, "TO LEFT\n");
     398            *pFlags |= HHT_TORIGHT;
     399        }
     400
     401        if (lpPt->y < rect.top) {
     402//          TRACE (header, "ABOVE\n");
     403            *pFlags |= HHT_ABOVE;
     404        }
     405        else if (lpPt->y > rect.bottom) {
     406//          TRACE (header, "BELOW\n");
     407            *pFlags |= HHT_BELOW;
     408        }
    408409    }
    409410
     
    442443
    443444    return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY,
    444                                    (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
     445                                   (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
    445446}
    446447
     
    472473
    473474    return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY,
    474                                (WPARAM)nmhdr.hdr.idFrom, (LPARAM)&nmhdr);
     475                               (WPARAM)nmhdr.hdr.idFrom, (LPARAM)&nmhdr);
    475476}
    476477
     
    489490
    490491    return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY,
    491                                (WPARAM)nmhdr.hdr.idFrom, (LPARAM)&nmhdr);
     492                               (WPARAM)nmhdr.hdr.idFrom, (LPARAM)&nmhdr);
    492493}
    493494
     
    509510
    510511//    TRACE(header, "[iItem=%d]\n", iItem);
    511    
     512
    512513    if ((iItem < 0) || (iItem >= (INT)infoPtr->uNumItem))
    513514        return FALSE;
     
    550551    HEADER_Refresh (hwnd, hdc);
    551552    ReleaseDC (hwnd, hdc);
    552    
     553
    553554    return TRUE;
    554555}
     
    573574
    574575    if (!phdi)
    575         return FALSE;
     576        return FALSE;
    576577    if ((nItem < 0) || (nItem >= (INT)infoPtr->uNumItem))
    577578        return FALSE;
     
    580581
    581582    if (phdi->mask == 0)
    582         return TRUE;
     583        return TRUE;
    583584
    584585    lpItem = (HEADER_ITEM*)&infoPtr->items[nItem];
    585586    if (phdi->mask & HDI_BITMAP)
    586         phdi->hbm = lpItem->hbm;
     587        phdi->hbm = lpItem->hbm;
    587588
    588589    if (phdi->mask & HDI_FORMAT)
    589         phdi->fmt = lpItem->fmt;
     590        phdi->fmt = lpItem->fmt;
    590591
    591592    if (phdi->mask & HDI_WIDTH)
    592         phdi->cxy = lpItem->cxy;
     593        phdi->cxy = lpItem->cxy;
    593594
    594595    if (phdi->mask & HDI_LPARAM)
    595         phdi->lParam = lpItem->lParam;
     596        phdi->lParam = lpItem->lParam;
    596597
    597598    if (phdi->mask & HDI_TEXT) {
    598         if (lpItem->pszText != LPSTR_TEXTCALLBACKW)
    599             lstrcpynWtoA (phdi->pszText, lpItem->pszText, phdi->cchTextMax);
    600         else
    601             phdi->pszText = LPSTR_TEXTCALLBACKA;
     599        if (lpItem->pszText != LPSTR_TEXTCALLBACKW)
     600            lstrcpynWtoA (phdi->pszText, lpItem->pszText, MIN(phdi->cchTextMax,lstrlenW(lpItem->pszText)));
     601        else
     602            phdi->pszText = LPSTR_TEXTCALLBACKA;
    602603    }
    603604
    604605    if (phdi->mask & HDI_IMAGE)
    605         phdi->iImage = lpItem->iImage;
     606        phdi->iImage = lpItem->iImage;
    606607
    607608    if (phdi->mask & HDI_ORDER)
    608         phdi->iOrder = lpItem->iOrder;
     609        phdi->iOrder = lpItem->iOrder;
    609610
    610611    return TRUE;
     
    621622
    622623    if (!phdi)
    623         return FALSE;
     624        return FALSE;
    624625    if ((nItem < 0) || (nItem >= (INT)infoPtr->uNumItem))
    625626        return FALSE;
     
    628629
    629630    if (phdi->mask == 0)
    630         return TRUE;
     631        return TRUE;
    631632
    632633    lpItem = (HEADER_ITEM*)&infoPtr->items[nItem];
    633634    if (phdi->mask & HDI_BITMAP)
    634         phdi->hbm = lpItem->hbm;
     635        phdi->hbm = lpItem->hbm;
    635636
    636637    if (phdi->mask & HDI_FORMAT)
    637         phdi->fmt = lpItem->fmt;
     638        phdi->fmt = lpItem->fmt;
    638639
    639640    if (phdi->mask & HDI_WIDTH)
    640         phdi->cxy = lpItem->cxy;
     641        phdi->cxy = lpItem->cxy;
    641642
    642643    if (phdi->mask & HDI_LPARAM)
    643         phdi->lParam = lpItem->lParam;
     644        phdi->lParam = lpItem->lParam;
    644645
    645646    if (phdi->mask & HDI_TEXT) {
    646         if (lpItem->pszText != LPSTR_TEXTCALLBACKW)
    647             lstrcpynW (phdi->pszText, lpItem->pszText, phdi->cchTextMax);
    648         else
    649             phdi->pszText = LPSTR_TEXTCALLBACKW;
     647        if (lpItem->pszText != LPSTR_TEXTCALLBACKW)
     648            lstrcpynW (phdi->pszText, lpItem->pszText, MIN(phdi->cchTextMax,lstrlenW(lpItem->pszText)));
     649        else
     650            phdi->pszText = LPSTR_TEXTCALLBACKW;
    650651    }
    651652
    652653    if (phdi->mask & HDI_IMAGE)
    653         phdi->iImage = lpItem->iImage;
     654        phdi->iImage = lpItem->iImage;
    654655
    655656    if (phdi->mask & HDI_ORDER)
    656         phdi->iOrder = lpItem->iOrder;
     657        phdi->iOrder = lpItem->iOrder;
    657658
    658659    return TRUE;
     
    720721
    721722    if ((phdi == NULL) || (nItem < 0))
    722         return -1;
     723        return -1;
    723724
    724725    if (nItem > infoPtr->uNumItem)
     
    752753            }
    753754        }
    754    
     755
    755756        COMCTL32_Free (oldItems);
    756757    }
     
    760761
    761762    if (phdi->mask & HDI_WIDTH)
    762         lpItem->cxy = phdi->cxy;
     763        lpItem->cxy = phdi->cxy;
    763764
    764765    if (phdi->mask & HDI_TEXT) {
    765         if (!phdi->pszText) /* null pointer check */
    766             phdi->pszText = "";
    767         if (phdi->pszText != LPSTR_TEXTCALLBACKA) {
    768             len = lstrlenA (phdi->pszText);
    769             lpItem->pszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    770             lstrcpyAtoW (lpItem->pszText, phdi->pszText);
    771         }
    772         else
    773             lpItem->pszText = LPSTR_TEXTCALLBACKW;
     766        if (!phdi->pszText) /* null pointer check */
     767            phdi->pszText = "";
     768        if (phdi->pszText != LPSTR_TEXTCALLBACKA) {
     769            len = lstrlenA (phdi->pszText);
     770            lpItem->pszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     771            lstrcpyAtoW (lpItem->pszText, phdi->pszText);
     772        }
     773        else
     774            lpItem->pszText = LPSTR_TEXTCALLBACKW;
    774775    }
    775776
    776777    if (phdi->mask & HDI_FORMAT)
    777         lpItem->fmt = phdi->fmt;
     778        lpItem->fmt = phdi->fmt;
    778779
    779780    if (lpItem->fmt == 0)
    780         lpItem->fmt = HDF_LEFT;
     781        lpItem->fmt = HDF_LEFT;
    781782
    782783    if (phdi->mask & HDI_BITMAP)
     
    813814
    814815    if ((phdi == NULL) || (nItem < 0))
    815         return -1;
     816        return -1;
    816817
    817818    if (nItem > infoPtr->uNumItem)
     
    839840        }
    840841
    841         COMCTL32_Free (oldItems);
     842        COMCTL32_Free (oldItems);
    842843    }
    843844
     
    846847
    847848    if (phdi->mask & HDI_WIDTH)
    848         lpItem->cxy = phdi->cxy;
     849        lpItem->cxy = phdi->cxy;
    849850
    850851    if (phdi->mask & HDI_TEXT) {
    851         WCHAR wide_null_char = 0;
    852         if (!phdi->pszText) /* null pointer check */
    853             phdi->pszText = &wide_null_char;   
    854         if (phdi->pszText != LPSTR_TEXTCALLBACKW) {
    855             len = lstrlenW (phdi->pszText);
    856             lpItem->pszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    857             lstrcpyW (lpItem->pszText, phdi->pszText);
    858         }
    859         else
    860             lpItem->pszText = LPSTR_TEXTCALLBACKW;
     852        WCHAR wide_null_char = 0;
     853        if (!phdi->pszText) /* null pointer check */
     854            phdi->pszText = &wide_null_char;
     855        if (phdi->pszText != LPSTR_TEXTCALLBACKW) {
     856            len = lstrlenW (phdi->pszText);
     857            lpItem->pszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     858            lstrcpyW (lpItem->pszText, phdi->pszText);
     859        }
     860        else
     861            lpItem->pszText = LPSTR_TEXTCALLBACKW;
    861862    }
    862863
    863864    if (phdi->mask & HDI_FORMAT)
    864         lpItem->fmt = phdi->fmt;
     865        lpItem->fmt = phdi->fmt;
    865866
    866867    if (lpItem->fmt == 0)
    867         lpItem->fmt = HDF_LEFT;
     868        lpItem->fmt = HDF_LEFT;
    868869
    869870    if (phdi->mask & HDI_BITMAP)
     
    947948
    948949    if (phdi == NULL)
    949         return FALSE;
     950        return FALSE;
    950951    if ((nItem < 0) || (nItem >= (INT)infoPtr->uNumItem))
    951952        return FALSE;
     
    954955
    955956    if (HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGINGA, nItem))
    956         return FALSE;
     957        return FALSE;
    957958
    958959    lpItem = (HEADER_ITEM*)&infoPtr->items[nItem];
    959960    if (phdi->mask & HDI_BITMAP)
    960         lpItem->hbm = phdi->hbm;
     961        lpItem->hbm = phdi->hbm;
    961962
    962963    if (phdi->mask & HDI_FORMAT)
    963         lpItem->fmt = phdi->fmt;
     964        lpItem->fmt = phdi->fmt;
    964965
    965966    if (phdi->mask & HDI_LPARAM)
    966         lpItem->lParam = phdi->lParam;
     967        lpItem->lParam = phdi->lParam;
    967968
    968969    if (phdi->mask & HDI_TEXT) {
    969         if (phdi->pszText != LPSTR_TEXTCALLBACKA) {
    970             if (lpItem->pszText) {
    971                 COMCTL32_Free (lpItem->pszText);
    972                 lpItem->pszText = NULL;
    973             }
    974             if (phdi->pszText) {
    975                 INT len = lstrlenA (phdi->pszText);
    976                 lpItem->pszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    977                 lstrcpyAtoW (lpItem->pszText, phdi->pszText);
    978             }
    979         }
    980         else
    981             lpItem->pszText = LPSTR_TEXTCALLBACKW;
     970        if (phdi->pszText != LPSTR_TEXTCALLBACKA) {
     971            if (lpItem->pszText) {
     972                COMCTL32_Free (lpItem->pszText);
     973                lpItem->pszText = NULL;
     974            }
     975            if (phdi->pszText) {
     976                INT len = lstrlenA (phdi->pszText);
     977                lpItem->pszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     978                lstrcpyAtoW (lpItem->pszText, phdi->pszText);
     979            }
     980        }
     981        else
     982            lpItem->pszText = LPSTR_TEXTCALLBACKW;
    982983    }
    983984
    984985    if (phdi->mask & HDI_WIDTH)
    985         lpItem->cxy = phdi->cxy;
     986        lpItem->cxy = phdi->cxy;
    986987
    987988    if (phdi->mask & HDI_IMAGE)
    988         lpItem->iImage = phdi->iImage;
     989        lpItem->iImage = phdi->iImage;
    989990
    990991    if (phdi->mask & HDI_ORDER)
    991         lpItem->iOrder = phdi->iOrder;
     992        lpItem->iOrder = phdi->iOrder;
    992993
    993994    HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGEDA, nItem);
     
    10121013
    10131014    if (phdi == NULL)
    1014         return FALSE;
     1015        return FALSE;
    10151016    if ((nItem < 0) || (nItem >= (INT)infoPtr->uNumItem))
    10161017        return FALSE;
     
    10191020
    10201021    if (HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGINGA, nItem))
    1021         return FALSE;
     1022        return FALSE;
    10221023
    10231024    lpItem = (HEADER_ITEM*)&infoPtr->items[nItem];
    10241025    if (phdi->mask & HDI_BITMAP)
    1025         lpItem->hbm = phdi->hbm;
     1026        lpItem->hbm = phdi->hbm;
    10261027
    10271028    if (phdi->mask & HDI_FORMAT)
    1028         lpItem->fmt = phdi->fmt;
     1029        lpItem->fmt = phdi->fmt;
    10291030
    10301031    if (phdi->mask & HDI_LPARAM)
    1031         lpItem->lParam = phdi->lParam;
     1032        lpItem->lParam = phdi->lParam;
    10321033
    10331034    if (phdi->mask & HDI_TEXT) {
    1034         if (phdi->pszText != LPSTR_TEXTCALLBACKW) {
    1035             if (lpItem->pszText) {
    1036                 COMCTL32_Free (lpItem->pszText);
    1037                 lpItem->pszText = NULL;
    1038             }
    1039             if (phdi->pszText) {
    1040                 INT len = lstrlenW (phdi->pszText);
    1041                 lpItem->pszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    1042                 lstrcpyW (lpItem->pszText, phdi->pszText);
    1043             }
    1044         }
    1045         else
    1046             lpItem->pszText = LPSTR_TEXTCALLBACKW;
     1035        if (phdi->pszText != LPSTR_TEXTCALLBACKW) {
     1036            if (lpItem->pszText) {
     1037                COMCTL32_Free (lpItem->pszText);
     1038                lpItem->pszText = NULL;
     1039            }
     1040            if (phdi->pszText) {
     1041                INT len = lstrlenW (phdi->pszText);
     1042                lpItem->pszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1043                lstrcpyW (lpItem->pszText, phdi->pszText);
     1044            }
     1045        }
     1046        else
     1047            lpItem->pszText = LPSTR_TEXTCALLBACKW;
    10471048    }
    10481049
    10491050    if (phdi->mask & HDI_WIDTH)
    1050         lpItem->cxy = phdi->cxy;
     1051        lpItem->cxy = phdi->cxy;
    10511052
    10521053    if (phdi->mask & HDI_IMAGE)
    1053         lpItem->iImage = phdi->iImage;
     1054        lpItem->iImage = phdi->iImage;
    10541055
    10551056    if (phdi->mask & HDI_ORDER)
    1056         lpItem->iOrder = phdi->iOrder;
     1057        lpItem->iOrder = phdi->iOrder;
    10571058
    10581059    HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGEDA, nItem);
     
    11261127
    11271128    if (infoPtr->items) {
    1128         lpItem = (HEADER_ITEM*)infoPtr->items;
     1129        lpItem = (HEADER_ITEM*)infoPtr->items;
    11291130        for (nItem = 0; nItem < infoPtr->uNumItem; nItem++, lpItem++) {
    1130             if ((lpItem->pszText) && (lpItem->pszText != LPSTR_TEXTCALLBACKW))
    1131                 COMCTL32_Free (lpItem->pszText);
     1131            if ((lpItem->pszText) && (lpItem->pszText != LPSTR_TEXTCALLBACKW))
     1132                COMCTL32_Free (lpItem->pszText);
    11321133        }
    11331134        COMCTL32_Free (infoPtr->items);
     
    11351136
    11361137    if (infoPtr->himl)
    1137         ImageList_Destroy (infoPtr->himl);
     1138        ImageList_Destroy (infoPtr->himl);
    11381139
    11391140    COMCTL32_Free (infoPtr);
     
    11591160    INT   nItem;
    11601161
    1161     pt.x = (INT)LOWORD(lParam); 
     1162    pt.x = (INT)LOWORD(lParam);
    11621163    pt.y = (INT)HIWORD(lParam);
    11631164    HEADER_InternalHitTest (hwnd, &pt, &flags, &nItem);
    11641165
    11651166    if ((GetWindowLongA (hwnd, GWL_STYLE) & HDS_BUTTONS) && (flags == HHT_ONHEADER))
    1166         HEADER_SendHeaderNotify (hwnd, HDN_ITEMDBLCLICKA, nItem);
     1167        HEADER_SendHeaderNotify (hwnd, HDN_ITEMDBLCLICKA, nItem);
    11671168    else if ((flags == HHT_ONDIVIDER) || (flags == HHT_ONDIVOPEN))
    1168         HEADER_SendHeaderNotify (hwnd, HDN_DIVIDERDBLCLICKA, nItem);
     1169        HEADER_SendHeaderNotify (hwnd, HDN_DIVIDERDBLCLICKA, nItem);
    11691170
    11701171    return 0;
     
    11821183    HDC   hdc;
    11831184
    1184     pt.x = (INT)LOWORD(lParam); 
     1185    pt.x = (INT)LOWORD(lParam);
    11851186    pt.y = (INT)HIWORD(lParam);
    11861187    HEADER_InternalHitTest (hwnd, &pt, &flags, &nItem);
    11871188
    11881189    if ((dwStyle & HDS_BUTTONS) && (flags == HHT_ONHEADER)) {
    1189         SetCapture (hwnd);
    1190         infoPtr->bCaptured = TRUE;   
    1191         infoPtr->bPressed  = TRUE;
    1192         infoPtr->iMoveItem = nItem;
    1193 
    1194         infoPtr->items[nItem].bDown = TRUE;
    1195 
    1196         /* Send WM_CUSTOMDRAW */
    1197         hdc = GetDC (hwnd);
    1198         HEADER_RefreshItem (hwnd, hdc, nItem);
    1199         ReleaseDC (hwnd, hdc);
    1200 
    1201 //      TRACE (header, "Pressed item %d!\n", nItem);
    1202     } 
     1190        SetCapture (hwnd);
     1191        infoPtr->bCaptured = TRUE;
     1192        infoPtr->bPressed  = TRUE;
     1193        infoPtr->iMoveItem = nItem;
     1194
     1195        infoPtr->items[nItem].bDown = TRUE;
     1196
     1197        /* Send WM_CUSTOMDRAW */
     1198        hdc = GetDC (hwnd);
     1199        HEADER_RefreshItem (hwnd, hdc, nItem);
     1200        ReleaseDC (hwnd, hdc);
     1201
     1202//      TRACE (header, "Pressed item %d!\n", nItem);
     1203    }
    12031204    else if ((flags == HHT_ONDIVIDER) || (flags == HHT_ONDIVOPEN)) {
    1204         if (!(HEADER_SendHeaderNotify (hwnd, HDN_BEGINTRACKA, nItem))) {
    1205             SetCapture (hwnd);
    1206             infoPtr->bCaptured = TRUE;   
    1207             infoPtr->bTracking = TRUE;
    1208             infoPtr->iMoveItem = nItem;
    1209             infoPtr->nOldWidth = infoPtr->items[nItem].cxy;
    1210             infoPtr->xTrackOffset = infoPtr->items[nItem].rect.right - pt.x;
    1211 
    1212             if (!(dwStyle & HDS_FULLDRAG)) {
    1213                 infoPtr->xOldTrack = infoPtr->items[nItem].rect.right;
    1214                 hdc = GetDC (hwnd);
    1215                 HEADER_DrawTrackLine (hwnd, hdc, infoPtr->xOldTrack);
    1216                 ReleaseDC (hwnd, hdc);
    1217             }
    1218 
    1219 //          TRACE (header, "Begin tracking item %d!\n", nItem);
    1220         }
     1205        if (!(HEADER_SendHeaderNotify (hwnd, HDN_BEGINTRACKA, nItem))) {
     1206            SetCapture (hwnd);
     1207            infoPtr->bCaptured = TRUE;
     1208            infoPtr->bTracking = TRUE;
     1209            infoPtr->iMoveItem = nItem;
     1210            infoPtr->nOldWidth = infoPtr->items[nItem].cxy;
     1211            infoPtr->xTrackOffset = infoPtr->items[nItem].rect.right - pt.x;
     1212
     1213            if (!(dwStyle & HDS_FULLDRAG)) {
     1214                infoPtr->xOldTrack = infoPtr->items[nItem].rect.right;
     1215                hdc = GetDC (hwnd);
     1216                HEADER_DrawTrackLine (hwnd, hdc, infoPtr->xOldTrack);
     1217                ReleaseDC (hwnd, hdc);
     1218            }
     1219
     1220//          TRACE (header, "Begin tracking item %d!\n", nItem);
     1221        }
    12211222    }
    12221223
     
    12401241
    12411242    if (infoPtr->bPressed) {
    1242         if ((nItem == infoPtr->iMoveItem) && (flags == HHT_ONHEADER)) {
    1243             infoPtr->items[infoPtr->iMoveItem].bDown = FALSE;
    1244             hdc = GetDC (hwnd);
    1245             HEADER_RefreshItem (hwnd, hdc, infoPtr->iMoveItem);
    1246             ReleaseDC (hwnd, hdc);
    1247 
    1248             HEADER_SendClickNotify (hwnd, HDN_ITEMCLICKA, infoPtr->iMoveItem);
    1249         }
    1250 //      TRACE (header, "Released item %d!\n", infoPtr->iMoveItem);
    1251         infoPtr->bPressed = FALSE;
     1243        if ((nItem == infoPtr->iMoveItem) && (flags == HHT_ONHEADER)) {
     1244            infoPtr->items[infoPtr->iMoveItem].bDown = FALSE;
     1245            hdc = GetDC (hwnd);
     1246            HEADER_RefreshItem (hwnd, hdc, infoPtr->iMoveItem);
     1247            ReleaseDC (hwnd, hdc);
     1248
     1249            HEADER_SendClickNotify (hwnd, HDN_ITEMCLICKA, infoPtr->iMoveItem);
     1250        }
     1251//      TRACE (header, "Released item %d!\n", infoPtr->iMoveItem);
     1252        infoPtr->bPressed = FALSE;
    12521253    }
    12531254    else if (infoPtr->bTracking) {
    1254 //      TRACE (header, "End tracking item %d!\n", infoPtr->iMoveItem);
    1255         infoPtr->bTracking = FALSE;
    1256 
    1257         HEADER_SendHeaderNotify (hwnd, HDN_ENDTRACKA, infoPtr->iMoveItem);
    1258 
    1259         if (!(dwStyle & HDS_FULLDRAG)) {
    1260             hdc = GetDC (hwnd);
    1261             HEADER_DrawTrackLine (hwnd, hdc, infoPtr->xOldTrack);
    1262             ReleaseDC (hwnd, hdc);
    1263             if (HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGINGA, infoPtr->iMoveItem))
    1264                 infoPtr->items[infoPtr->iMoveItem].cxy = infoPtr->nOldWidth;
    1265             else {
    1266                 nWidth = pt.x - infoPtr->items[infoPtr->iMoveItem].rect.left + infoPtr->xTrackOffset;
    1267                 if (nWidth < 0)
    1268                     nWidth = 0;
    1269                 infoPtr->items[infoPtr->iMoveItem].cxy = nWidth;
    1270                 HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGEDA, infoPtr->iMoveItem);
    1271             }
    1272 
    1273             HEADER_SetItemBounds (hwnd);
    1274             hdc = GetDC (hwnd);
    1275             HEADER_Refresh (hwnd, hdc);
    1276             ReleaseDC (hwnd, hdc);
    1277         }
     1255//      TRACE (header, "End tracking item %d!\n", infoPtr->iMoveItem);
     1256        infoPtr->bTracking = FALSE;
     1257
     1258        HEADER_SendHeaderNotify (hwnd, HDN_ENDTRACKA, infoPtr->iMoveItem);
     1259
     1260        if (!(dwStyle & HDS_FULLDRAG)) {
     1261            hdc = GetDC (hwnd);
     1262            HEADER_DrawTrackLine (hwnd, hdc, infoPtr->xOldTrack);
     1263            ReleaseDC (hwnd, hdc);
     1264            if (HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGINGA, infoPtr->iMoveItem))
     1265                infoPtr->items[infoPtr->iMoveItem].cxy = infoPtr->nOldWidth;
     1266            else {
     1267                nWidth = pt.x - infoPtr->items[infoPtr->iMoveItem].rect.left + infoPtr->xTrackOffset;
     1268                if (nWidth < 0)
     1269                    nWidth = 0;
     1270                infoPtr->items[infoPtr->iMoveItem].cxy = nWidth;
     1271                HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGEDA, infoPtr->iMoveItem);
     1272            }
     1273
     1274            HEADER_SetItemBounds (hwnd);
     1275            hdc = GetDC (hwnd);
     1276            HEADER_Refresh (hwnd, hdc);
     1277            ReleaseDC (hwnd, hdc);
     1278        }
    12781279    }
    12791280
    12801281    if (infoPtr->bCaptured) {
    1281         infoPtr->bCaptured = FALSE;
    1282         ReleaseCapture ();
    1283         HEADER_SendSimpleNotify (hwnd, NM_RELEASEDCAPTURE);
     1282        infoPtr->bCaptured = FALSE;
     1283        ReleaseCapture ();
     1284        HEADER_SendSimpleNotify (hwnd, NM_RELEASEDCAPTURE);
    12841285    }
    12851286
     
    13031304
    13041305    if ((dwStyle & HDS_BUTTONS) && (dwStyle & HDS_HOTTRACK)) {
    1305         if (flags & (HHT_ONHEADER | HHT_ONDIVIDER | HHT_ONDIVOPEN))
    1306             infoPtr->iHotItem = nItem;
    1307         else
    1308             infoPtr->iHotItem = -1;
    1309         hdc = GetDC (hwnd);
    1310         HEADER_Refresh (hwnd, hdc);
    1311         ReleaseDC (hwnd, hdc);
     1306        if (flags & (HHT_ONHEADER | HHT_ONDIVIDER | HHT_ONDIVOPEN))
     1307            infoPtr->iHotItem = nItem;
     1308        else
     1309            infoPtr->iHotItem = -1;
     1310        hdc = GetDC (hwnd);
     1311        HEADER_Refresh (hwnd, hdc);
     1312        ReleaseDC (hwnd, hdc);
    13121313    }
    13131314
    13141315    if (infoPtr->bCaptured) {
    1315         if (infoPtr->bPressed) {
    1316             if ((nItem == infoPtr->iMoveItem) && (flags == HHT_ONHEADER))
    1317                 infoPtr->items[infoPtr->iMoveItem].bDown = TRUE;
    1318             else
    1319                 infoPtr->items[infoPtr->iMoveItem].bDown = FALSE;
    1320             hdc = GetDC (hwnd);
    1321             HEADER_RefreshItem (hwnd, hdc, infoPtr->iMoveItem);
    1322             ReleaseDC (hwnd, hdc);
    1323 
    1324 //          TRACE (header, "Moving pressed item %d!\n", infoPtr->iMoveItem);
    1325         }
    1326         else if (infoPtr->bTracking) {
    1327             if (dwStyle & HDS_FULLDRAG) {
    1328                 if (HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGINGA, infoPtr->iMoveItem))
    1329                     infoPtr->items[infoPtr->iMoveItem].cxy = infoPtr->nOldWidth;
    1330                 else {
    1331                     nWidth = pt.x - infoPtr->items[infoPtr->iMoveItem].rect.left + infoPtr->xTrackOffset;
    1332                     if (nWidth < 0)
    1333                         nWidth = 0;
    1334                     infoPtr->items[infoPtr->iMoveItem].cxy = nWidth;
    1335                     HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGEDA,
    1336                                              infoPtr->iMoveItem);
    1337                 }
    1338                 HEADER_SetItemBounds (hwnd);
    1339                 hdc = GetDC (hwnd);
    1340                 HEADER_Refresh (hwnd, hdc);
    1341                 ReleaseDC (hwnd, hdc);
    1342             }
    1343             else {
    1344                 hdc = GetDC (hwnd);
    1345                 HEADER_DrawTrackLine (hwnd, hdc, infoPtr->xOldTrack);
    1346                 infoPtr->xOldTrack = pt.x + infoPtr->xTrackOffset;
    1347                 if (infoPtr->xOldTrack < infoPtr->items[infoPtr->iMoveItem].rect.left)
    1348                     infoPtr->xOldTrack = infoPtr->items[infoPtr->iMoveItem].rect.left;
    1349                 infoPtr->items[infoPtr->iMoveItem].cxy =
    1350                     infoPtr->xOldTrack - infoPtr->items[infoPtr->iMoveItem].rect.left;
    1351                 HEADER_DrawTrackLine (hwnd, hdc, infoPtr->xOldTrack);
    1352                 ReleaseDC (hwnd, hdc);
    1353             }
    1354 
    1355             HEADER_SendHeaderNotify (hwnd, HDN_TRACKA, infoPtr->iMoveItem);
    1356 //          TRACE (header, "Tracking item %d!\n", infoPtr->iMoveItem);
    1357         }
     1316        if (infoPtr->bPressed) {
     1317            if ((nItem == infoPtr->iMoveItem) && (flags == HHT_ONHEADER))
     1318                infoPtr->items[infoPtr->iMoveItem].bDown = TRUE;
     1319            else
     1320                infoPtr->items[infoPtr->iMoveItem].bDown = FALSE;
     1321            hdc = GetDC (hwnd);
     1322            HEADER_RefreshItem (hwnd, hdc, infoPtr->iMoveItem);
     1323            ReleaseDC (hwnd, hdc);
     1324
     1325//          TRACE (header, "Moving pressed item %d!\n", infoPtr->iMoveItem);
     1326        }
     1327        else if (infoPtr->bTracking) {
     1328            if (dwStyle & HDS_FULLDRAG) {
     1329                if (HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGINGA, infoPtr->iMoveItem))
     1330                    infoPtr->items[infoPtr->iMoveItem].cxy = infoPtr->nOldWidth;
     1331                else {
     1332                    nWidth = pt.x - infoPtr->items[infoPtr->iMoveItem].rect.left + infoPtr->xTrackOffset;
     1333                    if (nWidth < 0)
     1334                        nWidth = 0;
     1335                    infoPtr->items[infoPtr->iMoveItem].cxy = nWidth;
     1336                    HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGEDA,
     1337                                             infoPtr->iMoveItem);
     1338                }
     1339                HEADER_SetItemBounds (hwnd);
     1340                hdc = GetDC (hwnd);
     1341                HEADER_Refresh (hwnd, hdc);
     1342                ReleaseDC (hwnd, hdc);
     1343            }
     1344            else {
     1345                hdc = GetDC (hwnd);
     1346                HEADER_DrawTrackLine (hwnd, hdc, infoPtr->xOldTrack);
     1347                infoPtr->xOldTrack = pt.x + infoPtr->xTrackOffset;
     1348                if (infoPtr->xOldTrack < infoPtr->items[infoPtr->iMoveItem].rect.left)
     1349                    infoPtr->xOldTrack = infoPtr->items[infoPtr->iMoveItem].rect.left;
     1350                infoPtr->items[infoPtr->iMoveItem].cxy =
     1351                    infoPtr->xOldTrack - infoPtr->items[infoPtr->iMoveItem].rect.left;
     1352                HEADER_DrawTrackLine (hwnd, hdc, infoPtr->xOldTrack);
     1353                ReleaseDC (hwnd, hdc);
     1354            }
     1355
     1356            HEADER_SendHeaderNotify (hwnd, HDN_TRACKA, infoPtr->iMoveItem);
     1357//          TRACE (header, "Tracking item %d!\n", infoPtr->iMoveItem);
     1358        }
    13581359    }
    13591360
    13601361    if ((dwStyle & HDS_BUTTONS) && (dwStyle & HDS_HOTTRACK)) {
    1361 //      FIXME (header, "hot track support!\n");
     1362//      FIXME (header, "hot track support!\n");
    13621363    }
    13631364
     
    13751376    HEADER_Refresh (hwnd, hdc);
    13761377    if(!wParam)
    1377         EndPaint (hwnd, &ps);
     1378        EndPaint (hwnd, &ps);
    13781379    return 0;
    13791380}
     
    14471448{
    14481449    switch (msg) {
    1449         case HDM_CREATEDRAGIMAGE:
    1450             return HEADER_CreateDragImage (hwnd, wParam);
    1451 
    1452         case HDM_DELETEITEM:
    1453             return HEADER_DeleteItem (hwnd, wParam);
    1454 
    1455         case HDM_GETIMAGELIST:
    1456             return HEADER_GetImageList (hwnd);
    1457 
    1458         case HDM_GETITEMA:
    1459             return HEADER_GetItemA (hwnd, wParam, lParam);
    1460 
    1461         case HDM_GETITEMW:
    1462             return HEADER_GetItemW (hwnd, wParam, lParam);
    1463 
    1464         case HDM_GETITEMCOUNT:
    1465             return HEADER_GetItemCount (hwnd);
    1466 
    1467         case HDM_GETITEMRECT:
    1468             return HEADER_GetItemRect (hwnd, wParam, lParam);
    1469 
    1470 /*      case HDM_GETORDERARRAY: */
    1471 
    1472         case HDM_GETUNICODEFORMAT:
    1473             return HEADER_GetUnicodeFormat (hwnd);
    1474 
    1475         case HDM_HITTEST:
    1476             return HEADER_HitTest (hwnd, wParam, lParam);
    1477 
    1478         case HDM_INSERTITEMA:
    1479             return HEADER_InsertItemA (hwnd, wParam, lParam);
    1480 
    1481         case HDM_INSERTITEMW:
    1482             return HEADER_InsertItemW (hwnd, wParam, lParam);
    1483 
    1484         case HDM_LAYOUT:
    1485             return HEADER_Layout (hwnd, wParam, lParam);
    1486 
    1487         case HDM_SETIMAGELIST:
    1488             return HEADER_SetImageList (hwnd, wParam, lParam);
    1489 
    1490         case HDM_SETITEMA:
    1491             return HEADER_SetItemA (hwnd, wParam, lParam);
    1492 
    1493         case HDM_SETITEMW:
    1494             return HEADER_SetItemW (hwnd, wParam, lParam);
    1495 
    1496 /*      case HDM_SETORDERARRAY: */
    1497 
    1498         case HDM_SETUNICODEFORMAT:
    1499             return HEADER_SetUnicodeFormat (hwnd, wParam);
     1450        case HDM_CREATEDRAGIMAGE:
     1451            return HEADER_CreateDragImage (hwnd, wParam);
     1452
     1453        case HDM_DELETEITEM:
     1454            return HEADER_DeleteItem (hwnd, wParam);
     1455
     1456        case HDM_GETIMAGELIST:
     1457            return HEADER_GetImageList (hwnd);
     1458
     1459        case HDM_GETITEMA:
     1460            return HEADER_GetItemA (hwnd, wParam, lParam);
     1461
     1462        case HDM_GETITEMW:
     1463            return HEADER_GetItemW (hwnd, wParam, lParam);
     1464
     1465        case HDM_GETITEMCOUNT:
     1466            return HEADER_GetItemCount (hwnd);
     1467
     1468        case HDM_GETITEMRECT:
     1469            return HEADER_GetItemRect (hwnd, wParam, lParam);
     1470
     1471/*      case HDM_GETORDERARRAY: */
     1472
     1473        case HDM_GETUNICODEFORMAT:
     1474            return HEADER_GetUnicodeFormat (hwnd);
     1475
     1476        case HDM_HITTEST:
     1477            return HEADER_HitTest (hwnd, wParam, lParam);
     1478
     1479        case HDM_INSERTITEMA:
     1480            return HEADER_InsertItemA (hwnd, wParam, lParam);
     1481
     1482        case HDM_INSERTITEMW:
     1483            return HEADER_InsertItemW (hwnd, wParam, lParam);
     1484
     1485        case HDM_LAYOUT:
     1486            return HEADER_Layout (hwnd, wParam, lParam);
     1487
     1488        case HDM_SETIMAGELIST:
     1489            return HEADER_SetImageList (hwnd, wParam, lParam);
     1490
     1491        case HDM_SETITEMA:
     1492            return HEADER_SetItemA (hwnd, wParam, lParam);
     1493
     1494        case HDM_SETITEMW:
     1495            return HEADER_SetItemW (hwnd, wParam, lParam);
     1496
     1497/*      case HDM_SETORDERARRAY: */
     1498
     1499        case HDM_SETUNICODEFORMAT:
     1500            return HEADER_SetUnicodeFormat (hwnd, wParam);
    15001501
    15011502
     
    15271528            return HEADER_MouseMove (hwnd, wParam, lParam);
    15281529
    1529 /*      case WM_NOTIFYFORMAT: */
     1530/*      case WM_NOTIFYFORMAT: */
    15301531
    15311532        case WM_PAINT:
     
    15421543
    15431544        default:
    1544 //            if (msg >= WM_USER) 
    1545 //              ERR (header, "unknown msg %04x wp=%04x lp=%08lx\n",
    1546 //                   msg, wParam, lParam );
    1547             return DefWindowProcA (hwnd, msg, wParam, lParam);
     1545//            if (msg >= WM_USER)
     1546//              ERR (header, "unknown msg %04x wp=%04x lp=%08lx\n",
     1547//                   msg, wParam, lParam );
     1548            return DefWindowProcA (hwnd, msg, wParam, lParam);
    15481549    }
    15491550    return 0;
     
    15651566    wndClass.hCursor       = LoadCursorA (0, IDC_ARROWA);
    15661567    wndClass.lpszClassName = WC_HEADERA;
    1567  
     1568
    15681569    RegisterClassA (&wndClass);
    15691570}
     
    15741575{
    15751576    if (GlobalFindAtomA (WC_HEADERA))
    1576         UnregisterClassA (WC_HEADERA, (HINSTANCE)NULL);
    1577 }
    1578 
     1577        UnregisterClassA (WC_HEADERA, (HINSTANCE)NULL);
     1578}
     1579
  • trunk/src/comctl32/listview.c

    r164 r236  
    55 * Copyright 1999 Luc Tourangeau
    66 * Copyright 1999 Achim Hasenmueller
     7 * Copyright 1999 Christoph Bratschi
    78 *
    89 * NOTES
    9  * Listview control implementation. 
     10 * Listview control implementation.
    1011 *
    1112 * TODO:
     
    1718 *
    1819 * Data structure:
    19  *   LISTVIEW_SetItemCount : empty stub 
    20  * 
     20 *   LISTVIEW_SetItemCount : empty stub
     21 *
    2122 * Unicode:
    2223 *   LISTVIEW_SetItem32W : no unicode support
     
    3031 *   LISTVIEW_GetHotItem : not implemented
    3132 *   LISTVIEW_GetHoverTime : not implemented
    32  *   LISTVIEW_GetISearchString : not implemented 
     33 *   LISTVIEW_GetISearchString : not implemented
    3334 *   LISTVIEW_GetBkImage : not implemented
    3435 *   LISTVIEW_EditLabel : REPORT (need to implement a timer)
     
    3637 *   LISTVIEW_Arrange : empty stub
    3738 *   LISTVIEW_ApproximateViewRect : incomplete
    38  *   LISTVIEW_Scroll : not implemented 
     39 *   LISTVIEW_Scroll : not implemented
    3940 *   LISTVIEW_RedrawItems : empty stub
    4041 *   LISTVIEW_Update : not completed
     
    4849
    4950/*
    50  * constants 
     51 * constants
    5152 */
    5253
     
    7475
    7576/* default column width for items in list display mode */
    76 #define DEFAULT_COLUMN_WIDTH 96 
    77 
    78 /* 
     77#define DEFAULT_COLUMN_WIDTH 96
     78
     79/*
    7980 * macros
    8081 */
     
    8788#define GETITEMCOUNT(infoPtr) ((infoPtr)->hdpaItems->nItemCount)
    8889
    89 /* 
    90  * forward declarations 
     90/*
     91 * forward declarations
    9192 */
    9293static INT LISTVIEW_HitTestItem(HWND, LPLVHITTESTINFO);
     
    127128/***
    128129 * DESCRIPTION:
    129  * Update the scrollbars. This functions should be called whenever 
     130 * Update the scrollbars. This functions should be called whenever
    130131 * the content, size or view changes.
    131  * 
     132 *
    132133 * PARAMETER(S):
    133134 * [I] HWND : window handle
     
    138139static VOID LISTVIEW_UpdateScroll(HWND hwnd)
    139140{
    140   LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 
     141  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    141142  LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
    142143  UINT uView =  lStyle & LVS_TYPEMASK;
     
    164165        scrollInfo.nMax = nHiddenItemCount / nCountPerColumn + 1;
    165166      }
    166      
     167
    167168      scrollInfo.nPos = ListView_GetTopIndex(hwnd) / nCountPerColumn;
    168169      /*scrollInfo.nPage = LISTVIEW_GetCountPerRow(hwnd);*/
     
    175176      if (lStyle & WS_HSCROLL)
    176177      {
    177         ShowScrollBar(hwnd, SB_HORZ, FALSE);
     178        ShowScrollBar(hwnd, SB_HORZ, FALSE);
    178179      }
    179180    }
     
    196197/*     } */
    197198
    198     /* horizontal scrolling has not been implemented yet! I experienced some 
     199    /* horizontal scrolling has not been implemented yet! I experienced some
    199200       problems when performing child window scrolling. */
    200201  }
     
    228229          scrollInfo.nPos = 0;
    229230        }
    230  
     231
    231232        if (nHiddenWidth % nScrollPosWidth == 0)
    232233        {
    233           scrollInfo.nMax = nHiddenWidth / nScrollPosWidth; 
     234          scrollInfo.nMax = nHiddenWidth / nScrollPosWidth;
    234235        }
    235236        else
    236237        {
    237           scrollInfo.nMax = nHiddenWidth / nScrollPosWidth + 1; 
    238         }
    239          
     238          scrollInfo.nMax = nHiddenWidth / nScrollPosWidth + 1;
     239        }
     240
    240241        scrollInfo.nMin = 0;
    241242        /*scrollInfo.nPage = 10;*/
     
    274275        if (nHiddenHeight % nScrollPosHeight == 0)
    275276        {
    276           scrollInfo.nMax = nHiddenHeight / nScrollPosHeight; 
     277          scrollInfo.nMax = nHiddenHeight / nScrollPosHeight;
    277278        }
    278279        else
    279280        {
    280           scrollInfo.nMax = nHiddenHeight / nScrollPosHeight + 1; 
     281          scrollInfo.nMax = nHiddenHeight / nScrollPosHeight + 1;
    281282        }
    282283
     
    301302 * Prints a message for unsupported window styles.
    302303 * A kind of TODO list for window styles.
    303  * 
     304 *
    304305 * PARAMETER(S):
    305306 * [I] LONG : window style
     
    354355 * DESCRIPTION:
    355356 * Aligns the items with the top edge of the window.
    356  * 
     357 *
    357358 * PARAMETER(S):
    358359 * [I] HWND : window handle
     
    369370  RECT rcView;
    370371  INT i;
    371  
     372
    372373  if ((uView == LVS_SMALLICON) || (uView == LVS_ICON))
    373374  {
    374375    ZeroMemory(&ptItem, sizeof(POINT));
    375376    ZeroMemory(&rcView, sizeof(RECT));
    376    
     377
    377378    if (nListWidth > infoPtr->nItemWidth)
    378379    {
     
    384385          ptItem.y += infoPtr->nItemHeight;
    385386        }
    386        
     387
    387388        ListView_SetItemPosition(hwnd, i, ptItem.x, ptItem.y);
    388389        ptItem.x += infoPtr->nItemWidth;
     
    411412 * DESCRIPTION:
    412413 * Aligns the items with the left edge of the window.
    413  * 
     414 *
    414415 * PARAMETER(S):
    415416 * [I] HWND : window handle
     
    426427  RECT rcView;
    427428  INT i;
    428  
     429
    429430  if ((uView == LVS_SMALLICON) || (uView == LVS_ICON))
    430431  {
     
    468469 * DESCRIPTION:
    469470 * Set the bounding rectangle of all the items.
    470  * 
     471 *
    471472 * PARAMETER(S):
    472473 * [I] HWND : window handle
     
    482483  BOOL bResult = FALSE;
    483484
    484 //  TRACE("(hwnd=%x, left=%d, top=%d, right=%d, bottom=%d)\n", hwnd, 
     485//  TRACE("(hwnd=%x, left=%d, top=%d, right=%d, bottom=%d)\n", hwnd,
    485486//        lprcView->left, lprcView->top, lprcView->right, lprcView->bottom);
    486  
     487
    487488  if (lprcView != NULL)
    488489  {
     
    500501 * DESCRIPTION:
    501502 * Retrieves the bounding rectangle of all the items.
    502  * 
     503 *
    503504 * PARAMETER(S):
    504505 * [I] HWND : window handle
     
    528529    }
    529530
    530 //    TRACE("(left=%d, top=%d, right=%d, bottom=%d)\n", 
     531//    TRACE("(left=%d, top=%d, right=%d, bottom=%d)\n",
    531532//          lprcView->left, lprcView->top, lprcView->right, lprcView->bottom);
    532533  }
     
    538539 * DESCRIPTION:
    539540 * Retrieves the subitem pointer associated with the subitem index.
    540  * 
     541 *
    541542 * PARAMETER(S):
    542543 * [I] HDPA : DPA handle for a specific item
     
    547548 *   FAILURE : NULL
    548549 */
    549 static LISTVIEW_SUBITEM* LISTVIEW_GetSubItemPtr(HDPA hdpaSubItems, 
     550static LISTVIEW_SUBITEM* LISTVIEW_GetSubItemPtr(HDPA hdpaSubItems,
    550551                                                INT nSubItem)
    551552{
     
    571572 * DESCRIPTION:
    572573 * Calculates the width of an item.
    573  * 
     574 *
    574575 * PARAMETER(S):
    575576 * [I] HWND : window handle
     
    610611  {
    611612    for (i = 0; i < GETITEMCOUNT(infoPtr); i++)
    612     { 
     613    {
    613614      nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, i);
    614615      nItemWidth = max(nItemWidth, nLabelWidth);
    615616    }
    616    
     617
    617618    /* default label size */
    618619    if (GETITEMCOUNT(infoPtr) == 0)
     
    630631        /* add padding */
    631632        nItemWidth += WIDTH_PADDING;
    632      
     633
    633634        if (infoPtr->himlSmall != NULL)
    634635        {
     
    643644    }
    644645  }
    645  
     646
    646647  return nItemWidth;
    647648}
     
    650651 * DESCRIPTION:
    651652 * Calculates the height of an item.
    652  * 
     653 *
    653654 * PARAMETER(S):
    654655 * [I] HWND : window handle
     
    668669    nItemHeight = infoPtr->iconSpacing.cy;
    669670  }
    670   else 
    671   {
    672     TEXTMETRICA tm; 
     671  else
     672  {
     673    TEXTMETRICA tm;
    673674    HDC hdc = GetDC(hwnd);
    674675    HFONT hOldFont = SelectObject(hdc, infoPtr->hFont);
     
    685686 * DESCRIPTION:
    686687 * Adds a block of selections.
    687  * 
    688  * PARAMETER(S):
    689  * [I] HWND : window handle
    690  * [I] INT : item index 
     688 *
     689 * PARAMETER(S):
     690 * [I] HWND : window handle
     691 * [I] INT : item index
    691692 *
    692693 * RETURN:
     
    703704  lvItem.state = LVIS_SELECTED;
    704705  lvItem.stateMask= LVIS_SELECTED;
    705  
     706
    706707  for (i = nFirst; i <= nLast; i++)
    707708  {
    708709    ListView_SetItemState(hwnd, i, &lvItem);
    709710  }
    710  
     711
    711712  LISTVIEW_SetItemFocus(hwnd, nItem);
    712713  infoPtr->nSelectionMark = nItem;
     
    716717 * DESCRIPTION:
    717718 * Adds a single selection.
    718  * 
    719  * PARAMETER(S):
    720  * [I] HWND : window handle
    721  * [I] INT : item index 
     719 *
     720 * PARAMETER(S):
     721 * [I] HWND : window handle
     722 * [I] INT : item index
    722723 *
    723724 * RETURN:
     
    741742 * DESCRIPTION:
    742743 * Selects or unselects an item.
    743  * 
    744  * PARAMETER(S):
    745  * [I] HWND : window handle
    746  * [I] INT : item index 
    747  *
    748  * RETURN:
    749  *   SELECT: TRUE 
     744 *
     745 * PARAMETER(S):
     746 * [I] HWND : window handle
     747 * [I] INT : item index
     748 *
     749 * RETURN:
     750 *   SELECT: TRUE
    750751 *   UNSELECT : FALSE
    751752 */
     
    779780/***
    780781 * DESCRIPTION:
    781  * Selects items based on view coorddiantes. 
    782  * 
    783  * PARAMETER(S):
    784  * [I] HWND : window handle
    785  * [I] RECT : selection rectangle 
     782 * Selects items based on view coorddiantes.
     783 *
     784 * PARAMETER(S):
     785 * [I] HWND : window handle
     786 * [I] RECT : selection rectangle
    786787 *
    787788 * RETURN:
     
    816817 * DESCRIPTION:
    817818 * Sets a single group selection.
    818  * 
    819  * PARAMETER(S):
    820  * [I] HWND : window handle
    821  * [I] INT : item index 
    822  *
    823  * RETURN:
    824  * None 
     819 *
     820 * PARAMETER(S):
     821 * [I] HWND : window handle
     822 * [I] INT : item index
     823 *
     824 * RETURN:
     825 * None
    825826 */
    826827static VOID LISTVIEW_SetGroupSelection(HWND hwnd, INT nItem)
     
    836837    INT nLast = max(infoPtr->nSelectionMark, nItem);
    837838    lvItem.stateMask = LVIS_SELECTED;
    838    
     839
    839840    for (i = 0; i <= GETITEMCOUNT(infoPtr); i++)
    840841    {
     
    871872 * DESCRIPTION:
    872873 * Manages the item focus.
    873  * 
    874  * PARAMETER(S):
    875  * [I] HWND : window handle
    876  * [I] INT : item index 
     874 *
     875 * PARAMETER(S):
     876 * [I] HWND : window handle
     877 * [I] INT : item index
    877878 *
    878879 * RETURN:
     
    891892    ZeroMemory(&lvItem, sizeof(LVITEMA));
    892893    lvItem.stateMask = LVIS_FOCUSED;
    893     ListView_SetItemState(hwnd, infoPtr->nFocusedItem, &lvItem); 
     894    ListView_SetItemState(hwnd, infoPtr->nFocusedItem, &lvItem);
    894895
    895896    lvItem.state =  LVIS_FOCUSED;
     
    900901    ListView_EnsureVisible(hwnd, nItem, FALSE);
    901902  }
    902  
    903   return bResult; 
     903
     904  return bResult;
    904905}
    905906
     
    907908 * DESCRIPTION:
    908909 * Sets a single selection.
    909  * 
    910  * PARAMETER(S):
    911  * [I] HWND : window handle
    912  * [I] INT : item index 
     910 *
     911 * PARAMETER(S):
     912 * [I] HWND : window handle
     913 * [I] INT : item index
    913914 *
    914915 * RETURN:
     
    932933  ZeroMemory(&lvItem, sizeof(LVITEMA));
    933934  lvItem.stateMask = LVIS_FOCUSED;
    934   ListView_SetItemState(hwnd, infoPtr->nFocusedItem, &lvItem); 
    935  
     935  ListView_SetItemState(hwnd, infoPtr->nFocusedItem, &lvItem);
     936
    936937  lvItem.state =  LVIS_SELECTED | LVIS_FOCUSED;
    937938  lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
     
    945946 * DESCRIPTION:
    946947 * Set selection(s) with keyboard.
    947  * 
    948  * PARAMETER(S):
    949  * [I] HWND : window handle
    950  * [I] INT : item index 
     948 *
     949 * PARAMETER(S):
     950 * [I] HWND : window handle
     951 * [I] INT : item index
    951952 *
    952953 * RETURN:
     
    967968    {
    968969      bResult = TRUE;
    969       LISTVIEW_SetSelection(hwnd, nItem); 
     970      LISTVIEW_SetSelection(hwnd, nItem);
    970971      ListView_EnsureVisible(hwnd, nItem, FALSE);
    971972    }
     
    975976      {
    976977        bResult = TRUE;
    977         LISTVIEW_SetGroupSelection(hwnd, nItem); 
     978        LISTVIEW_SetGroupSelection(hwnd, nItem);
    978979      }
    979980      else if (wCtrl)
     
    984985      {
    985986        bResult = TRUE;
    986         LISTVIEW_SetSelection(hwnd, nItem); 
     987        LISTVIEW_SetSelection(hwnd, nItem);
    987988        ListView_EnsureVisible(hwnd, nItem, FALSE);
    988989      }
     
    992993  return bResult;
    993994}
    994  
     995
    995996/***
    996997 * DESCRIPTION:
    997998 * Selects an item based on coordinates.
    998  * 
     999 *
    9991000 * PARAMETER(S):
    10001001 * [I] HWND : window handle
     
    10101011  RECT rcItem;
    10111012  INT i;
    1012  
     1013
    10131014  for (i = 0; i < GETITEMCOUNT(infoPtr); i++)
    10141015  {
     
    10291030 * DESCRIPTION:
    10301031 * Removes all selection states.
    1031  * 
    1032  * PARAMETER(S):
    1033  * [I] HWND : window handle
    1034  * [I] INT : item index 
     1032 *
     1033 * PARAMETER(S):
     1034 * [I] HWND : window handle
     1035 * [I] INT : item index
    10351036 *
    10361037 * RETURN:
     
    10551056 * DESCRIPTION:
    10561057 * Removes a column.
    1057  * 
     1058 *
    10581059 * PARAMETER(S):
    10591060 * [IO] HDPA : dynamic pointer array handle
     
    10811082    }
    10821083  }
    1083    
     1084
    10841085  return bResult;
    10851086}
     
    10881089 * DESCRIPTION:
    10891090 * Removes a subitem at a given position.
    1090  * 
     1091 *
    10911092 * PARAMETER(S):
    10921093 * [IO] HDPA : dynamic pointer array handle
     
    11101111      {
    11111112        /* free string */
    1112         if ((lpSubItem->pszText != NULL) && 
     1113        if ((lpSubItem->pszText != NULL) &&
    11131114            (lpSubItem->pszText != LPSTR_TEXTCALLBACKA))
    11141115        {
    11151116          COMCTL32_Free(lpSubItem->pszText);
    11161117        }
    1117        
     1118
    11181119        /* free item */
    11191120        COMCTL32_Free(lpSubItem);
     
    11301131      }
    11311132    }
    1132   }   
    1133  
     1133  }
     1134
    11341135  return TRUE;
    11351136}
     
    11381139 * DESCRIPTION:
    11391140 * Compares the item information.
    1140  * 
    1141  * PARAMETER(S):
    1142  * [I] LISTVIEW_ITEM *: destination item 
    1143  * [I] LPLVITEM : source item 
     1141 *
     1142 * PARAMETER(S):
     1143 * [I] LISTVIEW_ITEM *: destination item
     1144 * [I] LPLVITEM : source item
    11441145 *
    11451146 * RETURN:
     
    11551156    if (lpLVItem->mask & LVIF_STATE)
    11561157    {
    1157       if ((lpItem->state & lpLVItem->stateMask) != 
     1158      if ((lpItem->state & lpLVItem->stateMask) !=
    11581159          (lpLVItem->state & lpLVItem->stateMask))
    11591160      {
    1160         uChanged |= LVIF_STATE; 
     1161        uChanged |= LVIF_STATE;
    11611162      }
    11621163    }
     
    11661167      if (lpItem->iImage != lpLVItem->iImage)
    11671168      {
    1168         uChanged |= LVIF_IMAGE; 
    1169       }
    1170     }
    1171  
     1169        uChanged |= LVIF_IMAGE;
     1170      }
     1171    }
     1172
    11721173    if (lpLVItem->mask & LVIF_PARAM)
    11731174    {
    11741175      if (lpItem->lParam != lpLVItem->lParam)
    11751176      {
    1176         uChanged |= LVIF_PARAM; 
    1177       }
    1178     }
    1179    
     1177        uChanged |= LVIF_PARAM;
     1178      }
     1179    }
     1180
    11801181    if (lpLVItem->mask & LVIF_INDENT)
    11811182    {
    11821183      if (lpItem->iIndent != lpLVItem->iIndent)
    11831184      {
    1184         uChanged |= LVIF_INDENT; 
    1185       }
    1186     }
    1187 
    1188     if (lpLVItem->mask & LVIF_TEXT) 
    1189     {
    1190       if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA) 
     1185        uChanged |= LVIF_INDENT;
     1186      }
     1187    }
     1188
     1189    if (lpLVItem->mask & LVIF_TEXT)
     1190    {
     1191      if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA)
    11911192      {
    11921193        if (lpItem->pszText != LPSTR_TEXTCALLBACKA)
    11931194        {
    1194           uChanged |= LVIF_TEXT; 
     1195          uChanged |= LVIF_TEXT;
    11951196        }
    11961197      }
     
    11991200        if (lpItem->pszText == LPSTR_TEXTCALLBACKA)
    12001201        {
    1201           uChanged |= LVIF_TEXT; 
    1202         }
    1203         else
    1204         {
    1205           if (lpLVItem->pszText)
    1206           {
    1207             if (lpItem->pszText)
    1208             {
    1209               if (strcmp(lpLVItem->pszText, lpItem->pszText) != 0)
    1210               {
    1211                 uChanged |= LVIF_TEXT;
    1212               }
    1213             }
    1214             else
    1215             {
    1216               uChanged |= LVIF_TEXT;
    1217             }
    1218           }
    1219           else
    1220           {
    1221             if (lpItem->pszText)
    1222             {
    1223               uChanged |= LVIF_TEXT;
    1224             }
    1225           }
    1226         }
     1202          uChanged |= LVIF_TEXT;
     1203        }
     1204        else
     1205        {
     1206          if (lpLVItem->pszText)
     1207          {
     1208            if (lpItem->pszText)
     1209            {
     1210              if (strcmp(lpLVItem->pszText, lpItem->pszText) != 0)
     1211              {
     1212                uChanged |= LVIF_TEXT;
     1213              }
     1214            }
     1215            else
     1216            {
     1217              uChanged |= LVIF_TEXT;
     1218            }
     1219          }
     1220          else
     1221          {
     1222            if (lpItem->pszText)
     1223            {
     1224              uChanged |= LVIF_TEXT;
     1225            }
     1226          }
     1227        }
    12271228      }
    12281229    }
     
    12341235 * DESCRIPTION:
    12351236 * Initializes item attributes.
    1236  * 
    1237  * PARAMETER(S):
    1238  * [I] HWND : window handle
    1239  * [O] LISTVIEW_ITEM *: destination item 
    1240  * [I] LPLVITEM : source item 
     1237 *
     1238 * PARAMETER(S):
     1239 * [I] HWND : window handle
     1240 * [O] LISTVIEW_ITEM *: destination item
     1241 * [I] LPLVITEM : source item
    12411242 *
    12421243 * RETURN:
     
    12441245 *   FAILURE : FALSE
    12451246 */
    1246 static BOOL LISTVIEW_InitItem(HWND hwnd, LISTVIEW_ITEM *lpItem, 
     1247static BOOL LISTVIEW_InitItem(HWND hwnd, LISTVIEW_ITEM *lpItem,
    12471248                              LPLVITEMA lpLVItem)
    12481249{
     
    12531254  {
    12541255    bResult = TRUE;
    1255    
     1256
    12561257    if (lpLVItem->mask & LVIF_STATE)
    12571258    {
     
    12591260      lpItem->state |= (lpLVItem->state & lpLVItem->stateMask);
    12601261    }
    1261    
     1262
    12621263    if (lpLVItem->mask & LVIF_IMAGE)
    12631264    {
    12641265      lpItem->iImage = lpLVItem->iImage;
    12651266    }
    1266  
     1267
    12671268    if (lpLVItem->mask & LVIF_PARAM)
    12681269    {
    12691270      lpItem->lParam = lpLVItem->lParam;
    12701271    }
    1271    
     1272
    12721273    if (lpLVItem->mask & LVIF_INDENT)
    12731274    {
     
    12751276    }
    12761277
    1277     if (lpLVItem->mask & LVIF_TEXT) 
    1278     {
    1279       if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA) 
     1278    if (lpLVItem->mask & LVIF_TEXT)
     1279    {
     1280      if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA)
    12801281      {
    12811282        if ((lStyle & LVS_SORTASCENDING) || (lStyle & LVS_SORTDESCENDING))
     
    12841285        }
    12851286
    1286         if ((lpItem->pszText != NULL) && 
     1287        if ((lpItem->pszText != NULL) &&
    12871288            (lpItem->pszText != LPSTR_TEXTCALLBACKA))
    12881289        {
    12891290          COMCTL32_Free(lpItem->pszText);
    12901291        }
    1291    
     1292
    12921293        lpItem->pszText = LPSTR_TEXTCALLBACKA;
    12931294      }
    1294       else 
     1295      else
    12951296      {
    12961297        if (lpItem->pszText == LPSTR_TEXTCALLBACKA)
     
    12981299          lpItem->pszText = NULL;
    12991300        }
    1300        
     1301
    13011302        bResult = Str_SetPtrA(&lpItem->pszText, lpLVItem->pszText);
    13021303      }
     
    13231324 *   FAILURE : FALSE
    13241325 */
    1325 static BOOL LISTVIEW_InitSubItem(HWND hwnd, LISTVIEW_SUBITEM *lpSubItem, 
     1326static BOOL LISTVIEW_InitSubItem(HWND hwnd, LISTVIEW_SUBITEM *lpSubItem,
    13261327                                   LPLVITEMA lpLVItem)
    13271328{
    13281329  LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
    13291330  BOOL bResult = FALSE;
    1330  
     1331
    13311332  if ((lpSubItem != NULL) && (lpLVItem != NULL))
    13321333  {
     
    13421343        lpSubItem->iImage = lpLVItem->iImage;
    13431344      }
    1344      
    1345       if (lpLVItem->mask & LVIF_TEXT) 
    1346       {
    1347         if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA) 
     1345
     1346      if (lpLVItem->mask & LVIF_TEXT)
     1347      {
     1348        if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA)
    13481349        {
    13491350          if ((lStyle & LVS_SORTASCENDING) || (lStyle & LVS_SORTDESCENDING))
    13501351          {
    13511352            return FALSE;
    1352           } 
    1353 
    1354           if ((lpSubItem->pszText != NULL) && 
     1353          }
     1354
     1355          if ((lpSubItem->pszText != NULL) &&
    13551356              (lpSubItem->pszText != LPSTR_TEXTCALLBACKA))
    13561357          {
    13571358            COMCTL32_Free(lpSubItem->pszText);
    13581359          }
    1359    
     1360
    13601361          lpSubItem->pszText = LPSTR_TEXTCALLBACKA;
    13611362        }
    1362         else 
     1363        else
    13631364        {
    13641365          if (lpSubItem->pszText == LPSTR_TEXTCALLBACKA)
     
    13661367            lpSubItem->pszText = NULL;
    13671368          }
    1368        
     1369
    13691370          bResult = Str_SetPtrA(&lpSubItem->pszText, lpLVItem->pszText);
    13701371        }
     
    13791380 * DESCRIPTION:
    13801381 * Adds a subitem at a given position (column index).
    1381  * 
    1382  * PARAMETER(S):
    1383  * [I] HWND : window handle
    1384  * [I] LPLVITEM : new subitem atttributes 
     1382 *
     1383 * PARAMETER(S):
     1384 * [I] HWND : window handle
     1385 * [I] LPLVITEM : new subitem atttributes
    13851386 *
    13861387 * RETURN:
     
    14061407        if (LISTVIEW_InitSubItem(hwnd, lpSubItem, lpLVItem) != FALSE)
    14071408        {
    1408           nPosition = LISTVIEW_FindInsertPosition(hdpaSubItems, 
     1409          nPosition = LISTVIEW_FindInsertPosition(hdpaSubItems,
    14091410                                                  lpSubItem->iSubItem);
    14101411          nItem = DPA_InsertPtr(hdpaSubItems, nPosition, lpSubItem);
     
    14121413          {
    14131414            bResult = TRUE;
    1414           }           
    1415         }
    1416       }
    1417     }
    1418   }
    1419  
    1420   /* cleanup if unsuccessful */   
     1415          }
     1416        }
     1417      }
     1418    }
     1419  }
     1420
     1421  /* cleanup if unsuccessful */
    14211422  if ((bResult == FALSE) && (lpSubItem != NULL))
    14221423  {
    14231424    COMCTL32_Free(lpSubItem);
    14241425  }
    1425  
     1426
    14261427  return bResult;
    14271428}
     
    14301431 * DESCRIPTION:
    14311432 * Finds the dpa insert position (array index).
    1432  * 
     1433 *
    14331434 * PARAMETER(S):
    14341435 * [I] HWND : window handle
     
    14531454        return i;
    14541455      }
    1455     } 
     1456    }
    14561457  }
    14571458
     
    14621463 * DESCRIPTION:
    14631464 * Retrieves a listview subitem at a given position (column index).
    1464  * 
     1465 *
    14651466 * PARAMETER(S):
    14661467 * [I] HWND : window handle
     
    14881489      {
    14891490        return NULL;
    1490       } 
    1491     }
    1492   }
    1493  
     1491      }
     1492    }
     1493  }
     1494
    14941495  return NULL;
    14951496}
     
    14981499 * DESCRIPTION:
    14991500 * Sets item attributes.
    1500  * 
    1501  * PARAMETER(S):
    1502  * [I] HWND : window handle
    1503  * [I] LPLVITEM : new item atttributes 
     1501 *
     1502 * PARAMETER(S):
     1503 * [I] HWND : window handle
     1504 * [I] LPLVITEM : new item atttributes
    15041505 *
    15051506 * RETURN:
     
    15401541              nmlv.uOldState = lpItem->state & lpLVItem->stateMask;
    15411542            }
    1542            
     1543
    15431544            nmlv.uChanged = uChanged;
    15441545            nmlv.iItem = lpLVItem->iItem;
     
    15711572 * DESCRIPTION:
    15721573 * Sets subitem attributes.
    1573  * 
    1574  * PARAMETER(S):
    1575  * [I] HWND : window handle
    1576  * [I] LPLVITEM : new subitem atttributes 
     1574 *
     1575 * PARAMETER(S):
     1576 * [I] HWND : window handle
     1577 * [I] LPLVITEM : new subitem atttributes
    15771578 *
    15781579 * RETURN:
     
    16061607            bResult = LISTVIEW_AddSubItem(hwnd, lpLVItem);
    16071608          }
    1608          
     1609
    16091610          InvalidateRect(hwnd, NULL, FALSE);
    1610         } 
     1611        }
    16111612      }
    16121613    }
     
    16191620 * DESCRIPTION:
    16201621 * Retrieves the index of the item at coordinate (0, 0) of the client area.
    1621  * 
     1622 *
    16221623 * PARAMETER(S):
    16231624 * [I] HWND : window handle
     
    16361637  scrollInfo.cbSize = sizeof(SCROLLINFO);
    16371638  scrollInfo.fMask = SIF_POS;
    1638  
     1639
    16391640  if (uView == LVS_LIST)
    16401641  {
     
    16571658    }
    16581659  }
    1659  
     1660
    16601661  return nItem;
    16611662}
     
    16641665 * DESCRIPTION:
    16651666 * Draws a subitem.
    1666  * 
     1667 *
    16671668 * PARAMETER(S):
    16681669 * [I] HWND : window handle
     
    16751676 * None
    16761677 */
    1677 static VOID LISTVIEW_DrawSubItem(HWND hwnd, HDC hdc, INT nItem, INT nSubItem, 
     1678static VOID LISTVIEW_DrawSubItem(HWND hwnd, HDC hdc, INT nItem, INT nSubItem,
    16781679                                 RECT rcItem)
    16791680{
    1680   LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 
     1681  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    16811682  CHAR szDispText[DISP_TEXT_SIZE];
    16821683  LVITEMA lvItem;
    16831684
    1684   TRACE("(hwnd=%x, hdc=%x, nItem=%d, nSubItem=%d\n", hwnd, hdc, 
     1685  TRACE("(hwnd=%x, hdc=%x, nItem=%d, nSubItem=%d\n", hwnd, hdc,
    16851686        nItem, nSubItem);
    16861687
     
    16971698  SetBkColor(hdc, infoPtr->clrTextBk);
    16981699  SetTextColor(hdc, infoPtr->clrText);
    1699  
    1700   ExtTextOutA(hdc, rcItem.left, rcItem.top, ETO_OPAQUE | ETO_CLIPPED, 
     1700
     1701  ExtTextOutA(hdc, rcItem.left, rcItem.top, ETO_OPAQUE | ETO_CLIPPED,
    17011702              &rcItem, lvItem.pszText, lstrlenA(lvItem.pszText), NULL);
    17021703}
     
    17061707 * DESCRIPTION:
    17071708 * Draws an item.
    1708  * 
     1709 *
    17091710 * PARAMETER(S):
    17101711 * [I] HWND : window handle
     
    17181719static VOID LISTVIEW_DrawItem(HWND hwnd, HDC hdc, INT nItem, RECT rcItem)
    17191720{
    1720   LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 
     1721  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    17211722  CHAR szDispText[DISP_TEXT_SIZE];
    17221723  INT nLabelWidth;
     
    17411742  if (infoPtr->himlState != NULL)
    17421743  {
    1743      UINT uStateImage = (lvItem.state & LVIS_STATEIMAGEMASK) >> 12; 
     1744     UINT uStateImage = (lvItem.state & LVIS_STATEIMAGEMASK) >> 12;
    17441745     if (uStateImage != 0)
    17451746     {
    1746        ImageList_Draw(infoPtr->himlState, uStateImage - 1, hdc, rcItem.left, 
     1747       ImageList_Draw(infoPtr->himlState, uStateImage - 1, hdc, rcItem.left,
    17471748                      rcItem.top, ILD_NORMAL);
    17481749     }
    1749  
    1750      rcItem.left += infoPtr->iconSize.cx; 
    1751   }
    1752  
     1750
     1751     rcItem.left += infoPtr->iconSize.cx;
     1752  }
     1753
    17531754  /* small icons */
    17541755  if (infoPtr->himlSmall != NULL)
     
    17571758    {
    17581759      ImageList_SetBkColor(infoPtr->himlSmall, CLR_NONE);
    1759       ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcItem.left, 
     1760      ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcItem.left,
    17601761                     rcItem.top, ILD_SELECTED);
    17611762    }
     
    17631764    {
    17641765      ImageList_SetBkColor(infoPtr->himlSmall, CLR_NONE);
    1765       ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcItem.left, 
     1766      ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcItem.left,
    17661767                     rcItem.top, ILD_NORMAL);
    17671768    }
    1768    
    1769     rcItem.left += infoPtr->iconSize.cx; 
     1769
     1770    rcItem.left += infoPtr->iconSize.cx;
    17701771  }
    17711772
    17721773  if ((lvItem.state & LVIS_SELECTED) && (infoPtr->bFocus != FALSE))
    17731774  {
    1774     /* set item colors */ 
     1775    /* set item colors */
    17751776    dwBkColor = SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
    17761777    dwTextColor = SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
     
    17781779    nMixMode = SetROP2(hdc, R2_XORPEN);
    17791780  }
    1780   else if ((GetWindowLongA(hwnd, GWL_STYLE) & LVS_SHOWSELALWAYS) && 
     1781  else if ((GetWindowLongA(hwnd, GWL_STYLE) & LVS_SHOWSELALWAYS) &&
    17811782           (lvItem.state & LVIS_SELECTED) && (infoPtr->bFocus == FALSE))
    17821783  {
     
    17941795    nMixMode = SetROP2(hdc, R2_COPYPEN);
    17951796  }
    1796  
     1797
    17971798  nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText);
    17981799  if (rcItem.left + nLabelWidth < rcItem.right)
     
    18001801    rcItem.right = rcItem.left + nLabelWidth;
    18011802  }
    1802  
    1803   /* draw label */ 
    1804   ExtTextOutA(hdc, rcItem.left, rcItem.top, ETO_OPAQUE | ETO_CLIPPED, 
     1803
     1804  /* draw label */
     1805  ExtTextOutA(hdc, rcItem.left, rcItem.top, ETO_OPAQUE | ETO_CLIPPED,
    18051806              &rcItem, lvItem.pszText, lstrlenA(lvItem.pszText), NULL);
    1806  
     1807
    18071808  if ((lvItem.state & LVIS_FOCUSED) && (infoPtr->bFocus == TRUE))
    18081809  {
    1809     Rectangle(hdc, rcItem.left, rcItem.top, rcItem.right, rcItem.bottom); 
     1810    Rectangle(hdc, rcItem.left, rcItem.top, rcItem.right, rcItem.bottom);
    18101811  }
    18111812
     
    18211822 * DESCRIPTION:
    18221823 * Draws an item when in large icon display mode.
    1823  * 
     1824 *
    18241825 * PARAMETER(S):
    18251826 * [I] HWND : window handle
     
    18341835static VOID LISTVIEW_DrawLargeItem(HWND hwnd, HDC hdc, INT nItem, RECT rcItem)
    18351836{
    1836   LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 
     1837  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    18371838  CHAR szDispText[DISP_TEXT_SIZE];
    18381839  INT nDrawPosX = rcItem.left;
     
    18421843
    18431844  TRACE("(hwnd=%x, hdc=%x, nItem=%d, left=%d, top=%d, right=%d, \
    1844 bottom=%d)\n", hwnd, hdc, nItem, rcItem.left, rcItem.top, rcItem.right, 
     1845bottom=%d)\n", hwnd, hdc, nItem, rcItem.left, rcItem.top, rcItem.right,
    18451846        rcItem.bottom);
    18461847
     
    18571858  if (lvItem.state & LVIS_SELECTED)
    18581859  {
    1859     /* set item colors */ 
     1860    /* set item colors */
    18601861    SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
    18611862    SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
     
    18781879    if (lvItem.state & LVIS_SELECTED)
    18791880    {
    1880       ImageList_Draw(infoPtr->himlNormal, lvItem.iImage, hdc, nDrawPosX, 
     1881      ImageList_Draw(infoPtr->himlNormal, lvItem.iImage, hdc, nDrawPosX,
    18811882                     rcItem.top, ILD_SELECTED);
    18821883    }
    18831884    else
    18841885    {
    1885       ImageList_Draw(infoPtr->himlNormal, lvItem.iImage, hdc, nDrawPosX, 
     1886      ImageList_Draw(infoPtr->himlNormal, lvItem.iImage, hdc, nDrawPosX,
    18861887                     rcItem.top, ILD_NORMAL);
    18871888    }
    18881889  }
    18891890
    1890   rcItem.top += infoPtr->iconSize.cy + ICON_BOTTOM_PADDING; 
     1891  rcItem.top += infoPtr->iconSize.cy + ICON_BOTTOM_PADDING;
    18911892  nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText);
    18921893  nDrawPosX = infoPtr->iconSpacing.cx - nLabelWidth;
     
    19021903  }
    19031904
    1904   /* draw label */ 
     1905  /* draw label */
    19051906  GetTextMetricsA(hdc, &tm);
    1906   rcItem.bottom = rcItem.top + tm.tmHeight + HEIGHT_PADDING; 
    1907   ExtTextOutA(hdc, rcItem.left, rcItem.top, ETO_OPAQUE | ETO_CLIPPED, 
     1907  rcItem.bottom = rcItem.top + tm.tmHeight + HEIGHT_PADDING;
     1908  ExtTextOutA(hdc, rcItem.left, rcItem.top, ETO_OPAQUE | ETO_CLIPPED,
    19081909              &rcItem, lvItem.pszText, lstrlenA(lvItem.pszText), NULL);
    1909        
     1910
    19101911  if (lvItem.state & LVIS_FOCUSED)
    19111912  {
    1912     Rectangle(hdc, rcItem.left, rcItem.top, rcItem.right, rcItem.bottom); 
     1913    Rectangle(hdc, rcItem.left, rcItem.top, rcItem.right, rcItem.bottom);
    19131914  }
    19141915}
     
    19171918 * DESCRIPTION:
    19181919 * Draws listview items when in report display mode.
    1919  * 
    1920  * PARAMETER(S):
    1921  * [I] HWND : window handle
    1922  * [I] HDC : device context handle 
     1920 *
     1921 * PARAMETER(S):
     1922 * [I] HWND : window handle
     1923 * [I] HDC : device context handle
    19231924 *
    19241925 * RETURN:
     
    19521953      if (j == 0)
    19531954      {
    1954         LISTVIEW_DrawItem(hwnd, hdc, nItem, rcItem); 
    1955       }
    1956       else 
     1955        LISTVIEW_DrawItem(hwnd, hdc, nItem, rcItem);
     1956      }
     1957      else
    19571958      {
    19581959        LISTVIEW_DrawSubItem(hwnd, hdc, nItem, j, rcItem);
    19591960      }
    19601961    }
    1961    
     1962
    19621963    nDrawPosY += infoPtr->nItemHeight;
    19631964  }
     
    19671968 * DESCRIPTION:
    19681969 * Retrieves the number of items that can fit vertically in the client area.
    1969  * 
     1970 *
    19701971 * PARAMETER(S):
    19711972 * [I] HWND : window handle
     
    20022003/***
    20032004 * DESCRIPTION:
    2004  * Retrieves the number of items that can fit horizontally in the client 
     2005 * Retrieves the number of items that can fit horizontally in the client
    20052006 * area.
    2006  * 
     2007 *
    20072008 * PARAMETER(S):
    20082009 * [I] HWND : window handle
     
    20312032/***
    20322033 * DESCRIPTION:
    2033  * Retrieves the number of columns needed to display all the items when in 
     2034 * Retrieves the number of columns needed to display all the items when in
    20342035 * list display mode.
    2035  * 
     2036 *
    20362037 * PARAMETER(S):
    20372038 * [I] HWND : window handle
     
    20402041 * Number of columns.
    20412042 */
    2042 static INT LISTVIEW_GetColumnCount(hwnd)
     2043static INT LISTVIEW_GetColumnCount(HWND hwnd)
    20432044{
    20442045  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
     
    20592060
    20602061  return nColumnCount;
    2061 } 
    2062  
     2062}
     2063
    20632064
    20642065/***
    20652066 * DESCRIPTION:
    20662067 * Draws listview items when in list display mode.
    2067  * 
    2068  * PARAMETER(S):
    2069  * [I] HWND : window handle
    2070  * [I] HDC : device context handle 
     2068 *
     2069 * PARAMETER(S):
     2070 * [I] HWND : window handle
     2071 * [I] HDC : device context handle
    20712072 *
    20722073 * RETURN:
     
    20812082  INT nColumnCount;
    20822083  INT nCountPerColumn;
    2083  
     2084
    20842085  /* get number of fully visible columns */
    20852086  nColumnCount = LISTVIEW_GetColumnCount(hwnd);
     
    21062107 * DESCRIPTION:
    21072108 * Draws listview items when in icon or small icon display mode.
    2108  * 
    2109  * PARAMETER(S):
    2110  * [I] HWND : window handle
    2111  * [I] HDC : device context handle 
     2109 *
     2110 * PARAMETER(S):
     2111 * [I] HWND : window handle
     2112 * [I] HDC : device context handle
    21122113 *
    21132114 * RETURN:
     
    21282129    ptPosition.x += ptOrigin.x;
    21292130    ptPosition.y += ptOrigin.y;
    2130      
     2131
    21312132    if (ptPosition.y + infoPtr->nItemHeight > infoPtr->rcList.top)
    21322133    {
     
    21592160 * DESCRIPTION:
    21602161 * Draws listview items.
    2161  * 
    2162  * PARAMETER(S):
    2163  * [I] HWND : window handle
    2164  * [I] HDC : device context handle 
     2162 *
     2163 * PARAMETER(S):
     2164 * [I] HWND : window handle
     2165 * [I] HDC : device context handle
    21652166 *
    21662167 * RETURN:
     
    21822183
    21832184  /* select transparent brush (for drawing the focus box) */
    2184   SelectObject(hdc, GetStockObject(NULL_BRUSH)); 
     2185  SelectObject(hdc, GetStockObject(NULL_BRUSH));
    21852186
    21862187  if (uView == LVS_LIST)
    21872188  {
    2188     LISTVIEW_RefreshList(hwnd, hdc); 
     2189    LISTVIEW_RefreshList(hwnd, hdc);
    21892190  }
    21902191  else if (uView == LVS_REPORT)
     
    22042205  SelectObject(hdc, hOldFont);
    22052206  SelectObject(hdc, hOldPen);
    2206  
     2207
    22072208  /* delete pen */
    22082209  DeleteObject(hPen);
     
    22132214 * DESCRIPTION:
    22142215 * Calculates the approximate width and height of a given number of items.
    2215  * 
     2216 *
    22162217 * PARAMETER(S):
    22172218 * [I] HWND : window handle
     
    22232224 * Returns a DWORD. The width in the low word and the height in high word.
    22242225 */
    2225 static LRESULT LISTVIEW_ApproximateViewRect(HWND hwnd, INT nItemCount, 
     2226static LRESULT LISTVIEW_ApproximateViewRect(HWND hwnd, INT nItemCount,
    22262227                                            WORD wWidth, WORD wHeight)
    22272228{
     
    22592260          nItemCountPerColumn = 1;
    22602261        }
    2261        
     2262
    22622263        if (nItemCount % nItemCountPerColumn != 0)
    22632264        {
     
    22892290    /* TO DO */
    22902291  }
    2291  
     2292
    22922293  return dwViewRect;
    22932294}
     
    22962297 * DESCRIPTION:
    22972298 * Arranges listview items in icon display mode.
    2298  * 
     2299 *
    22992300 * PARAMETER(S):
    23002301 * [I] HWND : window handle
     
    23072308static LRESULT LISTVIEW_Arrange(HWND hwnd, INT nAlignCode)
    23082309{
    2309   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 
     2310  UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
    23102311  BOOL bResult = FALSE;
    23112312
     
    23372338 * DESCRIPTION:
    23382339 * Removes all listview items and subitems.
    2339  * 
     2340 *
    23402341 * PARAMETER(S):
    23412342 * [I] HWND : window handle
     
    23662367    /* initialize memory */
    23672368    ZeroMemory(&nmlv, sizeof(NMLISTVIEW));
    2368    
     2369
    23692370    /* send LVN_DELETEALLITEMS notification */
    23702371    nmlv.hdr.hwndFrom = hwnd;
     
    23732374    nmlv.iItem = -1;
    23742375
    2375     /* verify if subsequent LVN_DELETEITEM notifications should be 
     2376    /* verify if subsequent LVN_DELETEITEM notifications should be
    23762377       suppressed */
    23772378    bSuppress = ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv);
     
    23882389          {
    23892390            /* free subitem string */
    2390             if ((lpSubItem->pszText != NULL) && 
     2391            if ((lpSubItem->pszText != NULL) &&
    23912392                (lpSubItem->pszText != LPSTR_TEXTCALLBACKA))
    23922393            {
    23932394              COMCTL32_Free(lpSubItem->pszText);
    23942395            }
    2395            
     2396
    23962397            /* free subitem */
    23972398            COMCTL32_Free(lpSubItem);
    2398           }   
    2399         }
    2400    
     2399          }
     2400        }
     2401
    24012402        lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0);
    24022403        if (lpItem != NULL)
     
    24122413
    24132414          /* free item string */
    2414           if ((lpItem->pszText != NULL) && 
     2415          if ((lpItem->pszText != NULL) &&
    24152416              (lpItem->pszText != LPSTR_TEXTCALLBACKA))
    24162417          {
    24172418            COMCTL32_Free(lpItem->pszText);
    24182419          }
    2419          
     2420
    24202421          /* free item */
    24212422          COMCTL32_Free(lpItem);
    24222423        }
    2423        
     2424
    24242425        DPA_Destroy(hdpaSubItems);
    24252426      }
     
    24282429    /* reinitialize listview memory */
    24292430    bResult = DPA_DeleteAllPtrs(infoPtr->hdpaItems);
    2430    
     2431
    24312432    /* align items (set position of each item) */
    24322433    if ((uView == LVS_ICON) || (uView == LVS_SMALLICON))
     
    24412442      }
    24422443    }
    2443    
     2444
    24442445    LISTVIEW_UpdateScroll(hwnd);
    24452446
     
    24472448    InvalidateRect(hwnd, NULL, TRUE);
    24482449  }
    2449  
     2450
    24502451  return bResult;
    24512452}
     
    24542455 * DESCRIPTION:
    24552456 * Removes a column from the listview control.
    2456  * 
     2457 *
    24572458 * PARAMETER(S):
    24582459 * [I] HWND : window handle
     
    24682469  UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
    24692470  BOOL bResult = FALSE;
    2470  
     2471
    24712472  if (Header_DeleteItem(infoPtr->hwndHeader, nColumn) != FALSE)
    24722473  {
     
    24902491 * DESCRIPTION:
    24912492 * Removes an item from the listview control.
    2492  * 
    2493  * PARAMETER(S):
    2494  * [I] HWND : window handle
    2495  * [I] INT : item index 
     2493 *
     2494 * PARAMETER(S):
     2495 * [I] HWND : window handle
     2496 * [I] INT : item index
    24962497 *
    24972498 * RETURN:
     
    25282529        {
    25292530          /* free item string */
    2530           if ((lpSubItem->pszText != NULL) && 
     2531          if ((lpSubItem->pszText != NULL) &&
    25312532              (lpSubItem->pszText != LPSTR_TEXTCALLBACKA))
    25322533          {
    25332534            COMCTL32_Free(lpSubItem->pszText);
    25342535          }
    2535          
     2536
    25362537          /* free item */
    25372538          COMCTL32_Free(lpSubItem);
    2538         }   
    2539       }
    2540    
     2539        }
     2540      }
     2541
    25412542      lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0);
    25422543      if (lpItem != NULL)
     
    25482549        nmlv.iItem = nItem;
    25492550        nmlv.lParam = lpItem->lParam;
    2550         SendMessageA(GetParent(hwnd), WM_NOTIFY, (WPARAM)lCtrlId, 
     2551        SendMessageA(GetParent(hwnd), WM_NOTIFY, (WPARAM)lCtrlId,
    25512552                     (LPARAM)&nmlv);
    25522553
    25532554        /* free item string */
    2554         if ((lpItem->pszText != NULL) && 
     2555        if ((lpItem->pszText != NULL) &&
    25552556            (lpItem->pszText != LPSTR_TEXTCALLBACKA))
    25562557        {
    25572558          COMCTL32_Free(lpItem->pszText);
    25582559        }
    2559        
     2560
    25602561        /* free item */
    25612562        COMCTL32_Free(lpItem);
    25622563      }
    2563      
     2564
    25642565      bResult = DPA_Destroy(hdpaSubItems);
    25652566    }
     
    25832584    InvalidateRect(hwnd, NULL, TRUE);
    25842585  }
    2585  
     2586
    25862587  return bResult;
    25872588}
     
    25922593 * DESCRIPTION:
    25932594 * Ensures the specified item is visible, scrolling into view if necessary.
    2594  * 
     2595 *
    25952596 * PARAMETER(S):
    25962597 * [I] HWND : window handle
     
    26372638          rcItem.left += infoPtr->rcList.left;
    26382639        }
    2639        
     2640
    26402641        if (rcItem.left % nScrollPosWidth == 0)
    26412642        {
     
    26462647          scrollInfo.nPos += rcItem.left / nScrollPosWidth - 1;
    26472648        }
    2648        
     2649
    26492650        SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE);
    26502651      }
     
    26782679      }
    26792680    }
    2680    
     2681
    26812682    if (rcItem.top < infoPtr->rcList.top)
    26822683    {
     
    26862687        if (uView == LVS_REPORT)
    26872688        {
    2688           rcItem.top -= infoPtr->rcList.top; 
     2689          rcItem.top -= infoPtr->rcList.top;
    26892690          nScrollPosHeight = infoPtr->nItemHeight;
    26902691        }
     
    27032704          scrollInfo.nPos += rcItem.top / nScrollPosHeight - 1;
    27042705        }
    2705        
     2706
    27062707        SetScrollInfo(hwnd, SB_VERT, &scrollInfo, TRUE);
    27072708      }
     
    27312732          scrollInfo.nPos += rcItem.bottom / nScrollPosHeight + 1;
    27322733        }
    2733        
     2734
    27342735        SetScrollInfo(hwnd, SB_VERT, &scrollInfo, TRUE);
    27352736      }
    27362737    }
    27372738  }
    2738  
     2739
    27392740  return TRUE;
    27402741}
     
    27432744 * DESCRIPTION:
    27442745 * Retrieves the nearest item, given a position and a direction.
    2745  * 
     2746 *
    27462747 * PARAMETER(S):
    27472748 * [I] HWND : window handle
     
    27652766    lvHitTestInfo.pt.x += pt.x;
    27662767    lvHitTestInfo.pt.y += pt.y;
    2767    
     2768
    27682769    do
    2769     { 
     2770    {
    27702771      if (vkDirection == VK_DOWN)
    27712772      {
    27722773        lvHitTestInfo.pt.y += infoPtr->nItemHeight;
    2773       }     
     2774      }
    27742775      else if (vkDirection == VK_UP)
    27752776      {
     
    27992800
    28002801  return nItem;
    2801 } 
     2802}
    28022803
    28032804/***
    28042805 * DESCRIPTION:
    28052806 * Searches for an item with specific characteristics.
    2806  * 
     2807 *
    28072808 * PARAMETER(S):
    28082809 * [I] HWND : window handle
    28092810 * [I] INT : base item index
    28102811 * [I] LPLVFINDINFO : item information to look for
    2811  * 
     2812 *
    28122813 * RETURN:
    28132814 *   SUCCESS : index of item
    28142815 *   FAILURE : -1
    28152816 */
    2816 static LRESULT LISTVIEW_FindItem(HWND hwnd, INT nStart, 
     2817static LRESULT LISTVIEW_FindItem(HWND hwnd, INT nStart,
    28172818                                 LPLVFINDINFO lpFindInfo)
    28182819{
     
    28332834      lvItem.mask |= LVIF_PARAM;
    28342835    }
    2835    
     2836
    28362837    if (lpFindInfo->flags & LVFI_STRING)
    28372838    {
     
    28652866        if (lpFindInfo->flags & LVFI_NEARESTXY)
    28662867        {
    2867           nItem = LISTVIEW_GetNearestItem(hwnd, ptItem, 
     2868          nItem = LISTVIEW_GetNearestItem(hwnd, ptItem,
    28682869                                          lpFindInfo->vkDirection);
    28692870          if (nItem != -1)
     
    28802881          nItem++;
    28812882        }
    2882        
     2883
    28832884        lvItem.iItem = nItem;
    28842885        lvItem.iSubItem = 0;
     
    28982899            }
    28992900          }
    2900          
     2901
    29012902          if (lvItem.mask & LVIF_PARAM)
    29022903          {
     
    29042905              continue;
    29052906          }
    2906          
     2907
    29072908          return nItem;
    29082909        }
     
    29182919      {
    29192920        return -1;
    2920       }       
    2921     }
    2922   }
    2923 
    2924  return -1; 
     2921      }
     2922    }
     2923  }
     2924
     2925 return -1;
    29252926}
    29262927
     
    29282929 * DESCRIPTION:
    29292930 * Retrieves the background color of the listview control.
    2930  * 
     2931 *
    29312932 * PARAMETER(S):
    29322933 * [I] HWND : window handle
     
    29452946 * DESCRIPTION:
    29462947 * Retrieves the background image of the listview control.
    2947  * 
     2948 *
    29482949 * PARAMETER(S):
    29492950 * [I] HWND : window handle
     
    29632964 * DESCRIPTION:
    29642965 * Retrieves the callback mask.
    2965  * 
     2966 *
    29662967 * PARAMETER(S):
    29672968 * [I] HWND : window handle
     
    29802981 * DESCRIPTION:
    29812982 * Retrieves column attributes.
    2982  * 
     2983 *
    29832984 * PARAMETER(S):
    29842985 * [I] HWND : window handle
     
    29952996  HDITEMA hdi;
    29962997  BOOL bResult = FALSE;
    2997  
     2998
    29982999  if (lpColumn != NULL)
    29993000  {
    30003001    /* initialize memory */
    30013002    ZeroMemory(&hdi, sizeof(HDITEMA));
    3002    
     3003
    30033004    if (lpColumn->mask & LVCF_FMT)
    30043005    {
     
    30293030    if (bResult != FALSE)
    30303031    {
    3031       if (lpColumn->mask & LVCF_FMT) 
     3032      if (lpColumn->mask & LVCF_FMT)
    30323033      {
    30333034        lpColumn->fmt = 0;
     
    30563057        lpColumn->cx = hdi.cxy;
    30573058      }
    3058      
     3059
    30593060      if ((lpColumn->mask & LVCF_TEXT) && (lpColumn->pszText) && (hdi.pszText))
    30603061      {
    3061         lstrcpynA (lpColumn->pszText, hdi.pszText, lpColumn->cchTextMax);
     3062        lstrcpynA (lpColumn->pszText, hdi.pszText, MIN(lpColumn->cchTextMax,lstrlenA(hdi.pszText)));
    30623063      }
    30633064
     
    30833084 * DESCRIPTION:
    30843085 * Retrieves the column width.
    3085  * 
     3086 *
    30863087 * PARAMETER(S):
    30873088 * [I] HWND : window handle
     
    30903091 * RETURN:
    30913092 *   SUCCESS : column width
    3092  *   FAILURE : zero 
     3093 *   FAILURE : zero
    30933094 */
    30943095static LRESULT LISTVIEW_GetColumnWidth(HWND hwnd, INT nColumn)
     
    31193120/***
    31203121 * DESCRIPTION:
    3121  * In list or report display mode, retrieves the number of items that can fit 
    3122  * vertically in the visible area. In icon or small icon display mode, 
     3122 * In list or report display mode, retrieves the number of items that can fit
     3123 * vertically in the visible area. In icon or small icon display mode,
    31233124 * retrieves the total number of visible items.
    3124  * 
     3125 *
    31253126 * PARAMETER(S):
    31263127 * [I] HWND : window handle
     
    31393140    if (infoPtr->rcList.right > infoPtr->nItemWidth)
    31403141    {
    3141       nItemCount = LISTVIEW_GetCountPerRow(hwnd) * 
     3142      nItemCount = LISTVIEW_GetCountPerRow(hwnd) *
    31423143                   LISTVIEW_GetCountPerColumn(hwnd);
    31433144    }
     
    31613162 * DESCRIPTION:
    31623163 * Retrieves the handle to the header control.
    3163  * 
     3164 *
    31643165 * PARAMETER(S):
    31653166 * [I] HWND : window handle
     
    31823183 * DESCRIPTION:
    31833184 * Retrieves an image list handle.
    3184  * 
    3185  * PARAMETER(S):
    3186  * [I] HWND : window handle
    3187  * [I] INT : image list identifier 
    3188  * 
     3185 *
     3186 * PARAMETER(S):
     3187 * [I] HWND : window handle
     3188 * [I] INT : image list identifier
     3189 *
    31893190 * RETURN:
    31903191 *   SUCCESS : image list handle
     
    31963197  HIMAGELIST himl = NULL;
    31973198
    3198   switch (nImageList) 
     3199  switch (nImageList)
    31993200  {
    32003201  case LVSIL_NORMAL:
     
    32173218 * DESCRIPTION:
    32183219 * Retrieves item attributes.
    3219  * 
     3220 *
    32203221 * PARAMETER(S):
    32213222 * [I] HWND : window handle
    32223223 * [IO] LPLVITEMA : item info
    3223  * 
    3224  * RETURN:
    3225  *   SUCCESS : TRUE 
     3224 *
     3225 * RETURN:
     3226 *   SUCCESS : TRUE
    32263227 *   FAILURE : FALSE
    32273228 */
     
    32573258              dispInfo.item.mask |= LVIF_IMAGE;
    32583259            }
    3259            
    3260             if ((lpItem->pszText == LPSTR_TEXTCALLBACKA) && 
     3260
     3261            if ((lpItem->pszText == LPSTR_TEXTCALLBACKA) &&
    32613262                (lpLVItem->mask & LVIF_TEXT))
    32623263            {
     
    32663267              dispInfo.item.cchTextMax = lpLVItem->cchTextMax;
    32673268            }
    3268            
     3269
    32693270            if ((infoPtr->uCallbackMask != 0) && (lpLVItem->mask & LVIF_STATE))
    3270             {       
     3271            {
    32713272              dispInfo.item.mask |= LVIF_STATE;
    3272               dispInfo.item.stateMask = infoPtr->uCallbackMask; 
     3273              dispInfo.item.stateMask = infoPtr->uCallbackMask;
    32733274            }
    3274            
     3275
    32753276            if (dispInfo.item.mask != 0)
    32763277            {
     
    32833284              ListView_Notify(GetParent(hwnd), lCtrlId, &dispInfo);
    32843285            }
    3285            
     3286
    32863287            if (dispInfo.item.mask & LVIF_IMAGE)
    32873288            {
     
    32923293              lpLVItem->iImage = lpItem->iImage;
    32933294            }
    3294            
     3295
    32953296            if (dispInfo.item.mask & LVIF_TEXT)
    32963297            {
     
    33053306              lpLVItem->pszText = lpItem->pszText;
    33063307            }
    3307            
     3308
    33083309            if (dispInfo.item.mask & LVIF_STATE)
    33093310            {
    33103311              lpLVItem->state = lpItem->state;
    33113312              lpLVItem->state &= ~dispInfo.item.stateMask;
    3312               lpLVItem->state |= (dispInfo.item.state & 
     3313              lpLVItem->state |= (dispInfo.item.state &
    33133314                                  dispInfo.item.stateMask);
    33143315            }
     
    33223323              lpLVItem->lParam = lpItem->lParam;
    33233324            }
    3324            
     3325
    33253326            if (lpLVItem->mask & LVIF_INDENT)
    33263327            {
     
    33303331          else
    33313332          {
    3332             lpSubItem = LISTVIEW_GetSubItemPtr(hdpaSubItems, 
     3333            lpSubItem = LISTVIEW_GetSubItemPtr(hdpaSubItems,
    33333334                                               lpLVItem->iSubItem);
    33343335            if (lpSubItem != NULL)
     
    33393340                dispInfo.item.mask |= LVIF_IMAGE;
    33403341              }
    3341              
    3342               if ((lpSubItem->pszText == LPSTR_TEXTCALLBACKA) && 
     3342
     3343              if ((lpSubItem->pszText == LPSTR_TEXTCALLBACKA) &&
    33433344                  (lpLVItem->mask & LVIF_TEXT))
    33443345              {
    33453346                dispInfo.item.mask |= LVIF_TEXT;
    3346                 ZeroMemory(lpLVItem->pszText, 
     3347                ZeroMemory(lpLVItem->pszText,
    33473348                           sizeof(CHAR)*lpLVItem->cchTextMax);
    33483349                dispInfo.item.pszText = lpLVItem->pszText;
     
    33563357                dispInfo.item.mask |= LVIF_IMAGE;
    33573358              }
    3358          
     3359
    33593360              if (lpLVItem->mask & LVIF_TEXT)
    33603361              {
    33613362                dispInfo.item.mask |= LVIF_TEXT;
    3362                 ZeroMemory(lpLVItem->pszText, 
     3363                ZeroMemory(lpLVItem->pszText,
    33633364                           sizeof(CHAR)*lpLVItem->cchTextMax);
    33643365                dispInfo.item.pszText = lpLVItem->pszText;
     
    34163417 * DESCRIPTION:
    34173418 * Retrieves the number of items in the listview control.
    3418  * 
    3419  * PARAMETER(S):
    3420  * [I] HWND : window handle
    3421  * 
     3419 *
     3420 * PARAMETER(S):
     3421 * [I] HWND : window handle
     3422 *
    34223423 * RETURN:
    34233424 * Number of items.
     
    34333434 * DESCRIPTION:
    34343435 * Retrieves the position (upper-left) of the listview control item.
    3435  * 
     3436 *
    34363437 * PARAMETER(S):
    34373438 * [I] HWND : window handle
     
    34433444 *   FAILURE : FALSE
    34443445 */
    3445 static BOOL LISTVIEW_GetItemPosition(HWND hwnd, INT nItem, 
     3446static BOOL LISTVIEW_GetItemPosition(HWND hwnd, INT nItem,
    34463447                                     LPPOINT lpptPosition)
    34473448{
     
    34543455  INT nRow;
    34553456
    3456   TRACE("(hwnd=%x,nItem=%d,lpptPosition=%p)\n", hwnd, nItem, 
     3457  TRACE("(hwnd=%x,nItem=%d,lpptPosition=%p)\n", hwnd, nItem,
    34573458        lpptPosition);
    34583459
    3459   if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) && 
     3460  if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) &&
    34603461      (lpptPosition != NULL))
    34613462  {
     
    34763477        {
    34773478          lpptPosition->x = (nItem / nCountPerColumn -1) * infoPtr->nItemWidth;
    3478           lpptPosition->y = (nRow + nCountPerColumn) * infoPtr->nItemHeight; 
     3479          lpptPosition->y = (nRow + nCountPerColumn) * infoPtr->nItemHeight;
    34793480        }
    34803481      }
     
    34893490      bResult = TRUE;
    34903491      lpptPosition->x = REPORT_MARGINX;
    3491       lpptPosition->y = ((nItem - ListView_GetTopIndex(hwnd)) * 
     3492      lpptPosition->y = ((nItem - ListView_GetTopIndex(hwnd)) *
    34923493                         infoPtr->nItemHeight) + infoPtr->rcList.top;
    34933494    }
     
    35073508    }
    35083509  }
    3509    
     3510
    35103511  return bResult;
    35113512}
     
    35143515 * DESCRIPTION:
    35153516 * Retrieves the bounding rectangle for a listview control item.
    3516  * 
     3517 *
    35173518 * PARAMETER(S):
    35183519 * [I] HWND : window handle
    35193520 * [I] INT : item index
    35203521 * [IO] LPRECT : bounding rectangle coordinates
    3521  * 
     3522 *
    35223523 * RETURN:
    35233524 *   SUCCESS : TRUE
     
    35383539
    35393540  TRACE("(hwnd=%x, nItem=%d, lprc=%p)\n", hwnd, nItem, lprc);
    3540  
     3541
    35413542  if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) && (lprc != NULL))
    35423543  {
    35433544    if (ListView_GetItemPosition(hwnd, nItem, &ptItem) != FALSE)
    35443545    {
    3545       switch(lprc->left) 
    3546       { 
    3547       case LVIR_ICON: 
     3546      switch(lprc->left)
     3547      {
     3548      case LVIR_ICON:
    35483549        if (uView == LVS_ICON)
    35493550        {
     
    35563557              lprc->top = ptItem.y + ptOrigin.y;
    35573558              lprc->right = lprc->left + infoPtr->iconSize.cx;
    3558               lprc->bottom = (lprc->top + infoPtr->iconSize.cy + 
     3559              lprc->bottom = (lprc->top + infoPtr->iconSize.cy +
    35593560                              ICON_BOTTOM_PADDING + ICON_TOP_PADDING);
    35603561            }
     
    35723573            if (infoPtr->himlState != NULL)
    35733574              lprc->left += infoPtr->iconSize.cx;
    3574              
     3575
    35753576            if (infoPtr->himlSmall != NULL)
    35763577              lprc->right = lprc->left + infoPtr->iconSize.cx;
     
    35793580          }
    35803581        }
    3581         else 
     3582        else
    35823583        {
    35833584          bResult = TRUE;
     
    35903591            lprc->left += infoPtr->iconSize.cx;
    35913592          }
    3592            
     3593
    35933594          if (infoPtr->himlSmall != NULL)
    35943595          {
     
    36023603        break;
    36033604
    3604       case LVIR_LABEL: 
     3605      case LVIR_LABEL:
    36053606        if (uView == LVS_ICON)
    36063607        {
     
    36243625                lprc->right = lprc->left + infoPtr->iconSpacing.cx - 1;
    36253626              }
    3626            
     3627
    36273628              hdc = GetDC(hwnd);
    36283629              hOldFont = SelectObject(hdc, infoPtr->hFont);
     
    36313632              SelectObject(hdc, hOldFont);
    36323633              ReleaseDC(hwnd, hdc);
    3633             }             
     3634            }
    36343635          }
    36353636        }
     
    36393640          {
    36403641            bResult = TRUE;
    3641             nMaxWidth = lprc->left = ptItem.x + ptOrigin.x; 
     3642            nMaxWidth = lprc->left = ptItem.x + ptOrigin.x;
    36423643            lprc->top = ptItem.y + ptOrigin.y;
    36433644            lprc->bottom = lprc->top + infoPtr->nItemHeight;
    3644            
     3645
    36453646            if (infoPtr->himlState != NULL)
    36463647            {
    36473648              lprc->left += infoPtr->iconSize.cx;
    36483649            }
    3649            
     3650
    36503651            if (infoPtr->himlSmall != NULL)
    36513652            {
    36523653              lprc->left += infoPtr->iconSize.cx;
    36533654            }
    3654            
     3655
    36553656            nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
    36563657            if (lprc->left + nLabelWidth < nMaxWidth + infoPtr->nItemWidth)
     
    36673668        {
    36683669          bResult = TRUE;
    3669           lprc->left = ptItem.x; 
     3670          lprc->left = ptItem.x;
    36703671          lprc->top = ptItem.y;
    36713672          lprc->bottom = lprc->top + infoPtr->nItemHeight;
     
    36863687
    36873688      case LVIR_BOUNDS:
    3688         if (uView == LVS_ICON)
    3689         {
    3690           if (infoPtr->himlNormal != NULL)
    3691           {
    3692             if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE)
    3693             {
    3694               bResult = TRUE;
    3695               lprc->left = ptItem.x + ptOrigin.x;
    3696               lprc->top = ptItem.y + ptOrigin.y;
    3697               lprc->right = lprc->left + infoPtr->iconSpacing.cx;
    3698               lprc->bottom = lprc->top + infoPtr->iconSpacing.cy;
    3699             }
    3700           }
    3701         }
    3702         else if (uView == LVS_SMALLICON)
    3703         {
    3704           if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE)
    3705           {
    3706             bResult = TRUE;
    3707             lprc->left = ptItem.x + ptOrigin.x;
    3708             lprc->right = lprc->left;
    3709             lprc->top = ptItem.y + ptOrigin.y;
    3710             lprc->bottom = lprc->top + infoPtr->nItemHeight;
    3711             if (infoPtr->himlState != NULL)
    3712               lprc->right += infoPtr->iconSize.cx;
    3713             if (infoPtr->himlSmall != NULL)
    3714               lprc->right += infoPtr->iconSize.cx;
    3715             lprc->right += LISTVIEW_GetLabelWidth(hwnd, nItem);
    3716           }
    3717         }
    3718         else
    3719         {
    3720           bResult = TRUE;
    3721           lprc->left = ptItem.x;
    3722           lprc->right = lprc->left;
    3723           lprc->top = ptItem.y;
    3724           lprc->bottom = lprc->top + infoPtr->nItemHeight;
    3725 
    3726           if (infoPtr->himlState != NULL)
    3727           {
    3728             lprc->right += infoPtr->iconSize.cx;
    3729           }
    3730 
    3731           if (infoPtr->himlSmall != NULL)
    3732           {
    3733             lprc->right += infoPtr->iconSize.cx;
    3734           }
    3735 
    3736           lprc->right += LISTVIEW_GetLabelWidth(hwnd, nItem);
    3737         }
    3738         break;
    3739        
    3740       case LVIR_SELECTBOUNDS:
    37413689        if (uView == LVS_ICON)
    37423690        {
     
    37513699              lprc->bottom = lprc->top + infoPtr->iconSpacing.cy;
    37523700            }
    3753           } 
     3701          }
    37543702        }
    37553703        else if (uView == LVS_SMALLICON)
     
    37583706          {
    37593707            bResult = TRUE;
    3760             lprc->left = ptItem.x + ptOrigin.x; 
     3708            lprc->left = ptItem.x + ptOrigin.x;
     3709            lprc->right = lprc->left;
    37613710            lprc->top = ptItem.y + ptOrigin.y;
    37623711            lprc->bottom = lprc->top + infoPtr->nItemHeight;
    3763            
     3712            if (infoPtr->himlState != NULL)
     3713              lprc->right += infoPtr->iconSize.cx;
     3714            if (infoPtr->himlSmall != NULL)
     3715              lprc->right += infoPtr->iconSize.cx;
     3716            lprc->right += LISTVIEW_GetLabelWidth(hwnd, nItem);
     3717          }
     3718        }
     3719        else
     3720        {
     3721          bResult = TRUE;
     3722          lprc->left = ptItem.x;
     3723          lprc->right = lprc->left;
     3724          lprc->top = ptItem.y;
     3725          lprc->bottom = lprc->top + infoPtr->nItemHeight;
     3726
     3727          if (infoPtr->himlState != NULL)
     3728          {
     3729            lprc->right += infoPtr->iconSize.cx;
     3730          }
     3731
     3732          if (infoPtr->himlSmall != NULL)
     3733          {
     3734            lprc->right += infoPtr->iconSize.cx;
     3735          }
     3736
     3737          lprc->right += LISTVIEW_GetLabelWidth(hwnd, nItem);
     3738        }
     3739        break;
     3740
     3741      case LVIR_SELECTBOUNDS:
     3742        if (uView == LVS_ICON)
     3743        {
     3744          if (infoPtr->himlNormal != NULL)
     3745          {
     3746            if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE)
     3747            {
     3748              bResult = TRUE;
     3749              lprc->left = ptItem.x + ptOrigin.x;
     3750              lprc->top = ptItem.y + ptOrigin.y;
     3751              lprc->right = lprc->left + infoPtr->iconSpacing.cx;
     3752              lprc->bottom = lprc->top + infoPtr->iconSpacing.cy;
     3753            }
     3754          }
     3755        }
     3756        else if (uView == LVS_SMALLICON)
     3757        {
     3758          if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE)
     3759          {
     3760            bResult = TRUE;
     3761            lprc->left = ptItem.x + ptOrigin.x;
     3762            lprc->top = ptItem.y + ptOrigin.y;
     3763            lprc->bottom = lprc->top + infoPtr->nItemHeight;
     3764
    37643765            if (infoPtr->himlState != NULL)
    37653766            {
    37663767              lprc->left += infoPtr->iconSize.cx;
    37673768            }
    3768            
     3769
    37693770            lprc->right = lprc->left;
    3770            
     3771
    37713772            if (infoPtr->himlSmall != NULL)
    37723773            {
    37733774              lprc->right += infoPtr->iconSize.cx;
    37743775            }
    3775            
     3776
    37763777            lprc->right += LISTVIEW_GetLabelWidth(hwnd, nItem);
    37773778          }
     
    37803781        {
    37813782          bResult = TRUE;
    3782           lprc->left = ptItem.x; 
     3783          lprc->left = ptItem.x;
    37833784          lprc->top = ptItem.y;
    37843785          lprc->bottom = lprc->top + infoPtr->nItemHeight;
     
    37883789            lprc->left += infoPtr->iconSize.cx;
    37893790          }
    3790          
     3791
    37913792          lprc->right = lprc->left;
    3792        
     3793
    37933794          if (infoPtr->himlSmall != NULL)
    37943795          {
     
    38023803    }
    38033804  }
    3804        
     3805
    38053806  return bResult;
    38063807}
     
    38093810 * DESCRIPTION:
    38103811 * Retrieves the width of a label.
    3811  * 
    3812  * PARAMETER(S):
    3813  * [I] HWND : window handle
    3814  * 
     3812 *
     3813 * PARAMETER(S):
     3814 * [I] HWND : window handle
     3815 *
    38153816 * RETURN:
    38163817 *   SUCCESS : string width (in pixels)
     
    38323833  if (ListView_GetItemA(hwnd, &lvItem) != FALSE)
    38333834  {
    3834     nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText); 
    3835   }
    3836    
     3835    nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText);
     3836  }
     3837
    38373838  return nLabelWidth;
    38383839}
     
    38413842 * DESCRIPTION:
    38423843 * Retrieves the spacing between listview control items.
    3843  * 
    3844  * PARAMETER(S):
    3845  * [I] HWND : window handle
    3846  * [I] BOOL : flag for small or large icon 
     3844 *
     3845 * PARAMETER(S):
     3846 * [I] HWND : window handle
     3847 * [I] BOOL : flag for small or large icon
    38473848 *
    38483849 * RETURN:
     
    38623863    /* TODO: need to store width of smallicon item */
    38633864    lResult = MAKELONG(0, infoPtr->nItemHeight);
    3864   } 
    3865  
     3865  }
     3866
    38663867  return lResult;
    38673868}
     
    38703871 * DESCRIPTION:
    38713872 * Retrieves the state of a listview control item.
    3872  * 
     3873 *
    38733874 * PARAMETER(S):
    38743875 * [I] HWND : window handle
    38753876 * [I] INT : item index
    38763877 * [I] UINT : state mask
    3877  * 
     3878 *
    38783879 * RETURN:
    38793880 * State specified by the mask.
     
    39023903/***
    39033904 * DESCRIPTION:
    3904  * Retrieves the text of a listview control item or subitem. 
    3905  * 
     3905 * Retrieves the text of a listview control item or subitem.
     3906 *
    39063907 * PARAMETER(S):
    39073908 * [I] HWND : window handle
    39083909 * [I] INT : item index
    39093910 * [IO] LPLVITEMA : item information
    3910  * 
     3911 *
    39113912 * RETURN:
    39123913 *   SUCCESS : string length
     
    39173918  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    39183919  INT nLength = 0;
    3919  
     3920
    39203921  if (lpLVItem != NULL)
    39213922  {
     
    39373938 * DESCRIPTION:
    39383939 * Searches for an item based on properties + relationships.
    3939  * 
     3940 *
    39403941 * PARAMETER(S):
    39413942 * [I] HWND : window handle
    39423943 * [I] INT : item index
    39433944 * [I] INT : relationship flag
    3944  * 
     3945 *
    39453946 * RETURN:
    39463947 *   SUCCESS : item index
     
    39553956  INT nCountPerColumn;
    39563957  INT i;
    3957  
     3958
    39583959  if ((nItem >= -1) && (nItem < GETITEMCOUNT(infoPtr)))
    3959   { 
     3960  {
    39603961    ZeroMemory(&lvFindInfo, sizeof(LVFINDINFO));
    39613962
    39623963    if (uFlags & LVNI_CUT)
    39633964      uMask |= LVIS_CUT;
    3964    
     3965
    39653966    if (uFlags & LVNI_DROPHILITED)
    39663967      uMask |= LVIS_DROPHILITED;
    3967          
     3968
    39683969    if (uFlags & LVNI_FOCUSED)
    39693970      uMask |= LVIS_FOCUSED;
     
    40874088 * DESCRIPTION:
    40884089 * Retrieves the origin coordinates when in icon or small icon display mode.
    4089  * 
     4090 *
    40904091 * PARAMETER(S):
    40914092 * [I] HWND : window handle
    40924093 * [O] LPPOINT : coordinate information
    4093  * 
     4094 *
    40944095 * RETURN:
    40954096 *   SUCCESS : TRUE
     
    41044105  INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top;
    41054106  BOOL bResult = FALSE;
    4106  
     4107
    41074108  TRACE("(hwnd=%x, lpptOrigin=%p)\n", hwnd, lpptOrigin);
    41084109
     
    41174118    {
    41184119      scrollInfo.fMask = SIF_POS;
    4119       if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE) 
     4120      if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE)
    41204121      {
    41214122        lpptOrigin->x = -scrollInfo.nPos * max(nListWidth / 10, 1);
     
    41314132      }
    41324133    }
    4133      
     4134
    41344135    bResult = TRUE;
    41354136  }
    4136  
     4137
    41374138  return bResult;
    41384139}
     
    41414142 * DESCRIPTION:
    41424143 * Retrieves the number of items that are marked as selected.
    4143  * 
    4144  * PARAMETER(S):
    4145  * [I] HWND : window handle
    4146  * 
     4144 *
     4145 * PARAMETER(S):
     4146 * [I] HWND : window handle
     4147 *
    41474148 * RETURN:
    41484149 * Number of items selected.
     
    41614162    }
    41624163  }
    4163  
     4164
    41644165  return nSelectedCount;
    41654166}
     
    41684169 * DESCRIPTION:
    41694170 * Retrieves item index that marks the start of a multiple selection.
    4170  * 
    4171  * PARAMETER(S):
    4172  * [I] HWND : window handle
    4173  * 
     4171 *
     4172 * PARAMETER(S):
     4173 * [I] HWND : window handle
     4174 *
    41744175 * RETURN:
    41754176 * Index number or -1 if there is no selection mark.
     
    41854186 * DESCRIPTION:
    41864187 * Retrieves the width of a string.
    4187  * 
    4188  * PARAMETER(S):
    4189  * [I] HWND : window handle
    4190  * 
     4188 *
     4189 * PARAMETER(S):
     4190 * [I] HWND : window handle
     4191 *
    41914192 * RETURN:
    41924193 *   SUCCESS : string width (in pixels)
     
    42174218 * DESCRIPTION:
    42184219 * Retrieves the text backgound color.
    4219  * 
    4220  * PARAMETER(S):
    4221  * [I] HWND : window handle
    4222  * 
     4220 *
     4221 * PARAMETER(S):
     4222 * [I] HWND : window handle
     4223 *
    42234224 * RETURN:
    42244225 * COLORREF associated with the the background.
     
    42344235 * DESCRIPTION:
    42354236 * Retrieves the text color.
    4236  * 
    4237  * PARAMETER(S):
    4238  * [I] HWND : window handle
    4239  * 
     4237 *
     4238 * PARAMETER(S):
     4239 * [I] HWND : window handle
     4240 *
    42404241 * RETURN:
    42414242 * COLORREF associated with the text.
     
    42514252 * DESCRIPTION:
    42524253 * Determines which section of the item was selected (if any).
    4253  * 
     4254 *
    42544255 * PARAMETER(S):
    42554256 * [I] HWND : window handle
     
    42654266  RECT rcItem;
    42664267  INT i;
    4267  
     4268
    42684269  TRACE("(hwnd=%x, x=%ld, y=%ld)\n", hwnd, lpHitTestInfo->pt.x,
    42694270        lpHitTestInfo->pt.y);
     
    42874288          }
    42884289        }
    4289      
     4290
    42904291        rcItem.left = LVIR_LABEL;
    42914292        if (LISTVIEW_GetItemRect(hwnd, i, &rcItem) != FALSE)
     
    42994300          }
    43004301        }
    4301        
     4302
    43024303        lpHitTestInfo->flags = LVHT_ONITEMSTATEICON;
    43034304        lpHitTestInfo->iItem = i;
     
    43074308    }
    43084309  }
    4309      
     4310
    43104311  lpHitTestInfo->flags = LVHT_NOWHERE;
    43114312
     
    43164317 * DESCRIPTION:
    43174318 * Determines which listview item is located at the specified position.
    4318  * 
     4319 *
    43194320 * PARAMETER(S):
    43204321 * [I] HWND : window handle
     
    43364337    lpHitTestInfo->flags = LVHT_TOLEFT;
    43374338  }
    4338   else if (infoPtr->rcList.right < lpHitTestInfo->pt.x) 
     4339  else if (infoPtr->rcList.right < lpHitTestInfo->pt.x)
    43394340  {
    43404341    lpHitTestInfo->flags = LVHT_TORIGHT;
     
    43444345    lpHitTestInfo->flags |= LVHT_ABOVE;
    43454346  }
    4346   else if (infoPtr->rcList.bottom < lpHitTestInfo->pt.y) 
     4347  else if (infoPtr->rcList.bottom < lpHitTestInfo->pt.y)
    43474348  {
    43484349    lpHitTestInfo->flags |= LVHT_BELOW;
     
    43534354    nItem = LISTVIEW_HitTestItem(hwnd, lpHitTestInfo);
    43544355  }
    4355  
     4356
    43564357  return nItem;
    43574358}
     
    43604361 * DESCRIPTION:
    43614362 * Inserts a new column.
    4362  * 
     4363 *
    43634364 * PARAMETER(S):
    43644365 * [I] HWND : window handle
     
    43704371 *   FAILURE : -1
    43714372 */
    4372 static LRESULT LISTVIEW_InsertColumnA(HWND hwnd, INT nColumn, 
     4373static LRESULT LISTVIEW_InsertColumnA(HWND hwnd, INT nColumn,
    43734374                                      LPLVCOLUMNA lpColumn)
    43744375{
     
    43774378  INT nNewColumn = -1;
    43784379
    4379   TRACE("(hwnd=%x, nColumn=%d, lpColumn=%p)\n",hwnd, nColumn, 
     4380  TRACE("(hwnd=%x, nColumn=%d, lpColumn=%p)\n",hwnd, nColumn,
    43804381        lpColumn);
    43814382
    4382   if (lpColumn != NULL) 
     4383  if (lpColumn != NULL)
    43834384  {
    43844385    /* initialize memory */
    43854386    ZeroMemory(&hdi, sizeof(HDITEMA));
    43864387
    4387     if (lpColumn->mask & LVCF_FMT) 
     4388    if (lpColumn->mask & LVCF_FMT)
    43884389    {
    43894390      /* format member is valid */
     
    44104411        }
    44114412      }
    4412  
     4413
    44134414      if (lpColumn->fmt & LVCFMT_BITMAP_ON_RIGHT)
    44144415      {
     
    44214422        /* ??? */
    44224423      }
    4423      
     4424
    44244425      if (lpColumn->fmt & LVCFMT_IMAGE)
    44254426      {
     
    44294430    }
    44304431
    4431     if (lpColumn->mask & LVCF_WIDTH) 
     4432    if (lpColumn->mask & LVCF_WIDTH)
    44324433    {
    44334434      hdi.mask |= HDI_WIDTH;
    44344435      hdi.cxy = lpColumn->cx;
    44354436    }
    4436  
    4437     if (lpColumn->mask & LVCF_TEXT) 
     4437
     4438    if (lpColumn->mask & LVCF_TEXT)
    44384439    {
    44394440      hdi.mask |= HDI_TEXT | HDI_FORMAT;
     
    44424443      hdi.fmt |= HDF_STRING;
    44434444    }
    4444  
    4445     if (lpColumn->mask & LVCF_IMAGE) 
     4445
     4446    if (lpColumn->mask & LVCF_IMAGE)
    44464447    {
    44474448      hdi.mask |= HDI_IMAGE;
     
    44494450    }
    44504451
    4451     if (lpColumn->mask & LVCF_ORDER) 
     4452    if (lpColumn->mask & LVCF_ORDER)
    44524453    {
    44534454      hdi.mask |= HDI_ORDER;
     
    44714472 * DESCRIPTION:
    44724473 * Inserts a new item in the listview control.
    4473  * 
     4474 *
    44744475 * PARAMETER(S):
    44754476 * [I] HWND : window handle
     
    45114512            if (nItem != -1)
    45124513            {
    4513               nItem = DPA_InsertPtr(infoPtr->hdpaItems, lpLVItem->iItem, 
     4514              nItem = DPA_InsertPtr(infoPtr->hdpaItems, lpLVItem->iItem,
    45144515                                    hdpaSubItems);
    45154516              if (nItem != -1)
     
    45214522                  {
    45224523                    LISTVIEW_SetItemFocus(hwnd, nItem);
    4523                   }           
     4524                  }
    45244525                }
    4525                
     4526
    45264527                /* send LVN_INSERTITEM notification */
    45274528                ZeroMemory(&nmlv, sizeof(NMLISTVIEW));
     
    45324533                nmlv.lParam = lpItem->lParam;;
    45334534                ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv);
    4534                
     4535
    45354536                /* align items (set position of each item) */
    45364537                if ((uView == LVS_SMALLICON) || (uView == LVS_ICON))
     
    45454546                  }
    45464547                }
    4547                
     4548
    45484549                LISTVIEW_UpdateScroll(hwnd);
    45494550                /* refresh client area */
     
    45624563    COMCTL32_Free(lpItem);
    45634564  }
    4564  
     4565
    45654566  return nItem;
    45664567}
     
    45714572 * DESCRIPTION:
    45724573 * Redraws a range of items.
    4573  * 
     4574 *
    45744575 * PARAMETER(S):
    45754576 * [I] HWND : window handle
     
    45834584static LRESULT LISTVIEW_RedrawItems(HWND hwnd, INT nFirst, INT nLast)
    45844585{
    4585   LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 
     4586  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    45864587  BOOL bResult = FALSE;
    45874588  RECT rc;
     
    46074608 * DESCRIPTION:
    46084609 * Sets the background color.
    4609  * 
     4610 *
    46104611 * PARAMETER(S):
    46114612 * [I] HWND : window handle
     
    46224623  infoPtr->clrBk = clrBk;
    46234624  InvalidateRect(hwnd, NULL, TRUE);
    4624  
     4625
    46254626  return TRUE;
    46264627}
     
    46304631 * Sets the callback mask. This mask will be used when the parent
    46314632 * window stores state information (some or all).
    4632  * 
     4633 *
    46334634 * PARAMETER(S):
    46344635 * [I] HWND : window handle
     
    46514652 * DESCRIPTION:
    46524653 * Sets the attributes of a header item.
    4653  * 
     4654 *
    46544655 * PARAMETER(S):
    46554656 * [I] HWND : window handle
     
    46614662 *   FAILURE : FALSE
    46624663 */
    4663 static LRESULT LISTVIEW_SetColumnA(HWND hwnd, INT nColumn, 
     4664static LRESULT LISTVIEW_SetColumnA(HWND hwnd, INT nColumn,
    46644665                                   LPLVCOLUMNA lpColumn)
    46654666{
     
    46684669  HDITEMA hdi;
    46694670
    4670   if ((lpColumn != NULL) && (nColumn >= 0) && 
     4671  if ((lpColumn != NULL) && (nColumn >= 0) &&
    46714672      (nColumn < Header_GetItemCount(infoPtr->hwndHeader)))
    46724673  {
     
    46744675    ZeroMemory(&hdi, sizeof(HDITEMA));
    46754676
    4676     if (lpColumn->mask & LVCF_FMT) 
     4677    if (lpColumn->mask & LVCF_FMT)
    46774678    {
    46784679      /* format member is valid */
     
    46994700        }
    47004701      }
    4701      
     4702
    47024703      if (lpColumn->fmt & LVCFMT_BITMAP_ON_RIGHT)
    47034704      {
     
    47094710        hdi.fmt |= HDF_IMAGE;
    47104711      }
    4711      
     4712
    47124713      if (lpColumn->fmt & LVCFMT_IMAGE)
    47134714      {
     
    47174718    }
    47184719
    4719     if (lpColumn->mask & LVCF_WIDTH) 
     4720    if (lpColumn->mask & LVCF_WIDTH)
    47204721    {
    47214722      hdi.mask |= HDI_WIDTH;
    47224723      hdi.cxy = lpColumn->cx;
    47234724    }
    4724    
    4725     if (lpColumn->mask & LVCF_TEXT) 
     4725
     4726    if (lpColumn->mask & LVCF_TEXT)
    47264727    {
    47274728      hdi.mask |= HDI_TEXT | HDI_FORMAT;
     
    47304731      hdi.fmt |= HDF_STRING;
    47314732    }
    4732  
    4733     if (lpColumn->mask & LVCF_IMAGE) 
     4733
     4734    if (lpColumn->mask & LVCF_IMAGE)
    47344735    {
    47354736      hdi.mask |= HDI_IMAGE;
     
    47374738    }
    47384739
    4739     if (lpColumn->mask & LVCF_ORDER) 
     4740    if (lpColumn->mask & LVCF_ORDER)
    47404741    {
    47414742      hdi.mask |= HDI_ORDER;
     
    47464747    bResult = Header_SetItemA(infoPtr->hwndHeader, nColumn, &hdi);
    47474748  }
    4748  
     4749
    47494750  return bResult;
    47504751}
     
    47734774    lStyle = GetWindowLongA(hwnd, GWL_STYLE);
    47744775    if ((lStyle & LVS_TYPEMASK) != LVS_REPORT)
    4775         return (FALSE);
     4776        return (FALSE);
    47764777
    47774778    // make sure we can get the listview info
    47784779    if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0)))
    4779         return (FALSE); 
     4780        return (FALSE);
    47804781    if (!infoPtr->hwndHeader) // make sure we have a header
    4781         return (FALSE);
    4782        
     4782        return (FALSE);
     4783
    47834784    // FIXME: currently ignoring LVSCW_AUTOSIZE (-1) and
    47844785    // LVSCV_AUTOSIZE_USEHEADER (-2)
    4785     if (cx < 0) 
    4786         return (FALSE);
    4787        
     4786    if (cx < 0)
     4787        return (FALSE);
     4788
    47884789    hdi.mask = HDI_WIDTH;
    47894790    hdi.cxy = cx;
     
    48024803 * DESCRIPTION:
    48034804 * Sets image lists.
    4804  * 
    4805  * PARAMETER(S):
    4806  * [I] HWND : window handle
    4807  * [I] INT : image list type 
     4805 *
     4806 * PARAMETER(S):
     4807 * [I] HWND : window handle
     4808 * [I] INT : image list type
    48084809 * [I] HIMAGELIST : image list handle
    48094810 *
     
    48174818  HIMAGELIST himlTemp = 0;
    48184819
    4819   switch (nType) 
     4820  switch (nType)
    48204821  {
    48214822  case LVSIL_NORMAL:
     
    48434844 * DESCRIPTION:
    48444845 * Sets the attributes of an item.
    4845  * 
    4846  * PARAMETER(S):
    4847  * [I] HWND : window handle
    4848  * [I] LPLVITEM : item information 
     4846 *
     4847 * PARAMETER(S):
     4848 * [I] HWND : window handle
     4849 * [I] LPLVITEM : item information
    48494850 *
    48504851 * RETURN:
     
    48814882 * DESCRIPTION:
    48824883 * Preallocates memory.
    4883  * 
     4884 *
    48844885 * PARAMETER(S):
    48854886 * [I] HWND : window handle
     
    48974898 * DESCRIPTION:
    48984899 * Sets the position of an item.
    4899  * 
     4900 *
    49004901 * PARAMETER(S):
    49014902 * [I] HWND : window handle
     
    49084909 *   FAILURE : FALSE
    49094910 */
    4910 static BOOL LISTVIEW_SetItemPosition(HWND hwnd, INT nItem, 
     4911static BOOL LISTVIEW_SetItemPosition(HWND hwnd, INT nItem,
    49114912                                     INT nPosX, INT nPosY)
    49124913{
     
    49434944 * DESCRIPTION:
    49444945 * Sets the state of one or many items.
    4945  * 
     4946 *
    49464947 * PARAMETER(S):
    49474948 * [I] HWND : window handle
     
    49674968    lvItem.state = lpLVItem->state;
    49684969    lvItem.stateMask = lpLVItem->stateMask ;
    4969    
     4970
    49704971    /* apply to all items */
    49714972    for (i = 0; i< GETITEMCOUNT(infoPtr); i++)
     
    49944995 * DESCRIPTION:
    49954996 * Sets the text of an item or subitem.
    4996  * 
     4997 *
    49974998 * PARAMETER(S):
    49984999 * [I] HWND : window handle
     
    50195020    bResult = ListView_SetItemA(hwnd, &lvItem);
    50205021  }
    5021  
     5022
    50225023  return bResult;
    50235024}
     
    50265027 * DESCRIPTION:
    50275028 * Sets the text background color.
    5028  * 
     5029 *
    50295030 * PARAMETER(S):
    50305031 * [I] HWND : window handle
     
    50485049 * DESCRIPTION:
    50495050 * Sets the text foreground color.
    5050  * 
    5051  * PARAMETER(S):
    5052  * [I] HWND : window handle
    5053  * [I] COLORREF : text color 
     5051 *
     5052 * PARAMETER(S):
     5053 * [I] HWND : window handle
     5054 * [I] COLORREF : text color
    50545055 *
    50555056 * RETURN:
     
    50715072 * DESCRIPTION:
    50725073 * Callback internally used by LISTVIEW_SortItems()
    5073  * 
     5074 *
    50745075 * PARAMETER(S):
    50755076 * [I] LPVOID : first LISTVIEW_ITEM to compare
     
    50825083 *   if first and second are equivalent : zero
    50835084 */
    5084 static INT WINAPI LISTVIEW_CallBackCompare( 
    5085   LPVOID first, 
    5086   LPVOID second, 
     5085static INT WINAPI LISTVIEW_CallBackCompare(
     5086  LPVOID first,
     5087  LPVOID second,
    50875088  LPARAM lParam)
    50885089{
     
    51005101 * DESCRIPTION:
    51015102 * Sorts the listview items.
    5102  * 
     5103 *
    51035104 * PARAMETER(S):
    51045105 * [I] HWND : window handle
     
    51175118    int nCount, i;
    51185119    HDPA sortList;
    5119    
     5120
    51205121    if (!infoPtr || !infoPtr->hdpaItems)
    5121         return FALSE;
    5122    
     5122        return FALSE;
     5123
    51235124    nCount = GETITEMCOUNT(infoPtr);
    51245125    // if there are 0 or 1 items, there is no need to sort
    51255126    if (nCount > 1)
    51265127    {
    5127         sortList = DPA_Create(nCount);
    5128 
    5129         infoPtr->pfnCompare = (PFNLVCOMPARE)lParam;
    5130         infoPtr->lParamSort = (LPARAM)wParam;
    5131        
    5132         // append pointers one by one to sortList
    5133         for (i = 0; i < nCount; i++)
    5134         {
    5135             if ((hdpaSubItems = (HDPA) DPA_GetPtr(infoPtr->hdpaItems, i)))
    5136                 if ((lpItem = (LISTVIEW_ITEM *) DPA_GetPtr(hdpaSubItems, 0)))
    5137                     DPA_InsertPtr(sortList, nCount + 1, lpItem);
    5138         }
    5139 
    5140         // sort the sortList
    5141         DPA_Sort(sortList, LISTVIEW_CallBackCompare, hwnd);
    5142 
    5143         // copy the pointers back
    5144         for (i = 0; i < nCount; i++)
    5145         {
    5146             if ((hdpaSubItems = (HDPA) DPA_GetPtr(infoPtr->hdpaItems, i)) &&
    5147                 (lpItem = (LISTVIEW_ITEM *) DPA_GetPtr(sortList, i)))
    5148                 DPA_SetPtr(hdpaSubItems, 0, lpItem);
    5149         }
    5150 
    5151         DPA_Destroy(sortList);
     5128        sortList = DPA_Create(nCount);
     5129
     5130        infoPtr->pfnCompare = (PFNLVCOMPARE)lParam;
     5131        infoPtr->lParamSort = (LPARAM)wParam;
     5132
     5133        // append pointers one by one to sortList
     5134        for (i = 0; i < nCount; i++)
     5135        {
     5136            if ((hdpaSubItems = (HDPA) DPA_GetPtr(infoPtr->hdpaItems, i)))
     5137                if ((lpItem = (LISTVIEW_ITEM *) DPA_GetPtr(hdpaSubItems, 0)))
     5138                    DPA_InsertPtr(sortList, nCount + 1, lpItem);
     5139        }
     5140
     5141        // sort the sortList
     5142        DPA_Sort(sortList, LISTVIEW_CallBackCompare, hwnd);
     5143
     5144        // copy the pointers back
     5145        for (i = 0; i < nCount; i++)
     5146        {
     5147            if ((hdpaSubItems = (HDPA) DPA_GetPtr(infoPtr->hdpaItems, i)) &&
     5148                (lpItem = (LISTVIEW_ITEM *) DPA_GetPtr(sortList, i)))
     5149                DPA_SetPtr(hdpaSubItems, 0, lpItem);
     5150        }
     5151
     5152        DPA_Destroy(sortList);
    51525153    }
    51535154
     
    51585159 * DESCRIPTION:
    51595160 * Updates an items or rearranges the listview control.
    5160  * 
     5161 *
    51615162 * PARAMETER(S):
    51625163 * [I] HWND : window handle
     
    51995200 * DESCRIPTION:
    52005201 * Creates the listview control.
    5201  * 
     5202 *
    52025203 * PARAMETER(S):
    52035204 * [I] HWND : window handle
     
    52175218
    52185219  /* determine the type of structures to use */
    5219   infoPtr->notifyFormat = SendMessageA(GetParent(hwnd), WM_NOTIFYFORMAT, 
     5220  infoPtr->notifyFormat = SendMessageA(GetParent(hwnd), WM_NOTIFYFORMAT,
    52205221                                       (WPARAM)hwnd, (LPARAM)NF_QUERY);
    52215222  if (infoPtr->notifyFormat != NFR_ANSI)
    52225223  {
    5223     FIXME("ANSI notify format is NOT used\n");
    5224   }
    5225  
     5224    //FIXME("ANSI notify format is NOT used\n");
     5225  }
     5226
    52265227  /* initialize color information  */
    52275228  infoPtr->clrBk = GetSysColor(COLOR_WINDOW);
    52285229  infoPtr->clrText = GetSysColor(COLOR_WINDOWTEXT);
    5229   infoPtr->clrTextBk = GetSysColor(COLOR_WINDOW); 
     5230  infoPtr->clrTextBk = GetSysColor(COLOR_WINDOW);
    52305231
    52315232  /* set default values */
     
    52415242  infoPtr->hDefaultFont = CreateFontIndirectA(&logFont);
    52425243  infoPtr->hFont = infoPtr->hDefaultFont;
    5243  
     5244
    52445245  /* create header */
    5245   infoPtr->hwndHeader = CreateWindowA(WC_HEADERA, (LPCSTR)NULL,
    5246                                       WS_CHILD | HDS_HORZ | HDS_BUTTONS,
    5247                                       0, 0, 0, 0, hwnd, (HMENU)0,
     5246
     5247  infoPtr->hwndHeader = CreateWindowA(WC_HEADERA, (LPCSTR)NULL,
     5248                                      WS_CHILD | HDS_HORZ | HDS_BUTTONS,
     5249                                      0, 0, 0, 0, hwnd, (HMENU)0,
    52485250                                      lpcs->hInstance, NULL);
    52495251
    52505252  /* set header font */
    5251   SendMessageA(infoPtr->hwndHeader, WM_SETFONT, (WPARAM)infoPtr->hFont, 
     5253  SendMessageA(infoPtr->hwndHeader, WM_SETFONT, (WPARAM)infoPtr->hFont,
    52525254               (LPARAM)TRUE);
    5253  
     5255
    52545256  if (uView == LVS_ICON)
    52555257  {
     
    52895291 * DESCRIPTION:
    52905292 * Erases the background of the listview control.
    5291  * 
     5293 *
    52925294 * PARAMETER(S):
    52935295 * [I] HWND : window handle
    52945296 * [I] WPARAM : device context handle
    52955297 * [I] LPARAM : not used
    5296  * 
     5298 *
    52975299 * RETURN:
    52985300 *   SUCCESS : TRUE
    52995301 *   FAILURE : FALSE
    53005302 */
    5301 static LRESULT LISTVIEW_EraseBackground(HWND hwnd, WPARAM wParam, 
     5303static LRESULT LISTVIEW_EraseBackground(HWND hwnd, WPARAM wParam,
    53025304                                        LPARAM lParam)
    53035305{
     
    53055307  BOOL bResult;
    53065308
    5307   if (infoPtr->clrBk == CLR_NONE) 
     5309  if (infoPtr->clrBk == CLR_NONE)
    53085310  {
    53095311    bResult = SendMessageA(GetParent(hwnd), WM_ERASEBKGND, wParam, lParam);
    53105312  }
    5311   else 
     5313  else
    53125314  {
    53135315    RECT rc;
     
    53255327 * DESCRIPTION:
    53265328 * Retrieves the listview control font.
    5327  * 
     5329 *
    53285330 * PARAMETER(S):
    53295331 * [I] HWND : window handle
     
    53425344 * DESCRIPTION:
    53435345 * Performs vertical scrolling.
    5344  * 
     5346 *
    53455347 * PARAMETER(S):
    53465348 * [I] HWND : window handle
    53475349 * [I] INT : scroll code
    5348  * [I] SHORT : current scroll position if scroll code is SB_THIMBPOSITION 
     5350 * [I] SHORT : current scroll position if scroll code is SB_THIMBPOSITION
    53495351 *             or SB_THUMBTRACK.
    53505352 * [I] HWND : scrollbar control window handle
     
    53625364  scrollInfo.cbSize = sizeof(SCROLLINFO);
    53635365  scrollInfo.fMask = /*SIF_PAGE |*/ SIF_POS | SIF_RANGE;
    5364  
     5366
    53655367  if (GetScrollInfo(hwnd, SB_VERT, &scrollInfo) != FALSE)
    53665368  {
     
    53745376      }
    53755377    break;
    5376    
     5378
    53775379    case SB_LINEDOWN:
    53785380      if (scrollInfo.nPos < scrollInfo.nMax)
     
    53815383      }
    53825384      break;
    5383      
     5385
    53845386    case SB_PAGEUP:
    53855387      if (scrollInfo.nPos > scrollInfo.nMin)
     
    54065408      }
    54075409      break;
    5408      
     5410
    54095411    case SB_PAGEDOWN:
    54105412      if (scrollInfo.nPos < scrollInfo.nMax)
     
    54205422          nPage = 10;
    54215423        }
    5422        
     5424
    54235425        if (scrollInfo.nPos <= scrollInfo.nMax - nPage)
    54245426        {
     
    54435445    }
    54445446  }
    5445    
     5447
    54465448  return 0;
    54475449}
     
    54505452 * DESCRIPTION:
    54515453 * Performs horizontal scrolling.
    5452  * 
     5454 *
    54535455 * PARAMETER(S):
    54545456 * [I] HWND : window handle
    54555457 * [I] INT : scroll code
    5456  * [I] SHORT : current scroll position if scroll code is SB_THIMBPOSITION 
     5458 * [I] SHORT : current scroll position if scroll code is SB_THIMBPOSITION
    54575459 *             or SB_THUMBTRACK.
    54585460 * [I] HWND : scrollbar control window handle
     
    54705472  scrollInfo.cbSize = sizeof(SCROLLINFO);
    54715473  scrollInfo.fMask = /*SIF_PAGE |*/ SIF_POS | SIF_RANGE;
    5472  
     5474
    54735475  if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE)
    54745476  {
     
    54835485      }
    54845486      break;
    5485    
     5487
    54865488    case SB_LINERIGHT:
    54875489      if (scrollInfo.nPos < scrollInfo.nMax)
     
    54905492      }
    54915493      break;
    5492      
     5494
    54935495    case SB_PAGELEFT:
    54945496      if (scrollInfo.nPos > scrollInfo.nMin)
     
    55045506          nPage = 10;
    55055507        }
    5506        
     5508
    55075509        if (scrollInfo.nPos >= nPage)
    55085510        {
     
    55155517      }
    55165518      break;
    5517      
     5519
    55185520    case SB_PAGERIGHT:
    55195521      if (scrollInfo.nPos < scrollInfo.nMax)
     
    55295531          nPage = 10;
    55305532        }
    5531        
     5533
    55325534        if (scrollInfo.nPos <= scrollInfo.nMax - nPage)
    55335535        {
     
    55525554    }
    55535555  }
    5554    
     5556
    55555557  return 0;
    55565558}
     
    55585560/***
    55595561 * DESCRIPTION:
    5560  * ??? 
    5561  * 
    5562  * PARAMETER(S):
    5563  * [I] HWND : window handle
    5564  * [I] INT : virtual key 
     5562 * ???
     5563 *
     5564 * PARAMETER(S):
     5565 * [I] HWND : window handle
     5566 * [I] INT : virtual key
    55655567 * [I] LONG : key data
    55665568 *
     
    55735575  INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
    55745576  HWND hwndParent = GetParent(hwnd);
    5575   NMLVKEYDOWN nmKeyDown; 
     5577  NMLVKEYDOWN nmKeyDown;
    55765578  NMHDR nmh;
    55775579  INT nItem = -1;
     
    55805582  /* send LVN_KEYDOWN notification */
    55815583  ZeroMemory(&nmKeyDown, sizeof(NMLVKEYDOWN));
    5582   nmKeyDown.hdr.hwndFrom = hwnd; 
    5583   nmKeyDown.hdr.idFrom = nCtrlId; 
    5584   nmKeyDown.hdr.code = LVN_KEYDOWN; 
    5585   nmKeyDown.wVKey = nVirtualKey; 
    5586   nmKeyDown.flags = 0; 
    5587   SendMessageA(hwndParent, WM_NOTIFY, (WPARAM)nCtrlId, (LPARAM)&nmKeyDown); 
    5588  
     5584  nmKeyDown.hdr.hwndFrom = hwnd;
     5585  nmKeyDown.hdr.idFrom = nCtrlId;
     5586  nmKeyDown.hdr.code = LVN_KEYDOWN;
     5587  nmKeyDown.wVKey = nVirtualKey;
     5588  nmKeyDown.flags = 0;
     5589  SendMessageA(hwndParent, WM_NOTIFY, (WPARAM)nCtrlId, (LPARAM)&nmKeyDown);
     5590
    55895591  /* initialize */
    55905592  nmh.hwndFrom = hwnd;
     
    55995601      nmh.code = NM_RETURN;
    56005602      ListView_Notify(hwndParent, nCtrlId, &nmh);
    5601      
     5603
    56025604      /* send LVN_ITEMACTIVATE notification */
    56035605      nmh.code = LVN_ITEMACTIVATE;
     
    56275629    nItem = LISTVIEW_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_ABOVE);
    56285630    break;
    5629    
     5631
    56305632  case VK_RIGHT:
    56315633    nItem = LISTVIEW_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_TORIGHT);
     
    56625664 * DESCRIPTION:
    56635665 * Kills the focus.
    5664  * 
     5666 *
    56655667 * PARAMETER(S):
    56665668 * [I] HWND : window handle
     
    56935695 * DESCRIPTION:
    56945696 * Processes double click messages (left mouse button).
    5695  * 
     5697 *
    56965698 * PARAMETER(S):
    56975699 * [I] HWND : window handle
     
    57035705 * Zero
    57045706 */
    5705 static LRESULT LISTVIEW_LButtonDblClk(HWND hwnd, WORD wKey, WORD wPosX, 
     5707static LRESULT LISTVIEW_LButtonDblClk(HWND hwnd, WORD wKey, WORD wPosX,
    57065708                                      WORD wPosY)
    57075709{
     
    57275729 * DESCRIPTION:
    57285730 * Processes mouse down messages (left mouse button).
    5729  * 
     5731 *
    57305732 * PARAMETER(S):
    57315733 * [I] HWND : window handle
     
    57375739 * Zero
    57385740 */
    5739 static LRESULT LISTVIEW_LButtonDown(HWND hwnd, WORD wKey, WORD wPosX, 
     5741static LRESULT LISTVIEW_LButtonDown(HWND hwnd, WORD wKey, WORD wPosX,
    57405742                                    WORD wPosY)
    57415743{
     
    57485750  INT nItem;
    57495751
    5750   TRACE("(hwnd=%x, key=%hu, X=%hu, Y=%hu)\n", hwnd, wKey, wPosX, 
     5752  TRACE("(hwnd=%x, key=%hu, X=%hu, Y=%hu)\n", hwnd, wKey, wPosX,
    57515753        wPosY);
    57525754
    5753   /* send NM_RELEASEDCAPTURE notification */ 
     5755  /* send NM_RELEASEDCAPTURE notification */
    57545756  nmh.hwndFrom = hwnd;
    57555757  nmh.idFrom = nCtrlId;
    57565758  nmh.code = NM_RELEASEDCAPTURE;
    57575759  ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
    5758  
     5760
    57595761  if (infoPtr->bFocus == FALSE)
    57605762  {
     
    57645766  /* set left button down flag */
    57655767  infoPtr->bLButtonDown = TRUE;
    5766  
     5768
    57675769  ptPosition.x = wPosX;
    57685770  ptPosition.y = wPosY;
     
    58155817 * DESCRIPTION:
    58165818 * Processes mouse up messages (left mouse button).
    5817  * 
     5819 *
    58185820 * PARAMETER(S):
    58195821 * [I] HWND : window handle
     
    58255827 * Zero
    58265828 */
    5827 static LRESULT LISTVIEW_LButtonUp(HWND hwnd, WORD wKey, WORD wPosX, 
     5829static LRESULT LISTVIEW_LButtonUp(HWND hwnd, WORD wKey, WORD wPosX,
    58285830                                  WORD wPosY)
    58295831{
     
    58325834  TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY);
    58335835
    5834   if (infoPtr->bLButtonDown != FALSE) 
     5836  if (infoPtr->bLButtonDown != FALSE)
    58355837  {
    58365838    INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
     
    58535855 * DESCRIPTION:
    58545856 * Creates the listview control (called before WM_CREATE).
    5855  * 
    5856  * PARAMETER(S):
    5857  * [I] HWND : window handle
    5858  * [I] WPARAM : unhandled 
     5857 *
     5858 * PARAMETER(S):
     5859 * [I] HWND : window handle
     5860 * [I] WPARAM : unhandled
    58595861 * [I] LPARAM : widow creation info
    5860  * 
     5862 *
    58615863 * RETURN:
    58625864 * Zero
     
    58665868  LISTVIEW_INFO *infoPtr;
    58675869
    5868   TRACE("(hwnd=%x,wParam=%x,lParam=%lx)\n", hwnd, wParam, lParam);
     5870  //TRACE("(hwnd=%x,wParam=%x,lParam=%lx)\n", hwnd, wParam, lParam);
    58695871
    58705872  /* allocate memory for info structure */
    58715873  infoPtr = (LISTVIEW_INFO *)COMCTL32_Alloc(sizeof(LISTVIEW_INFO));
    5872   SetWindowLongA(hwnd, 0, (LONG)infoPtr);
    5873   if (infoPtr == NULL) 
    5874   {
    5875     ERR("could not allocate info memory!\n");
     5874  SetWindowLongA(hwnd,0,(DWORD)infoPtr);
     5875  if (infoPtr == NULL)
     5876  {
     5877    //ERR("could not allocate info memory!\n");
    58765878    return 0;
    58775879  }
    58785880
    5879   if ((LISTVIEW_INFO *)GetWindowLongA(hwnd, 0) != infoPtr) 
    5880   {
    5881     ERR("pointer assignment error!\n");
     5881  if ((LISTVIEW_INFO *)GetWindowLongA(hwnd, 0) != infoPtr)
     5882  {
     5883    //ERR("pointer assignment error!\n");
    58825884    return 0;
    58835885  }
    58845886
    5885   return DefWindowProcA(hwnd, WM_NCCREATE, wParam, lParam);
     5887  return DefWindowProcA(hwnd,WM_NCCREATE,wParam,lParam);
    58865888}
    58875889
     
    58895891 * DESCRIPTION:
    58905892 * Destroys the listview control (called after WM_DESTROY).
    5891  * 
    5892  * PARAMETER(S):
    5893  * [I] HWND : window handle
    5894  * 
     5893 *
     5894 * PARAMETER(S):
     5895 * [I] HWND : window handle
     5896 *
    58955897 * RETURN:
    58965898 * Zero
     
    59005902  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    59015903
    5902   TRACE("(hwnd=%x)\n", hwnd);
     5904  //TRACE("(hwnd=%x)\n", hwnd);
    59035905
    59045906  /* delete all items */
     
    59245926 * DESCRIPTION:
    59255927 * Handles notifications from children.
    5926  * 
     5928 *
    59275929 * PARAMETER(S):
    59285930 * [I] HWND : window handle
    59295931 * [I] INT : control identifier
    59305932 * [I] LPNMHDR : notification information
    5931  * 
     5933 *
    59325934 * RETURN:
    59335935 * Zero
     
    59365938{
    59375939  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    5938  
    5939   if (lpnmh->hwndFrom == infoPtr->hwndHeader) 
     5940
     5941  if (lpnmh->hwndFrom == infoPtr->hwndHeader)
    59405942  {
    59415943    /* handle notification from header control */
     
    59535955 * DESCRIPTION:
    59545956 * Determines the type of structure to use.
    5955  * 
     5957 *
    59565958 * PARAMETER(S):
    59575959 * [I] HWND : window handle of the sender
    5958  * [I] HWND : listview window handle 
     5960 * [I] HWND : listview window handle
    59595961 * [I] INT : command specifying the nature of the WM_NOTIFYFORMAT
    59605962 *
     
    59695971  {
    59705972    /* determine the type of structure to use */
    5971     infoPtr->notifyFormat = SendMessageA(hwndFrom, WM_NOTIFYFORMAT, 
     5973    infoPtr->notifyFormat = SendMessageA(hwndFrom, WM_NOTIFYFORMAT,
    59725974                                         (WPARAM)hwnd, (LPARAM)NF_QUERY);
    59735975    if (infoPtr->notifyFormat == NFR_UNICODE)
     
    59835985 * DESCRIPTION:
    59845986 * Paints/Repaints the listview control.
    5985  * 
     5987 *
    59865988 * PARAMETER(S):
    59875989 * [I] HWND : window handle
     
    60146016 * DESCRIPTION:
    60156017 * Processes double click messages (right mouse button).
    6016  * 
     6018 *
    60176019 * PARAMETER(S):
    60186020 * [I] HWND : window handle
     
    60246026 * Zero
    60256027 */
    6026 static LRESULT LISTVIEW_RButtonDblClk(HWND hwnd, WORD wKey, WORD wPosX, 
     6028static LRESULT LISTVIEW_RButtonDblClk(HWND hwnd, WORD wKey, WORD wPosX,
    60276029                                      WORD wPosY)
    60286030{
    60296031  INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
    60306032  NMHDR nmh;
    6031 
    6032   TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY);
    6033 
    6034   /* send NM_RELEASEDCAPTURE notification */
    6035   nmh.hwndFrom = hwnd;
    6036   nmh.idFrom = nCtrlId;
    6037   nmh.code = NM_RELEASEDCAPTURE;
    6038   ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
    6039 
    6040   /* send NM_RDBLCLK notification */
    6041   nmh.code = NM_RDBLCLK;
    6042   ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
    6043 
    6044   return 0;
    6045 }
    6046 
    6047 /***
    6048  * DESCRIPTION:
    6049  * Processes mouse down messages (right mouse button).
    6050  *
    6051  * PARAMETER(S):
    6052  * [I] HWND : window handle
    6053  * [I] WORD : key flag
    6054  * [I] WORD : x coordinate
    6055  * [I] WORD : y coordinate
    6056  *
    6057  * RETURN:
    6058  * Zero
    6059  */
    6060 static LRESULT LISTVIEW_RButtonDown(HWND hwnd, WORD wKey, WORD wPosX,
    6061                                     WORD wPosY)
    6062 {
    6063   LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    6064   INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
    6065   POINT ptPosition;
    6066   NMHDR nmh;
    6067   INT nItem;
    60686033
    60696034  TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY);
     
    60746039  nmh.code = NM_RELEASEDCAPTURE;
    60756040  ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
    6076  
     6041
     6042  /* send NM_RDBLCLK notification */
     6043  nmh.code = NM_RDBLCLK;
     6044  ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
     6045
     6046  return 0;
     6047}
     6048
     6049/***
     6050 * DESCRIPTION:
     6051 * Processes mouse down messages (right mouse button).
     6052 *
     6053 * PARAMETER(S):
     6054 * [I] HWND : window handle
     6055 * [I] WORD : key flag
     6056 * [I] WORD : x coordinate
     6057 * [I] WORD : y coordinate
     6058 *
     6059 * RETURN:
     6060 * Zero
     6061 */
     6062static LRESULT LISTVIEW_RButtonDown(HWND hwnd, WORD wKey, WORD wPosX,
     6063                                    WORD wPosY)
     6064{
     6065  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
     6066  INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
     6067  POINT ptPosition;
     6068  NMHDR nmh;
     6069  INT nItem;
     6070
     6071  TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY);
     6072
     6073  /* send NM_RELEASEDCAPTURE notification */
     6074  nmh.hwndFrom = hwnd;
     6075  nmh.idFrom = nCtrlId;
     6076  nmh.code = NM_RELEASEDCAPTURE;
     6077  ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
     6078
    60776079  /* make sure the listview control window has the focus */
    60786080  if (infoPtr->bFocus == FALSE)
     
    60996101    LISTVIEW_RemoveSelections(hwnd, 0, GETITEMCOUNT(infoPtr));
    61006102  }
    6101  
     6103
    61026104  return 0;
    61036105}
     
    61066108 * DESCRIPTION:
    61076109 * Processes mouse up messages (right mouse button).
    6108  * 
     6110 *
    61096111 * PARAMETER(S):
    61106112 * [I] HWND : window handle
     
    61166118 * Zero
    61176119 */
    6118 static LRESULT LISTVIEW_RButtonUp(HWND hwnd, WORD wKey, WORD wPosX, 
     6120static LRESULT LISTVIEW_RButtonUp(HWND hwnd, WORD wKey, WORD wPosX,
    61196121                                  WORD wPosY)
    61206122{
     
    61256127  TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY);
    61266128
    6127   if (infoPtr->bRButtonDown != FALSE) 
     6129  if (infoPtr->bRButtonDown != FALSE)
    61286130  {
    61296131    /* send NM_RClICK notification */
     
    61376139    infoPtr->bRButtonDown = FALSE;
    61386140  }
    6139  
     6141
    61406142  return 0;
    61416143}
     
    61436145/***
    61446146 * DESCRIPTION:
    6145  * Sets the focus. 
    6146  * 
     6147 * Sets the focus.
     6148 *
    61476149 * PARAMETER(S):
    61486150 * [I] HWND : window handle
     
    61726174/***
    61736175 * DESCRIPTION:
    6174  * Sets the font. 
    6175  * 
     6176 * Sets the font.
     6177 *
    61766178 * PARAMETER(S):
    61776179 * [I] HWND : window handle
     
    62016203  {
    62026204    /* set header font */
    6203     SendMessageA(infoPtr->hwndHeader, WM_SETFONT, (WPARAM)hFont, 
     6205    SendMessageA(infoPtr->hwndHeader, WM_SETFONT, (WPARAM)hFont,
    62046206                   MAKELPARAM(fRedraw, 0));
    62056207  }
     
    62076209  /* invalidate listview control client area */
    62086210  InvalidateRect(hwnd, NULL, TRUE);
    6209  
     6211
    62106212  if (fRedraw != FALSE)
    62116213  {
     
    62206222 * Resizes the listview control. This function processes WM_SIZE
    62216223 * messages.  At this time, the width and height are not used.
    6222  * 
     6224 *
    62236225 * PARAMETER(S):
    62246226 * [I] HWND : window handle
     
    62316233static LRESULT LISTVIEW_Size(HWND hwnd, int Width, int Height)
    62326234{
    6233   LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 
     6235  LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
    62346236  UINT uView = lStyle & LVS_TYPEMASK;
    62356237
     
    62516253
    62526254  LISTVIEW_UpdateScroll(hwnd);
    6253  
     6255
    62546256  /* invalidate client area + erase background */
    62556257  InvalidateRect(hwnd, NULL, TRUE);
     
    62616263 * DESCRIPTION:
    62626264 * Sets the size information.
    6263  * 
     6265 *
    62646266 * PARAMETER(S):
    62656267 * [I] HWND : window handle
     
    62746276  UINT uView = lStyle & LVS_TYPEMASK;
    62756277  RECT rcList;
    6276  
     6278
    62776279  GetClientRect(hwnd, &rcList);
    62786280  infoPtr->rcList.left = 0;
     
    62806282  infoPtr->rcList.top = 0;
    62816283  infoPtr->rcList.bottom = max(rcList.bottom - rcList.top, 1);
    6282      
     6284
    62836285  if (uView == LVS_LIST)
    62846286  {
     
    62876289      INT nHScrollHeight = GetSystemMetrics(SM_CYHSCROLL);
    62886290      if (infoPtr->rcList.bottom > nHScrollHeight)
    6289       { 
     6291      {
    62906292        infoPtr->rcList.bottom -= nHScrollHeight;
    62916293      }
     
    63096311/***
    63106312 * DESCRIPTION:
    6311  * Processes WM_STYLECHANGED messages. 
    6312  * 
     6313 * Processes WM_STYLECHANGED messages.
     6314 *
    63136315 * PARAMETER(S):
    63146316 * [I] HWND : window handle
     
    63196321 * Zero
    63206322 */
    6321 static INT LISTVIEW_StyleChanged(HWND hwnd, WPARAM wStyleType, 
     6323static INT LISTVIEW_StyleChanged(HWND hwnd, WPARAM wStyleType,
    63226324                                 LPSTYLESTRUCT lpss)
    63236325{
     
    63276329  RECT rcList = infoPtr->rcList;
    63286330
    6329   TRACE("(hwnd=%x, styletype=%x, stylestruct=%p)\n", 
     6331  TRACE("(hwnd=%x, styletype=%x, stylestruct=%p)\n",
    63306332        hwnd, wStyleType, lpss);
    63316333
     
    63366338      ShowWindow(infoPtr->hwndHeader, SW_HIDE);
    63376339    }
    6338  
     6340
    63396341    if ((lpss->styleOld & WS_HSCROLL) != 0)
    63406342    {
    63416343       ShowScrollBar(hwnd, SB_HORZ, FALSE);
    63426344    }
    6343  
     6345
    63446346    if ((lpss->styleOld & WS_VSCROLL) != 0)
    63456347    {
    63466348       ShowScrollBar(hwnd, SB_VERT, FALSE);
    63476349    }
    6348  
     6350
    63496351    if (uNewView == LVS_ICON)
    63506352    {
     
    63706372      hl.pwpos = &wp;
    63716373      Header_Layout(infoPtr->hwndHeader, &hl);
    6372       SetWindowPos(infoPtr->hwndHeader, hwnd, wp.x, wp.y, wp.cx, wp.cy, 
     6374      SetWindowPos(infoPtr->hwndHeader, hwnd, wp.x, wp.y, wp.cx, wp.cy,
    63736375                   wp.flags);
    63746376      if (!(LVS_NOCOLUMNHEADER & lpss->styleNew))
     
    64096411    /* add scrollbars if needed */
    64106412    LISTVIEW_UpdateScroll(hwnd);
    6411    
     6413
    64126414    /* invalidate client area + erase background */
    64136415    InvalidateRect(hwnd, NULL, TRUE);
     
    64306432  switch (uMsg)
    64316433  {
    6432   case LVM_APPROXIMATEVIEWRECT: 
    6433     return LISTVIEW_ApproximateViewRect(hwnd, (INT)wParam, 
     6434  case LVM_APPROXIMATEVIEWRECT:
     6435    return LISTVIEW_ApproximateViewRect(hwnd, (INT)wParam,
    64346436                                        LOWORD(lParam), HIWORD(lParam));
    6435   case LVM_ARRANGE: 
     6437  case LVM_ARRANGE:
    64366438    return LISTVIEW_Arrange(hwnd, (INT)wParam);
    64376439
     
    64476449    return LISTVIEW_DeleteItem(hwnd, (INT)wParam);
    64486450
    6449 /*      case LVM_EDITLABEL: */
     6451/*      case LVM_EDITLABEL: */
    64506452
    64516453  case LVM_ENSUREVISIBLE:
     
    64586460    return LISTVIEW_GetBkColor(hwnd);
    64596461
    6460 /*      case LVM_GETBKIMAGE: */
     6462/*      case LVM_GETBKIMAGE: */
    64616463
    64626464  case LVM_GETCALLBACKMASK:
     
    64666468    return LISTVIEW_GetColumnA(hwnd, (INT)wParam, (LPLVCOLUMNA)lParam);
    64676469
    6468 /*      case LVM_GETCOLUMNW: */
    6469 /*      case LVM_GETCOLUMNORDERARRAY: */
     6470/*      case LVM_GETCOLUMNW: */
     6471/*      case LVM_GETCOLUMNORDERARRAY: */
    64706472
    64716473  case LVM_GETCOLUMNWIDTH:
     
    64756477    return LISTVIEW_GetCountPerPage(hwnd);
    64766478
    6477 /*      case LVM_GETEDITCONTROL: */
    6478 /*      case LVM_GETEXTENDEDLISTVIEWSTYLE: */
     6479/*      case LVM_GETEDITCONTROL: */
     6480/*      case LVM_GETEXTENDEDLISTVIEWSTYLE: */
    64796481
    64806482  case LVM_GETHEADER:
    64816483    return LISTVIEW_GetHeader(hwnd);
    64826484
    6483 /*      case LVM_GETHOTCURSOR: */
    6484 /*      case LVM_GETHOTITEM: */
    6485 /*      case LVM_GETHOVERTIME: */
     6485/*      case LVM_GETHOTCURSOR: */
     6486/*      case LVM_GETHOTITEM: */
     6487/*      case LVM_GETHOVERTIME: */
    64866488
    64876489  case LVM_GETIMAGELIST:
    64886490    return LISTVIEW_GetImageList(hwnd, (INT)wParam);
    64896491
    6490 /*      case LVM_GETISEARCHSTRING: */
     6492/*      case LVM_GETISEARCHSTRING: */
    64916493
    64926494  case LVM_GETITEMA:
    64936495    return LISTVIEW_GetItemA(hwnd, (LPLVITEMA)lParam);
    64946496
    6495 /*      case LVM_GETITEMW: */
     6497/*      case LVM_GETITEMW: */
    64966498
    64976499  case LVM_GETITEMCOUNT:
     
    65016503    return LISTVIEW_GetItemPosition(hwnd, (INT)wParam, (LPPOINT)lParam);
    65026504
    6503   case LVM_GETITEMRECT: 
     6505  case LVM_GETITEMRECT:
    65046506    return LISTVIEW_GetItemRect(hwnd, (INT)wParam, (LPRECT)lParam);
    65056507
    6506   case LVM_GETITEMSPACING: 
     6508  case LVM_GETITEMSPACING:
    65076509    return LISTVIEW_GetItemSpacing(hwnd, (BOOL)wParam);
    65086510
    6509   case LVM_GETITEMSTATE: 
     6511  case LVM_GETITEMSTATE:
    65106512    return LISTVIEW_GetItemState(hwnd, (INT)wParam, (UINT)lParam);
    6511    
     6513
    65126514  case LVM_GETITEMTEXTA:
    65136515    LISTVIEW_GetItemTextA(hwnd, (INT)wParam, (LPLVITEMA)lParam);
    65146516    break;
    65156517
    6516 /*      case LVM_GETITEMTEXTW: */
     6518/*      case LVM_GETITEMTEXTW: */
    65176519
    65186520  case LVM_GETNEXTITEM:
    65196521    return LISTVIEW_GetNextItem(hwnd, (INT)wParam, LOWORD(lParam));
    65206522
    6521 /*      case LVM_GETNUMBEROFWORKAREAS: */
     6523/*      case LVM_GETNUMBEROFWORKAREAS: */
    65226524
    65236525  case LVM_GETORIGIN:
     
    65276529    return LISTVIEW_GetSelectedCount(hwnd);
    65286530
    6529   case LVM_GETSELECTIONMARK: 
     6531  case LVM_GETSELECTIONMARK:
    65306532    return LISTVIEW_GetSelectionMark(hwnd);
    65316533
     
    65336535    return LISTVIEW_GetStringWidthA (hwnd, (LPCSTR)lParam);
    65346536
    6535 /*      case LVM_GETSTRINGWIDTHW: */
    6536 /*      case LVM_GETSUBITEMRECT: */
     6537/*      case LVM_GETSTRINGWIDTHW: */
     6538/*      case LVM_GETSUBITEMRECT: */
    65376539
    65386540  case LVM_GETTEXTBKCOLOR:
     
    65426544    return LISTVIEW_GetTextColor(hwnd);
    65436545
    6544 /*      case LVM_GETTOOLTIPS: */
     6546/*      case LVM_GETTOOLTIPS: */
    65456547
    65466548  case LVM_GETTOPINDEX:
    65476549    return LISTVIEW_GetTopIndex(hwnd);
    65486550
    6549 /*      case LVM_GETUNICODEFORMAT: */
     6551/*      case LVM_GETUNICODEFORMAT: */
    65506552
    65516553  case LVM_GETVIEWRECT:
    65526554    return LISTVIEW_GetViewRect(hwnd, (LPRECT)lParam);
    65536555
    6554 /*      case LVM_GETWORKAREAS: */
     6556/*      case LVM_GETWORKAREAS: */
    65556557
    65566558  case LVM_HITTEST:
     
    65586560
    65596561  case LVM_INSERTCOLUMNA:
    6560     return LISTVIEW_InsertColumnA(hwnd, (INT)wParam, 
     6562    return LISTVIEW_InsertColumnA(hwnd, (INT)wParam,
    65616563                                    (LPLVCOLUMNA)lParam);
    65626564
    6563 /*      case LVM_INSERTCOLUMNW: */
     6565/*      case LVM_INSERTCOLUMNW: */
    65646566
    65656567  case LVM_INSERTITEMA:
    65666568    return LISTVIEW_InsertItemA(hwnd, (LPLVITEMA)lParam);
    65676569
    6568 /*      case LVM_INSERTITEMW: */
     6570/*      case LVM_INSERTITEMW: */
    65696571
    65706572  case LVM_REDRAWITEMS:
     
    65776579    return LISTVIEW_SetBkColor(hwnd, (COLORREF)lParam);
    65786580
    6579 /*      case LVM_SETBKIMAGE: */
     6581/*      case LVM_SETBKIMAGE: */
    65806582
    65816583  case LVM_SETCALLBACKMASK:
     
    65856587    return LISTVIEW_SetColumnA(hwnd, (INT)wParam, (LPLVCOLUMNA)lParam);
    65866588
    6587 /*      case LVM_SETCOLUMNW: */
    6588 /*      case LVM_SETCOLUMNORDERARRAY: */
     6589/*      case LVM_SETCOLUMNW: */
     6590/*      case LVM_SETCOLUMNORDERARRAY: */
    65896591
    65906592  case LVM_SETCOLUMNWIDTH:
    65916593    return LISTVIEW_SetColumnWidth(hwnd, (INT)wParam, (INT)lParam);
    65926594
    6593 /*      case LVM_SETEXTENDEDLISTVIEWSTYLE: */
    6594 /*      case LVM_SETHOTCURSOR: */
    6595 /*      case LVM_SETHOTITEM: */
    6596 /*      case LVM_SETHOVERTIME: */
    6597 /*      case LVM_SETICONSPACING: */
    6598        
     6595/*      case LVM_SETEXTENDEDLISTVIEWSTYLE: */
     6596/*      case LVM_SETHOTCURSOR: */
     6597/*      case LVM_SETHOTITEM: */
     6598/*      case LVM_SETHOVERTIME: */
     6599/*      case LVM_SETICONSPACING: */
     6600
    65996601  case LVM_SETIMAGELIST:
    66006602    return LISTVIEW_SetImageList(hwnd, (INT)wParam, (HIMAGELIST)lParam);
     
    66036605    return LISTVIEW_SetItemA(hwnd, (LPLVITEMA)lParam);
    66046606
    6605 /*      case LVM_SETITEMW: */
    6606 
    6607   case LVM_SETITEMCOUNT: 
     6607/*      case LVM_SETITEMW: */
     6608
     6609  case LVM_SETITEMCOUNT:
    66086610    LISTVIEW_SetItemCount(hwnd, (INT)wParam);
    66096611    break;
    6610    
     6612
    66116613  case LVM_SETITEMPOSITION:
    66126614    return LISTVIEW_SetItemPosition(hwnd, (INT)wParam, (INT)LOWORD(lParam),
    66136615                                    (INT)HIWORD(lParam));
    66146616
    6615 /*      case LVM_SETITEMPOSITION: */
    6616 
    6617   case LVM_SETITEMSTATE: 
     6617/*      case LVM_SETITEMPOSITION: */
     6618
     6619  case LVM_SETITEMSTATE:
    66186620    return LISTVIEW_SetItemState(hwnd, (INT)wParam, (LPLVITEMA)lParam);
    66196621
     
    66216623    return LISTVIEW_SetItemTextA(hwnd, (INT)wParam, (LPLVITEMA)lParam);
    66226624
    6623 /*      case LVM_SETSELECTIONMARK: */
     6625/*      case LVM_SETSELECTIONMARK: */
    66246626
    66256627  case LVM_SETTEXTBKCOLOR:
     
    66296631    return LISTVIEW_SetTextColor(hwnd, (COLORREF)lParam);
    66306632
    6631 /*      case LVM_SETTOOLTIPS: */
    6632 /*      case LVM_SETUNICODEFORMAT: */
    6633 /*      case LVM_SETWORKAREAS: */
     6633/*      case LVM_SETTOOLTIPS: */
     6634/*      case LVM_SETUNICODEFORMAT: */
     6635/*      case LVM_SETWORKAREAS: */
    66346636
    66356637  case LVM_SORTITEMS:
    66366638    return LISTVIEW_SortItems(hwnd, wParam, lParam);
    66376639
    6638 /*      case LVM_SUBITEMHITTEST: */
    6639 
    6640   case LVM_UPDATE: 
     6640/*      case LVM_SUBITEMHITTEST: */
     6641
     6642  case LVM_UPDATE:
    66416643    return LISTVIEW_Update(hwnd, (INT)wParam);
    66426644
    6643 /*      case WM_CHAR: */
    6644 /*      case WM_COMMAND: */
     6645/*      case WM_CHAR: */
     6646/*      case WM_COMMAND: */
    66456647
    66466648  case WM_CREATE:
    66476649    return LISTVIEW_Create(hwnd, wParam, lParam);
    6648    
     6650
    66496651  case WM_ERASEBKGND:
    66506652    return LISTVIEW_EraseBackground(hwnd, wParam, lParam);
     
    66576659
    66586660  case WM_HSCROLL:
    6659     return LISTVIEW_HScroll(hwnd, (INT)LOWORD(wParam), 
     6661    return LISTVIEW_HScroll(hwnd, (INT)LOWORD(wParam),
    66606662                            (INT)HIWORD(wParam), (HWND)lParam);
    66616663
     
    66676669
    66686670  case WM_LBUTTONDBLCLK:
    6669     return LISTVIEW_LButtonDblClk(hwnd, (WORD)wParam, LOWORD(lParam), 
     6671    return LISTVIEW_LButtonDblClk(hwnd, (WORD)wParam, LOWORD(lParam),
    66706672                                HIWORD(lParam));
    6671    
     6673
    66726674  case WM_LBUTTONDOWN:
    6673     return LISTVIEW_LButtonDown(hwnd, (WORD)wParam, LOWORD(lParam), 
     6675    return LISTVIEW_LButtonDown(hwnd, (WORD)wParam, LOWORD(lParam),
    66746676                                HIWORD(lParam));
    66756677  case WM_LBUTTONUP:
    6676     return LISTVIEW_LButtonUp(hwnd, (WORD)wParam, LOWORD(lParam), 
     6678    return LISTVIEW_LButtonUp(hwnd, (WORD)wParam, LOWORD(lParam),
    66776679                              HIWORD(lParam));
    6678    
    6679 /*      case WM_MOUSEMOVE: */
    6680 /*          return LISTVIEW_MouseMove (hwnd, wParam, lParam); */
     6680
     6681/*      case WM_MOUSEMOVE: */
     6682/*          return LISTVIEW_MouseMove (hwnd, wParam, lParam); */
    66816683
    66826684  case WM_NCCREATE:
     
    66926694    return LISTVIEW_NotifyFormat(hwnd, (HWND)wParam, (INT)lParam);
    66936695
    6694   case WM_PAINT: 
    6695     return LISTVIEW_Paint(hwnd, (HDC)wParam); 
     6696  case WM_PAINT:
     6697    return LISTVIEW_Paint(hwnd, (HDC)wParam);
    66966698
    66976699  case WM_RBUTTONDBLCLK:
    6698     return LISTVIEW_RButtonDblClk(hwnd, (WORD)wParam, LOWORD(lParam), 
     6700    return LISTVIEW_RButtonDblClk(hwnd, (WORD)wParam, LOWORD(lParam),
    66996701                                  HIWORD(lParam));
    67006702
    67016703  case WM_RBUTTONDOWN:
    6702     return LISTVIEW_RButtonDown(hwnd, (WORD)wParam, LOWORD(lParam), 
     6704    return LISTVIEW_RButtonDown(hwnd, (WORD)wParam, LOWORD(lParam),
    67036705                                HIWORD(lParam));
    67046706
    67056707  case WM_RBUTTONUP:
    6706     return LISTVIEW_RButtonUp(hwnd, (WORD)wParam, LOWORD(lParam), 
     6708    return LISTVIEW_RButtonUp(hwnd, (WORD)wParam, LOWORD(lParam),
    67076709                              HIWORD(lParam));
    67086710
     
    67136715    return LISTVIEW_SetFont(hwnd, (HFONT)wParam, (WORD)lParam);
    67146716
    6715 /*      case WM_SETREDRAW: */
     6717/*      case WM_SETREDRAW: */
    67166718
    67176719  case WM_SIZE:
     
    67216723    return LISTVIEW_StyleChanged(hwnd, wParam, (LPSTYLESTRUCT)lParam);
    67226724
    6723 /*      case WM_TIMER: */
     6725/*      case WM_TIMER: */
    67246726
    67256727  case WM_VSCROLL:
    6726     return LISTVIEW_VScroll(hwnd, (INT)LOWORD(wParam), 
     6728    return LISTVIEW_VScroll(hwnd, (INT)LOWORD(wParam),
    67276729                            (INT)HIWORD(wParam), (HWND)lParam);
    67286730
    6729 /*      case WM_WINDOWPOSCHANGED: */
    6730 /*      case WM_WININICHANGE: */
     6731/*      case WM_WINDOWPOSCHANGED: */
     6732/*      case WM_WININICHANGE: */
    67316733
    67326734  default:
    6733     if (uMsg >= WM_USER)
    6734     {
    6735       ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam,
    6736           lParam);
    6737     }
     6735    //if (uMsg >= WM_USER)
     6736    //{
     6737    //  ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam,
     6738    //      lParam);
     6739    //}
    67386740
    67396741    /* call default window procedure */
     
    67476749 * DESCRIPTION:
    67486750 * Registers the window class.
    6749  * 
     6751 *
    67506752 * PARAMETER(S):
    67516753 * None
     
    67586760  WNDCLASSA wndClass;
    67596761
    6760   if (!GlobalFindAtomA(WC_LISTVIEWA)) 
     6762  if (!GlobalFindAtomA(WC_LISTVIEWA))
    67616763  {
    67626764    ZeroMemory(&wndClass, sizeof(WNDCLASSA));
     
    67756777 * DESCRIPTION:
    67766778 * Unregisters the window class.
    6777  * 
     6779 *
    67786780 * PARAMETER(S):
    67796781 * None
  • trunk/src/comctl32/progress.c

    r219 r236  
    1 /* $Id: progress.c,v 1.6 1999-06-26 14:20:31 cbratschi Exp $ */
     1/* $Id: progress.c,v 1.7 1999-06-28 15:46:25 cbratschi Exp $ */
    22/*
    33 * Progress control
     
    284284
    285285
     286static LRESULT PROGRESS_NCCreate(HWND hwnd,WPARAM wParam,LPARAM lParam)
     287{
     288  DWORD dwExStyle;
     289
     290  dwExStyle = GetWindowLongA(hwnd,GWL_EXSTYLE);
     291  SetWindowLongA(hwnd,GWL_EXSTYLE,dwExStyle | WS_EX_STATICEDGE);
     292
     293  return TRUE;
     294}
     295
     296static LRESULT PROGRESS_Create(HWND hwnd,WPARAM wParam,LPARAM lParam)
     297{
     298  PROGRESS_INFO *infoPtr;
     299
     300  /* allocate memory for info struct */
     301  infoPtr = (PROGRESS_INFO *)COMCTL32_Alloc(sizeof(PROGRESS_INFO));
     302  SetWindowLongA(hwnd,0,(DWORD)infoPtr);
     303
     304  /* initialize the info struct */
     305  infoPtr->MinVal = 0;
     306  infoPtr->MaxVal = 100;
     307  infoPtr->CurVal = 0;
     308  infoPtr->Step = 10;
     309  infoPtr->ColorBar = CLR_DEFAULT;
     310  infoPtr->ColorBk = CLR_DEFAULT;
     311  infoPtr->hFont = (HANDLE)NULL;
     312//      TRACE(progress, "Progress Ctrl creation, hwnd=%04x\n", hwnd);
     313
     314  return 0;
     315}
     316
     317static LRESULT PROGRESS_Destroy(HWND hwnd,WPARAM wParam,LPARAM lParam)
     318{
     319  PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
     320
     321  //      TRACE (progress, "Progress Ctrl destruction, hwnd=%04x\n", hwnd);
     322  COMCTL32_Free (infoPtr);
     323
     324  return 0;
     325}
     326
     327static LRESULT PROGRESS_GetFont(HWND hwnd,WPARAM wParam,LPARAM lParam)
     328{
     329  PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
     330
     331  return (LRESULT)infoPtr->hFont;
     332}
     333
    286334/***********************************************************************
    287335 *           PROGRESS_SetFont
    288336 * Set new Font for progress bar
    289337 */
    290 static HFONT
    291 PROGRESS_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
    292 {
    293     PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
     338static HFONT PROGRESS_SetFont (HWND hwnd,WPARAM wParam,LPARAM lParam)
     339{
     340  PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
    294341  HFONT hOldFont = infoPtr->hFont;
    295342
    296343  infoPtr->hFont = (HFONT)wParam;
    297   if (LOWORD(lParam))
    298         PROGRESS_Refresh (hwnd);
     344  if (LOWORD(lParam)) PROGRESS_Refresh (hwnd);
     345
    299346  return hOldFont;
    300347}
    301348
     349static LRESULT PROGRESS_DeltaPos(HWND hwnd,WPARAM wParam,LPARAM lParam)
     350{
     351  PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
     352  INT temp;
     353
     354  //if(lParam) UNKNOWN_PARAM(PBM_DELTAPOS, wParam, lParam);
     355  temp = infoPtr->CurVal;
     356  if (wParam != 0)
     357  {
     358    infoPtr->CurVal += (INT)wParam;
     359    PROGRESS_CoercePos(hwnd);
     360    PROGRESS_Update(hwnd,temp);
     361  }
     362
     363  return temp;
     364}
     365
     366static LRESULT PROGRESS_SetPos(HWND hwnd,WPARAM wParam,LPARAM lParam)
     367{
     368  PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
     369  INT temp;
     370
     371  //if (lParam) UNKNOWN_PARAM(PBM_SETPOS, wParam, lParam);
     372  temp = infoPtr->CurVal;
     373  if (temp != wParam)
     374  {
     375    infoPtr->CurVal = (UINT16)wParam; //CB: 0..65535 allowed
     376    PROGRESS_CoercePos(hwnd);
     377    PROGRESS_Update(hwnd,temp);
     378  }
     379
     380  return temp;
     381}
     382
     383static LRESULT PROGRESS_SetRange(HWND hwnd,WPARAM wParam,LPARAM lParam)
     384{
     385  PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
     386  INT temp;
     387
     388  //if (wParam) UNKNOWN_PARAM(PBM_SETRANGE, wParam, lParam);
     389  temp = MAKELONG(infoPtr->MinVal,infoPtr->MaxVal);
     390  if (temp != lParam)
     391  {
     392    infoPtr->MinVal = LOWORD(lParam);
     393    infoPtr->MaxVal = HIWORD(lParam);
     394    if (infoPtr->MaxVal <= infoPtr->MinVal) infoPtr->MaxVal = infoPtr->MinVal+1;
     395    PROGRESS_CoercePos(hwnd);
     396    PROGRESS_Refresh(hwnd);
     397  }
     398
     399  return temp;
     400}
     401
     402static LRESULT PROGRESS_SetStep(HWND hwnd,WPARAM wParam,LPARAM lParam)
     403{
     404  PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
     405  INT temp;
     406
     407  //if (lParam) UNKNOWN_PARAM(PBM_SETSTEP, wParam, lParam);
     408  temp = infoPtr->Step;
     409  infoPtr->Step = (INT)wParam; //CB: negative steps allowed
     410
     411  return temp;
     412}
     413
     414static LRESULT PROGRESS_StepIt(HWND hwnd,WPARAM wParam,LPARAM lParam)
     415{
     416  PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
     417  INT temp;
     418
     419  //if (wParam || lParam) UNKNOWN_PARAM(PBM_STEPIT, wParam, lParam);
     420  temp = infoPtr->CurVal;
     421  infoPtr->CurVal += infoPtr->Step;
     422  if(infoPtr->CurVal > infoPtr->MaxVal) infoPtr->CurVal = infoPtr->MinVal;
     423  if(temp != infoPtr->CurVal) PROGRESS_Update (hwnd,temp);
     424
     425  return temp;
     426}
     427
     428static LRESULT PROGRESS_SetRange32(HWND hwnd,WPARAM wParam,LPARAM lParam)
     429{
     430  PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
     431  INT temp;
     432
     433  temp = MAKELONG(infoPtr->MinVal,infoPtr->MaxVal);
     434  if((infoPtr->MinVal != (INT)wParam) || (infoPtr->MaxVal != (INT)lParam))
     435  {
     436    infoPtr->MinVal = (INT)wParam;
     437    infoPtr->MaxVal = (INT)lParam;
     438    if(infoPtr->MaxVal <= infoPtr->MinVal) infoPtr->MaxVal = infoPtr->MinVal+1;
     439    PROGRESS_CoercePos(hwnd);
     440    PROGRESS_Refresh(hwnd);
     441  }
     442
     443  return temp;
     444}
     445
     446static LRESULT PROGRESS_GetRange(HWND hwnd,WPARAM wParam,LPARAM lParam)
     447{
     448  PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
     449
     450  if (lParam)
     451  {
     452    ((PPBRANGE)lParam)->iLow = infoPtr->MinVal;
     453    ((PPBRANGE)lParam)->iHigh = infoPtr->MaxVal;
     454  }
     455
     456  return (wParam) ? infoPtr->MinVal : infoPtr->MaxVal;
     457}
     458
     459static LRESULT PROGRESS_GetPos(HWND hwnd,WPARAM wParam,LPARAM lParam)
     460{
     461  PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
     462
     463  //if (wParam || lParam) UNKNOWN_PARAM(PBM_STEPIT, wParam, lParam);
     464
     465  return (infoPtr->CurVal);
     466}
     467
     468static LRESULT PROGRESS_SetBarColor(HWND hwnd,WPARAM wParam,LPARAM lParam)
     469{
     470  PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
     471  COLORREF oldColorBar = infoPtr->ColorBar;
     472
     473  //if (wParam) UNKNOWN_PARAM(PBM_SETBARCOLOR, wParam, lParam);
     474  infoPtr->ColorBar = (COLORREF)lParam;
     475  if (infoPtr->ColorBar != oldColorBar) PROGRESS_Refresh(hwnd);
     476
     477  return 0;
     478}
     479
     480static LRESULT PROGRESS_SetBkColor(HWND hwnd,WPARAM wParam,LPARAM lParam)
     481{
     482  PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
     483  COLORREF oldColorBk = infoPtr->ColorBk;
     484
     485  //if (wParam) UNKNOWN_PARAM(PBM_SETBKCOLOR, wParam, lParam);
     486  infoPtr->ColorBk = (COLORREF)lParam;
     487  if (infoPtr->ColorBk != oldColorBk) PROGRESS_Refresh (hwnd);
     488
     489  return 0;
     490}
    302491
    303492/***********************************************************************
     
    307496                                  WPARAM wParam, LPARAM lParam)
    308497{
    309     PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
    310   INT temp;
    311 
    312498  switch(message)
    313499    {
    314500    case WM_NCCREATE:
    315             {
    316                 DWORD dwExStyle;
    317                 dwExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
    318                 SetWindowLongA(hwnd, GWL_EXSTYLE, dwExStyle | WS_EX_STATICEDGE);
    319             }
    320       return TRUE;
     501      return PROGRESS_NCCreate(hwnd,wParam,lParam);
    321502
    322503    case WM_CREATE:
    323       /* allocate memory for info struct */
    324       infoPtr =
    325         (PROGRESS_INFO *)COMCTL32_Alloc (sizeof(PROGRESS_INFO));
    326       SetWindowLongA(hwnd, 0, (DWORD)infoPtr);
    327 
    328       /* initialize the info struct */
    329       infoPtr->MinVal=0;
    330       infoPtr->MaxVal=100;
    331       infoPtr->CurVal=0;
    332       infoPtr->Step=10;
    333       infoPtr->ColorBar=CLR_DEFAULT;
    334       infoPtr->ColorBk=CLR_DEFAULT;
    335       infoPtr->hFont=(HANDLE)NULL;
    336 //      TRACE(progress, "Progress Ctrl creation, hwnd=%04x\n", hwnd);
    337       break;
     504      return PROGRESS_Create(hwnd,wParam,lParam);
    338505
    339506    case WM_DESTROY:
    340 //      TRACE (progress, "Progress Ctrl destruction, hwnd=%04x\n", hwnd);
    341       COMCTL32_Free (infoPtr);
    342       break;
     507      return PROGRESS_Destroy(hwnd,wParam,lParam);
    343508
    344509    case WM_ERASEBKGND:
     
    348513
    349514    case WM_GETFONT:
    350       return (LRESULT)infoPtr->hFont;
     515      return PROGRESS_GetFont(hwnd,wParam,lParam);
    351516
    352517    case WM_SETFONT:
    353       return PROGRESS_SetFont (hwnd, wParam, lParam);
     518      return PROGRESS_SetFont (hwnd,wParam,lParam);
    354519
    355520    case WM_PAINT:
    356       PROGRESS_Paint (hwnd);
     521      PROGRESS_Paint(hwnd);
    357522      break;
    358523
    359524    case PBM_DELTAPOS:
    360       if(lParam)
    361         UNKNOWN_PARAM(PBM_DELTAPOS, wParam, lParam);
    362       temp = infoPtr->CurVal;
    363       if(wParam != 0){
    364         infoPtr->CurVal += (INT)wParam;
    365         PROGRESS_CoercePos (hwnd);
    366         PROGRESS_Update (hwnd,temp);
    367       }
    368       return temp;
     525      return PROGRESS_DeltaPos(hwnd,wParam,lParam);
    369526
    370527    case PBM_SETPOS:
    371       if (lParam)
    372         UNKNOWN_PARAM(PBM_SETPOS, wParam, lParam);
    373       temp = infoPtr->CurVal;
    374       if(temp != wParam){
    375         infoPtr->CurVal = (UINT16)wParam; //CB: 0..65535 allowed
    376         PROGRESS_CoercePos(hwnd);
    377         PROGRESS_Update (hwnd,temp);
    378       }
    379       return temp;
     528      return PROGRESS_SetPos(hwnd,wParam,lParam);
    380529
    381530    case PBM_SETRANGE:
    382       if (wParam)
    383         UNKNOWN_PARAM(PBM_SETRANGE, wParam, lParam);
    384       temp = MAKELONG(infoPtr->MinVal, infoPtr->MaxVal);
    385       if(temp != lParam){
    386         infoPtr->MinVal = LOWORD(lParam);
    387         infoPtr->MaxVal = HIWORD(lParam);
    388         if(infoPtr->MaxVal <= infoPtr->MinVal)
    389           infoPtr->MaxVal = infoPtr->MinVal+1;
    390         PROGRESS_CoercePos(hwnd);
    391         PROGRESS_Refresh (hwnd);
    392       }
    393       return temp;
     531      return PROGRESS_SetRange(hwnd,wParam,lParam);
    394532
    395533    case PBM_SETSTEP:
    396       if (lParam)
    397         UNKNOWN_PARAM(PBM_SETSTEP, wParam, lParam);
    398       temp = infoPtr->Step;
    399       infoPtr->Step = (INT)wParam; //CB: negative steps allowed
    400       return temp;
     534      return PROGRESS_SetStep(hwnd,wParam,lParam);
    401535
    402536    case PBM_STEPIT:
    403       if (wParam || lParam)
    404         UNKNOWN_PARAM(PBM_STEPIT, wParam, lParam);
    405       temp = infoPtr->CurVal;
    406       infoPtr->CurVal += infoPtr->Step;
    407       if(infoPtr->CurVal > infoPtr->MaxVal)
    408         infoPtr->CurVal = infoPtr->MinVal;
    409       if(temp != infoPtr->CurVal)
    410         PROGRESS_Update (hwnd,temp);
    411       return temp;
     537      return PROGRESS_StepIt(hwnd,wParam,lParam);
    412538
    413539    case PBM_SETRANGE32:
    414       temp = MAKELONG(infoPtr->MinVal, infoPtr->MaxVal);
    415       if((infoPtr->MinVal != (INT)wParam) ||
    416          (infoPtr->MaxVal != (INT)lParam)) {
    417         infoPtr->MinVal = (INT)wParam;
    418         infoPtr->MaxVal = (INT)lParam;
    419         if(infoPtr->MaxVal <= infoPtr->MinVal)
    420           infoPtr->MaxVal = infoPtr->MinVal+1;
    421         PROGRESS_CoercePos(hwnd);
    422         PROGRESS_Refresh (hwnd);
    423       }
    424       return temp;
     540      return PROGRESS_SetRange32(hwnd,wParam,lParam);
    425541
    426542    case PBM_GETRANGE:
    427       if (lParam){
    428         ((PPBRANGE)lParam)->iLow = infoPtr->MinVal;
    429         ((PPBRANGE)lParam)->iHigh = infoPtr->MaxVal;
    430       }
    431       return (wParam) ? infoPtr->MinVal : infoPtr->MaxVal;
     543      return PROGRESS_GetRange(hwnd,wParam,lParam);
    432544
    433545    case PBM_GETPOS:
    434       if (wParam || lParam)
    435         UNKNOWN_PARAM(PBM_STEPIT, wParam, lParam);
    436       return (infoPtr->CurVal);
     546      return PROGRESS_GetPos(hwnd,wParam,lParam);
    437547
    438548    case PBM_SETBARCOLOR:
    439       if (wParam)
    440         UNKNOWN_PARAM(PBM_SETBARCOLOR, wParam, lParam);
    441       infoPtr->ColorBar = (COLORREF)lParam;
    442       PROGRESS_Refresh (hwnd);
    443       break;
     549      return PROGRESS_SetBarColor(hwnd,wParam,lParam);
    444550
    445551    case PBM_SETBKCOLOR:
    446       if (wParam)
    447         UNKNOWN_PARAM(PBM_SETBKCOLOR, wParam, lParam);
    448       infoPtr->ColorBk = (COLORREF)lParam;
    449       PROGRESS_Refresh (hwnd);
    450       break;
     552      return PROGRESS_SetBkColor(hwnd,wParam,lParam);
    451553
    452554    default:
  • trunk/src/comctl32/rebar.c

    r94 r236  
    1 /* $Id: rebar.c,v 1.4 1999-06-10 16:22:01 achimha Exp $ */
     1/* $Id: rebar.c,v 1.5 1999-06-28 15:46:26 cbratschi Exp $ */
    22/*
    33 * Rebar control
     
    55 * Copyright 1998, 1999 Eric Kohl
    66 * Copyright 1999 Achim Hasenmueller
     7 * Copyright 1999 Christoph Bratschi
    78 *
    89 * NOTES
     
    1415 *   - vertical placement
    1516 *   - ComboBox and ComboBoxEx placement
    16  *   - center image 
     17 *   - center image
    1718 *   - Layout code.
    1819 *   - Display code.
     
    5253    /* draw gripper */
    5354    if (lpBand->fDraw & DRAW_GRIPPER)
    54         DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
     55        DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
    5556
    5657    /* draw caption image */
    5758    if (lpBand->fDraw & DRAW_IMAGE) {
    58         /* FIXME: center image */
    59         POINT pt;
    60 
    61         pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
    62         pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
    63 
    64         ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
    65 /*                      lpBand->rcCapImage.left, lpBand->rcCapImage.top, */
    66                         pt.x, pt.y,
    67                         ILD_TRANSPARENT);
     59        /* FIXME: center image */
     60        POINT pt;
     61
     62        pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
     63        pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
     64
     65        ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
     66/*                      lpBand->rcCapImage.left, lpBand->rcCapImage.top, */
     67                        pt.x, pt.y,
     68                        ILD_TRANSPARENT);
    6869    }
    6970
    7071    /* draw caption text */
    7172    if (lpBand->fDraw & DRAW_TEXT) {
    72         HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
    73         INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
    74         DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
    75                      DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    76         if (oldBkMode != TRANSPARENT)
    77             SetBkMode (hdc, oldBkMode);
    78         SelectObject (hdc, hOldFont);
     73        HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
     74        INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
     75        DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
     76                     DT_CENTER | DT_VCENTER | DT_SINGLELINE);
     77        if (oldBkMode != TRANSPARENT)
     78            SetBkMode (hdc, oldBkMode);
     79        SelectObject (hdc, hOldFont);
    7980    }
    8081}
     
    8990
    9091    for (i = 0; i < infoPtr->uNumBands; i++) {
    91         lpBand = &infoPtr->bands[i];
    92 
    93         if ((lpBand->fStyle & RBBS_HIDDEN) ||
    94             ((GetWindowLongA (hwnd, GWL_STYLE) & CCS_VERT) &&
    95              (lpBand->fStyle & RBBS_NOVERT)))
    96             continue;
    97 
    98         REBAR_DrawBand (hdc, infoPtr, lpBand);
     92        lpBand = &infoPtr->bands[i];
     93
     94        if ((lpBand->fStyle & RBBS_HIDDEN) ||
     95            ((GetWindowLongA (hwnd, GWL_STYLE) & CCS_VERT) &&
     96             (lpBand->fStyle & RBBS_NOVERT)))
     97            continue;
     98
     99        REBAR_DrawBand (hdc, infoPtr, lpBand);
    99100
    100101    }
     
    112113    /* image is visible */
    113114    if ((lpBand->iImage > -1) && (infoPtr->himl)) {
    114         lpBand->fDraw |= DRAW_IMAGE;
    115 
    116         lpBand->rcCapImage.right  = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
    117         lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
    118 
    119         /* update band height */
    120         if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
    121             lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
    122             lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
    123         }
     115        lpBand->fDraw |= DRAW_IMAGE;
     116
     117        lpBand->rcCapImage.right  = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
     118        lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
     119
     120        /* update band height */
     121        if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
     122            lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
     123            lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
     124        }
    124125    }
    125126
     
    132133    /* text is visible */
    133134    if (lpBand->lpText) {
    134         HDC hdc = GetDC (0);
    135         HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
    136         SIZE size;
    137 
    138         lpBand->fDraw |= DRAW_TEXT;
    139         GetTextExtentPoint32W (hdc, lpBand->lpText,
    140                                lstrlenW (lpBand->lpText), &size);
    141         lpBand->rcCapText.right += size.cx;
    142 
    143         SelectObject (hdc, hOldFont);
    144         ReleaseDC (0, hdc);
     135        HDC hdc = GetDC (0);
     136        HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
     137        SIZE size;
     138
     139        lpBand->fDraw |= DRAW_TEXT;
     140        GetTextExtentPoint32W (hdc, lpBand->lpText,
     141                               lstrlenW (lpBand->lpText), &size);
     142        lpBand->rcCapText.right += size.cx;
     143
     144        SelectObject (hdc, hOldFont);
     145        ReleaseDC (0, hdc);
    145146    }
    146147
    147148    /* set initial child window rectangle */
    148149    if (lpBand->fStyle & RBBS_FIXEDSIZE) {
    149         lpBand->rcChild.left   = lpBand->rcCapText.right;
    150         lpBand->rcChild.top    = lpBand->rcBand.top;
    151         lpBand->rcChild.right  = lpBand->rcBand.right;
    152         lpBand->rcChild.bottom = lpBand->rcBand.bottom;
     150        lpBand->rcChild.left   = lpBand->rcCapText.right;
     151        lpBand->rcChild.top    = lpBand->rcBand.top;
     152        lpBand->rcChild.right  = lpBand->rcBand.right;
     153        lpBand->rcChild.bottom = lpBand->rcBand.bottom;
    153154    }
    154155    else {
    155         lpBand->rcChild.left   = lpBand->rcCapText.right + 4;
    156         lpBand->rcChild.top    = lpBand->rcBand.top + 2;
    157         lpBand->rcChild.right  = lpBand->rcBand.right - 4;
    158         lpBand->rcChild.bottom = lpBand->rcBand.bottom - 2;
     156        lpBand->rcChild.left   = lpBand->rcCapText.right + 4;
     157        lpBand->rcChild.top    = lpBand->rcBand.top + 2;
     158        lpBand->rcChild.right  = lpBand->rcBand.right - 4;
     159        lpBand->rcChild.bottom = lpBand->rcBand.bottom - 2;
    159160    }
    160161
    161162    /* calculate gripper rectangle */
    162163    if ((!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
    163         (!(lpBand->fStyle & RBBS_FIXEDSIZE)) &&
    164         ((lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
    165         (infoPtr->uNumBands > 1))) {
    166         lpBand->fDraw |= DRAW_GRIPPER;
    167         lpBand->rcGripper.left   = lpBand->rcBand.left + 3;
    168         lpBand->rcGripper.right  = lpBand->rcGripper.left + 3;
    169         lpBand->rcGripper.top    = lpBand->rcBand.top + 3;
    170         lpBand->rcGripper.bottom = lpBand->rcBand.bottom - 3;
    171 
    172         /* move caption rectangles */
    173         OffsetRect (&lpBand->rcCapImage, GRIPPER_WIDTH, 0);
    174         OffsetRect (&lpBand->rcCapText, GRIPPER_WIDTH, 0);
    175 
    176         /* adjust child rectangle */
    177         lpBand->rcChild.left += GRIPPER_WIDTH;
     164        (!(lpBand->fStyle & RBBS_FIXEDSIZE)) &&
     165        ((lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
     166        (infoPtr->uNumBands > 1))) {
     167        lpBand->fDraw |= DRAW_GRIPPER;
     168        lpBand->rcGripper.left   = lpBand->rcBand.left + 3;
     169        lpBand->rcGripper.right  = lpBand->rcGripper.left + 3;
     170        lpBand->rcGripper.top    = lpBand->rcBand.top + 3;
     171        lpBand->rcGripper.bottom = lpBand->rcBand.bottom - 3;
     172
     173        /* move caption rectangles */
     174        OffsetRect (&lpBand->rcCapImage, GRIPPER_WIDTH, 0);
     175        OffsetRect (&lpBand->rcCapText, GRIPPER_WIDTH, 0);
     176
     177        /* adjust child rectangle */
     178        lpBand->rcChild.left += GRIPPER_WIDTH;
    178179    }
    179180
     
    192193    /* image is visible */
    193194    if ((lpBand->iImage > -1) && (infoPtr->himl)) {
    194         lpBand->fDraw |= DRAW_IMAGE;
    195 
    196         lpBand->rcCapImage.right  = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
    197         lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
    198 
    199         /* update band width */
    200         if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
    201             lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
    202             lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
    203         }
     195        lpBand->fDraw |= DRAW_IMAGE;
     196
     197        lpBand->rcCapImage.right  = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
     198        lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
     199
     200        /* update band width */
     201        if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
     202            lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
     203            lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
     204        }
    204205    }
    205206
     
    212213    /* text is visible */
    213214    if (lpBand->lpText) {
    214         HDC hdc = GetDC (0);
    215         HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
    216         SIZE size;
    217 
    218         lpBand->fDraw |= DRAW_TEXT;
    219         GetTextExtentPoint32W (hdc, lpBand->lpText,
    220                                lstrlenW (lpBand->lpText), &size);
    221 /*      lpBand->rcCapText.right += size.cx; */
    222         lpBand->rcCapText.bottom += size.cy;
    223 
    224         SelectObject (hdc, hOldFont);
    225         ReleaseDC (0, hdc);
     215        HDC hdc = GetDC (0);
     216        HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
     217        SIZE size;
     218
     219        lpBand->fDraw |= DRAW_TEXT;
     220        GetTextExtentPoint32W (hdc, lpBand->lpText,
     221                               lstrlenW (lpBand->lpText), &size);
     222/*      lpBand->rcCapText.right += size.cx; */
     223        lpBand->rcCapText.bottom += size.cy;
     224
     225        SelectObject (hdc, hOldFont);
     226        ReleaseDC (0, hdc);
    226227    }
    227228
    228229    /* set initial child window rectangle */
    229230    if (lpBand->fStyle & RBBS_FIXEDSIZE) {
    230         lpBand->rcChild.left   = lpBand->rcBand.left;
    231         lpBand->rcChild.top    = lpBand->rcCapText.bottom;
    232         lpBand->rcChild.right  = lpBand->rcBand.right;
    233         lpBand->rcChild.bottom = lpBand->rcBand.bottom;
     231        lpBand->rcChild.left   = lpBand->rcBand.left;
     232        lpBand->rcChild.top    = lpBand->rcCapText.bottom;
     233        lpBand->rcChild.right  = lpBand->rcBand.right;
     234        lpBand->rcChild.bottom = lpBand->rcBand.bottom;
    234235    }
    235236    else {
    236         lpBand->rcChild.left   = lpBand->rcBand.left + 2;
    237         lpBand->rcChild.top    = lpBand->rcCapText.bottom + 4;
    238         lpBand->rcChild.right  = lpBand->rcBand.right - 2;
    239         lpBand->rcChild.bottom = lpBand->rcBand.bottom - 4;
     237        lpBand->rcChild.left   = lpBand->rcBand.left + 2;
     238        lpBand->rcChild.top    = lpBand->rcCapText.bottom + 4;
     239        lpBand->rcChild.right  = lpBand->rcBand.right - 2;
     240        lpBand->rcChild.bottom = lpBand->rcBand.bottom - 4;
    240241    }
    241242
    242243    /* calculate gripper rectangle */
    243244    if ((!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
    244         (!(lpBand->fStyle & RBBS_FIXEDSIZE)) &&
    245         ((lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
    246         (infoPtr->uNumBands > 1))) {
    247         lpBand->fDraw |= DRAW_GRIPPER;
    248 
    249         if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_VERTICALGRIPPER) {
    250             /* adjust band width */
    251             lpBand->rcBand.right += GRIPPER_WIDTH;
    252             lpBand->uMinHeight += GRIPPER_WIDTH;
    253 
    254             lpBand->rcGripper.left   = lpBand->rcBand.left + 3;
    255             lpBand->rcGripper.right  = lpBand->rcGripper.left + 3;
    256             lpBand->rcGripper.top    = lpBand->rcBand.top + 3;
    257             lpBand->rcGripper.bottom = lpBand->rcBand.bottom - 3;
    258 
    259             /* move caption rectangles */
    260             OffsetRect (&lpBand->rcCapImage, GRIPPER_WIDTH, 0);
    261             OffsetRect (&lpBand->rcCapText, GRIPPER_WIDTH, 0);
    262  
    263             /* adjust child rectangle */
    264             lpBand->rcChild.left += GRIPPER_WIDTH;
    265         }
    266         else {
    267             lpBand->rcGripper.left   = lpBand->rcBand.left + 3;
    268             lpBand->rcGripper.right  = lpBand->rcBand.right - 3;
    269             lpBand->rcGripper.top    = lpBand->rcBand.top + 3;
    270             lpBand->rcGripper.bottom = lpBand->rcGripper.top + 3;
    271 
    272             /* move caption rectangles */
    273             OffsetRect (&lpBand->rcCapImage, 0, GRIPPER_WIDTH);
    274             OffsetRect (&lpBand->rcCapText, 0, GRIPPER_WIDTH);
    275  
    276             /* adjust child rectangle */
    277             lpBand->rcChild.top += GRIPPER_WIDTH;
    278         }
     245        (!(lpBand->fStyle & RBBS_FIXEDSIZE)) &&
     246        ((lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
     247        (infoPtr->uNumBands > 1))) {
     248        lpBand->fDraw |= DRAW_GRIPPER;
     249
     250        if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_VERTICALGRIPPER) {
     251            /* adjust band width */
     252            lpBand->rcBand.right += GRIPPER_WIDTH;
     253            lpBand->uMinHeight += GRIPPER_WIDTH;
     254
     255            lpBand->rcGripper.left   = lpBand->rcBand.left + 3;
     256            lpBand->rcGripper.right  = lpBand->rcGripper.left + 3;
     257            lpBand->rcGripper.top    = lpBand->rcBand.top + 3;
     258            lpBand->rcGripper.bottom = lpBand->rcBand.bottom - 3;
     259
     260            /* move caption rectangles */
     261            OffsetRect (&lpBand->rcCapImage, GRIPPER_WIDTH, 0);
     262            OffsetRect (&lpBand->rcCapText, GRIPPER_WIDTH, 0);
     263
     264            /* adjust child rectangle */
     265            lpBand->rcChild.left += GRIPPER_WIDTH;
     266        }
     267        else {
     268            lpBand->rcGripper.left   = lpBand->rcBand.left + 3;
     269            lpBand->rcGripper.right  = lpBand->rcBand.right - 3;
     270            lpBand->rcGripper.top    = lpBand->rcBand.top + 3;
     271            lpBand->rcGripper.bottom = lpBand->rcGripper.top + 3;
     272
     273            /* move caption rectangles */
     274            OffsetRect (&lpBand->rcCapImage, 0, GRIPPER_WIDTH);
     275            OffsetRect (&lpBand->rcCapText, 0, GRIPPER_WIDTH);
     276
     277            /* adjust child rectangle */
     278            lpBand->rcChild.top += GRIPPER_WIDTH;
     279        }
    279280    }
    280281}
     
    292293
    293294    if (lpRect)
    294         rcClient = *lpRect;
     295        rcClient = *lpRect;
    295296    else
    296         GetClientRect (hwnd, &rcClient);
     297        GetClientRect (hwnd, &rcClient);
    297298
    298299    x = 0;
     
    300301
    301302    if (dwStyle & CCS_VERT) {
    302         cx = 20;    /* FIXME: fixed height */
    303         cy = rcClient.bottom - rcClient.top;
     303        cx = 20;    /* FIXME: fixed height */
     304        cy = rcClient.bottom - rcClient.top;
    304305    }
    305306    else {
    306         cx = rcClient.right - rcClient.left;
    307         cy = 20;    /* FIXME: fixed height */
     307        cx = rcClient.right - rcClient.left;
     308        cy = 20;    /* FIXME: fixed height */
    308309    }
    309310
    310311    for (i = 0; i < infoPtr->uNumBands; i++) {
    311         lpBand = &infoPtr->bands[i];
    312 
    313         if ((lpBand->fStyle & RBBS_HIDDEN) ||
    314             ((dwStyle & CCS_VERT) && (lpBand->fStyle & RBBS_NOVERT)))
    315             continue;
    316 
    317 
    318         if (dwStyle & CCS_VERT) {
    319             if (lpBand->fStyle & RBBS_VARIABLEHEIGHT)
    320                 cx = lpBand->cyMaxChild;
    321             else if (lpBand->fStyle & RBBIM_CHILDSIZE)
    322                 cx = lpBand->cyMinChild;
    323             else
    324                 cx = 20; /* FIXME */
    325 
    326             lpBand->rcBand.left   = x;
    327             lpBand->rcBand.right  = x + cx;
    328             lpBand->rcBand.top    = y;
    329             lpBand->rcBand.bottom = y + cy;
    330             lpBand->uMinHeight = cx;
    331         }
    332         else {
    333             if (lpBand->fStyle & RBBS_VARIABLEHEIGHT)
    334                 cy = lpBand->cyMaxChild;
    335             else if (lpBand->fStyle & RBBIM_CHILDSIZE)
    336                 cy = lpBand->cyMinChild;
    337             else
    338                 cy = 20; /* FIXME */
    339 
    340             lpBand->rcBand.left   = x;
    341             lpBand->rcBand.right  = x + cx;
    342             lpBand->rcBand.top    = y;
    343             lpBand->rcBand.bottom = y + cy;
    344             lpBand->uMinHeight = cy;
    345         }
    346 
    347         if (dwStyle & CCS_VERT) {
    348             REBAR_CalcVertBand (hwnd, infoPtr, lpBand);
    349             x += lpBand->uMinHeight;
    350         }
    351         else {
    352             REBAR_CalcHorzBand (infoPtr, lpBand);
    353             y += lpBand->uMinHeight;
    354         }
     312        lpBand = &infoPtr->bands[i];
     313
     314        if ((lpBand->fStyle & RBBS_HIDDEN) ||
     315            ((dwStyle & CCS_VERT) && (lpBand->fStyle & RBBS_NOVERT)))
     316            continue;
     317
     318
     319        if (dwStyle & CCS_VERT) {
     320            if (lpBand->fStyle & RBBS_VARIABLEHEIGHT)
     321                cx = lpBand->cyMaxChild;
     322            else if (lpBand->fStyle & RBBIM_CHILDSIZE)
     323                cx = lpBand->cyMinChild;
     324            else
     325                cx = 20; /* FIXME */
     326
     327            lpBand->rcBand.left   = x;
     328            lpBand->rcBand.right  = x + cx;
     329            lpBand->rcBand.top    = y;
     330            lpBand->rcBand.bottom = y + cy;
     331            lpBand->uMinHeight = cx;
     332        }
     333        else {
     334            if (lpBand->fStyle & RBBS_VARIABLEHEIGHT)
     335                cy = lpBand->cyMaxChild;
     336            else if (lpBand->fStyle & RBBIM_CHILDSIZE)
     337                cy = lpBand->cyMinChild;
     338            else
     339                cy = 20; /* FIXME */
     340
     341            lpBand->rcBand.left   = x;
     342            lpBand->rcBand.right  = x + cx;
     343            lpBand->rcBand.top    = y;
     344            lpBand->rcBand.bottom = y + cy;
     345            lpBand->uMinHeight = cy;
     346        }
     347
     348        if (dwStyle & CCS_VERT) {
     349            REBAR_CalcVertBand (hwnd, infoPtr, lpBand);
     350            x += lpBand->uMinHeight;
     351        }
     352        else {
     353            REBAR_CalcHorzBand (infoPtr, lpBand);
     354            y += lpBand->uMinHeight;
     355        }
    355356    }
    356357
    357358    if (dwStyle & CCS_VERT) {
    358         infoPtr->calcSize.cx = x;
    359         infoPtr->calcSize.cy = rcClient.bottom - rcClient.top;
     359        infoPtr->calcSize.cx = x;
     360        infoPtr->calcSize.cy = rcClient.bottom - rcClient.top;
    360361    }
    361362    else {
    362         infoPtr->calcSize.cx = rcClient.right - rcClient.left;
    363         infoPtr->calcSize.cy = y;
     363        infoPtr->calcSize.cx = rcClient.right - rcClient.left;
     364        infoPtr->calcSize.cy = y;
    364365    }
    365366}
     
    373374
    374375//    TRACE (rebar, " to [%d x %d]!\n",
    375 //         infoPtr->calcSize.cx, infoPtr->calcSize.cy);
     376//         infoPtr->calcSize.cx, infoPtr->calcSize.cy);
    376377
    377378    infoPtr->bAutoResize = TRUE;
     
    383384
    384385    if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER) {
    385         InflateRect (&rc, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
     386        InflateRect (&rc, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
    386387    }
    387388
    388389    SetWindowPos (hwnd, 0, 0, 0,
    389                     rc.right - rc.left, rc.bottom - rc.top,
    390                     SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW);
     390                    rc.right - rc.left, rc.bottom - rc.top,
     391                    SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW);
    391392}
    392393
     
    401402
    402403    for (i = 0; i < infoPtr->uNumBands; i++) {
    403         lpBand = &infoPtr->bands[i];
    404 
    405         if (lpBand->fStyle & RBBS_HIDDEN)
    406             continue;
    407         if (lpBand->hwndChild) {
    408 //          TRACE (rebar, "hwndChild = %x\n", lpBand->hwndChild);
    409 
    410             GetClassNameA (lpBand->hwndChild, szClassName, 40);
    411             if (!lstrcmpA (szClassName, "ComboBox")) {
    412                 INT nEditHeight, yPos;
    413                 RECT rc;
    414 
    415                 /* special placement code for combo box */
    416 
    417 
    418                 /* get size of edit line */
    419                 GetWindowRect (lpBand->hwndChild, &rc);
    420                 nEditHeight = rc.bottom - rc.top;
    421                 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
    422 
    423                 /* center combo box inside child area */
    424                 SetWindowPos (lpBand->hwndChild, HWND_TOP,
    425                             lpBand->rcChild.left, /*lpBand->rcChild.top*/ yPos,
    426                             lpBand->rcChild.right - lpBand->rcChild.left,
    427                             nEditHeight,
    428                             SWP_SHOWWINDOW);
    429             }
     404        lpBand = &infoPtr->bands[i];
     405
     406        if (lpBand->fStyle & RBBS_HIDDEN)
     407            continue;
     408        if (lpBand->hwndChild) {
     409//          TRACE (rebar, "hwndChild = %x\n", lpBand->hwndChild);
     410
     411            GetClassNameA (lpBand->hwndChild, szClassName, 40);
     412            if (!lstrcmpA (szClassName, "ComboBox")) {
     413                INT nEditHeight, yPos;
     414                RECT rc;
     415
     416                /* special placement code for combo box */
     417
     418
     419                /* get size of edit line */
     420                GetWindowRect (lpBand->hwndChild, &rc);
     421                nEditHeight = rc.bottom - rc.top;
     422                yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
     423
     424                /* center combo box inside child area */
     425                SetWindowPos (lpBand->hwndChild, HWND_TOP,
     426                            lpBand->rcChild.left, /*lpBand->rcChild.top*/ yPos,
     427                            lpBand->rcChild.right - lpBand->rcChild.left,
     428                            nEditHeight,
     429                            SWP_SHOWWINDOW);
     430            }
    430431#if 0
    431             else if (!lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
    432                 /* special placement code for extended combo box */
    433 
    434 
    435             }
     432            else if (!lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
     433                /* special placement code for extended combo box */
     434
     435
     436            }
    436437#endif
    437             else {
    438                 SetWindowPos (lpBand->hwndChild, HWND_TOP,
    439                             lpBand->rcChild.left, lpBand->rcChild.top,
    440                             lpBand->rcChild.right - lpBand->rcChild.left,
    441                             lpBand->rcChild.bottom - lpBand->rcChild.top,
    442                             SWP_SHOWWINDOW);
    443             }
    444         }
     438            else {
     439                SetWindowPos (lpBand->hwndChild, HWND_TOP,
     440                            lpBand->rcChild.left, lpBand->rcChild.top,
     441                            lpBand->rcChild.right - lpBand->rcChild.left,
     442                            lpBand->rcChild.bottom - lpBand->rcChild.top,
     443                            SWP_SHOWWINDOW);
     444            }
     445        }
    445446    }
    446447}
     
    460461    if (PtInRect (&rect, *lpPt))
    461462    {
    462         if (infoPtr->uNumBands == 0) {
    463             *pFlags = RBHT_NOWHERE;
    464             if (pBand)
    465                 *pBand = -1;
    466 //          TRACE (rebar, "NOWHERE\n");
    467             return;
    468         }
    469         else {
    470             /* somewhere inside */
    471             for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
    472                 lpBand = &infoPtr->bands[iCount];
    473                 if (PtInRect (&lpBand->rcBand, *lpPt)) {
    474                     if (pBand)
    475                         *pBand = iCount;
    476                     if (PtInRect (&lpBand->rcGripper, *lpPt)) {
    477                         *pFlags = RBHT_GRABBER;
    478 //                      TRACE (rebar, "ON GRABBER %d\n", iCount);
    479                         return;
    480                     }
    481                     else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
    482                         *pFlags = RBHT_CAPTION;
    483 //                      TRACE (rebar, "ON CAPTION %d\n", iCount);
    484                         return;
    485                     }
    486                     else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
    487                         *pFlags = RBHT_CAPTION;
    488 //                      TRACE (rebar, "ON CAPTION %d\n", iCount);
    489                         return;
    490                     }
    491                     else if (PtInRect (&lpBand->rcChild, *lpPt)) {
    492                         *pFlags = RBHT_CLIENT;
    493 //                      TRACE (rebar, "ON CLIENT %d\n", iCount);
    494                         return;
    495                     }
    496                     else {
    497                         *pFlags = RBHT_NOWHERE;
    498 //                      TRACE (rebar, "NOWHERE %d\n", iCount);
    499                         return;
    500                     }
    501                 }
    502             }
    503 
    504             *pFlags = RBHT_NOWHERE;
    505             if (pBand)
    506                 *pBand = -1;
    507 
    508 //          TRACE (rebar, "NOWHERE\n");
    509             return;
    510         }
     463        if (infoPtr->uNumBands == 0) {
     464            *pFlags = RBHT_NOWHERE;
     465            if (pBand)
     466                *pBand = -1;
     467//          TRACE (rebar, "NOWHERE\n");
     468            return;
     469        }
     470        else {
     471            /* somewhere inside */
     472            for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
     473                lpBand = &infoPtr->bands[iCount];
     474                if (PtInRect (&lpBand->rcBand, *lpPt)) {
     475                    if (pBand)
     476                        *pBand = iCount;
     477                    if (PtInRect (&lpBand->rcGripper, *lpPt)) {
     478                        *pFlags = RBHT_GRABBER;
     479//                      TRACE (rebar, "ON GRABBER %d\n", iCount);
     480                        return;
     481                    }
     482                    else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
     483                        *pFlags = RBHT_CAPTION;
     484//                      TRACE (rebar, "ON CAPTION %d\n", iCount);
     485                        return;
     486                    }
     487                    else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
     488                        *pFlags = RBHT_CAPTION;
     489//                      TRACE (rebar, "ON CAPTION %d\n", iCount);
     490                        return;
     491                    }
     492                    else if (PtInRect (&lpBand->rcChild, *lpPt)) {
     493                        *pFlags = RBHT_CLIENT;
     494//                      TRACE (rebar, "ON CLIENT %d\n", iCount);
     495                        return;
     496                    }
     497                    else {
     498                        *pFlags = RBHT_NOWHERE;
     499//                      TRACE (rebar, "NOWHERE %d\n", iCount);
     500                        return;
     501                    }
     502                }
     503            }
     504
     505            *pFlags = RBHT_NOWHERE;
     506            if (pBand)
     507                *pBand = -1;
     508
     509//          TRACE (rebar, "NOWHERE\n");
     510            return;
     511        }
    511512    }
    512513    else {
    513         *pFlags = RBHT_NOWHERE;
    514         if (pBand)
    515             *pBand = -1;
    516 //      TRACE (rebar, "NOWHERE\n");
    517         return;
     514        *pFlags = RBHT_NOWHERE;
     515        if (pBand)
     516            *pBand = -1;
     517//      TRACE (rebar, "NOWHERE\n");
     518        return;
    518519    }
    519520
     
    534535
    535536    if (uBand >= infoPtr->uNumBands)
    536         return FALSE;
     537        return FALSE;
    537538
    538539//    TRACE (rebar, "deleting band %u!\n", uBand);
    539540
    540541    if (infoPtr->uNumBands == 1) {
    541 //      TRACE (rebar, " simple delete!\n");
    542         COMCTL32_Free (infoPtr->bands);
    543         infoPtr->bands = NULL;
    544         infoPtr->uNumBands = 0;
     542//      TRACE (rebar, " simple delete!\n");
     543        COMCTL32_Free (infoPtr->bands);
     544        infoPtr->bands = NULL;
     545        infoPtr->uNumBands = 0;
    545546    }
    546547    else {
    547         REBAR_BAND *oldBands = infoPtr->bands;
     548        REBAR_BAND *oldBands = infoPtr->bands;
    548549//        TRACE(rebar, "complex delete! [uBand=%u]\n", uBand);
    549550
    550         infoPtr->uNumBands--;
    551         infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
     551        infoPtr->uNumBands--;
     552        infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
    552553        if (uBand > 0) {
    553554            memcpy (&infoPtr->bands[0], &oldBands[0],
     
    560561        }
    561562
    562         COMCTL32_Free (oldBands);
     563        COMCTL32_Free (oldBands);
    563564    }
    564565
     
    583584
    584585    if (!lParam)
    585         return 0;
     586        return 0;
    586587    if ((UINT)wParam >= infoPtr->uNumBands)
    587         return 0;
     588        return 0;
    588589
    589590    lpBand = &infoPtr->bands[(UINT)wParam];
     
    618619
    619620    if (lprbbi == NULL)
    620         return FALSE;
     621        return FALSE;
    621622    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
    622         return FALSE;
     623        return FALSE;
    623624    if ((UINT)wParam >= infoPtr->uNumBands)
    624         return FALSE;
     625        return FALSE;
    625626
    626627//    TRACE (rebar, "index %u\n", (UINT)wParam);
     
    630631
    631632    if (lprbbi->fMask & RBBIM_STYLE)
    632         lprbbi->fStyle = lpBand->fStyle;
     633        lprbbi->fStyle = lpBand->fStyle;
    633634
    634635    if (lprbbi->fMask & RBBIM_COLORS) {
    635         lprbbi->clrFore = lpBand->clrFore;
    636         lprbbi->clrBack = lpBand->clrBack;
    637     }
    638 
    639     if ((lprbbi->fMask & RBBIM_TEXT) && 
    640         (lprbbi->lpText) && (lpBand->lpText)) {
    641             lstrcpynWtoA (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
     636        lprbbi->clrFore = lpBand->clrFore;
     637        lprbbi->clrBack = lpBand->clrBack;
     638    }
     639
     640    if ((lprbbi->fMask & RBBIM_TEXT) &&
     641        (lprbbi->lpText) && (lpBand->lpText)) {
     642            lstrcpynWtoA (lprbbi->lpText, lpBand->lpText, MIN(lprbbi->cch,lstrlenW(lpBand->lpText)));
    642643    }
    643644
    644645    if (lprbbi->fMask & RBBIM_IMAGE)
    645         lprbbi->iImage = lpBand->iImage;
     646        lprbbi->iImage = lpBand->iImage;
    646647
    647648    if (lprbbi->fMask & RBBIM_CHILD)
    648         lprbbi->hwndChild = lpBand->hwndChild;
     649        lprbbi->hwndChild = lpBand->hwndChild;
    649650
    650651    if (lprbbi->fMask & RBBIM_CHILDSIZE) {
    651         lprbbi->cxMinChild = lpBand->cxMinChild;
    652         lprbbi->cyMinChild = lpBand->cyMinChild;
    653         lprbbi->cyMaxChild = lpBand->cyMaxChild;
    654         lprbbi->cyChild    = lpBand->cyChild;
    655         lprbbi->cyIntegral = lpBand->cyIntegral;
     652        lprbbi->cxMinChild = lpBand->cxMinChild;
     653        lprbbi->cyMinChild = lpBand->cyMinChild;
     654        lprbbi->cyMaxChild = lpBand->cyMaxChild;
     655        lprbbi->cyChild    = lpBand->cyChild;
     656        lprbbi->cyIntegral = lpBand->cyIntegral;
    656657    }
    657658
    658659    if (lprbbi->fMask & RBBIM_SIZE)
    659         lprbbi->cx = lpBand->cx;
     660        lprbbi->cx = lpBand->cx;
    660661
    661662    if (lprbbi->fMask & RBBIM_BACKGROUND)
    662         lprbbi->hbmBack = lpBand->hbmBack;
     663        lprbbi->hbmBack = lpBand->hbmBack;
    663664
    664665    if (lprbbi->fMask & RBBIM_ID)
    665         lprbbi->wID = lpBand->wID;
     666        lprbbi->wID = lpBand->wID;
    666667
    667668    /* check for additional data */
    668669    if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
    669         if (lprbbi->fMask & RBBIM_IDEALSIZE)
    670             lprbbi->cxIdeal = lpBand->cxIdeal;
    671 
    672         if (lprbbi->fMask & RBBIM_LPARAM)
    673             lprbbi->lParam = lpBand->lParam;
    674 
    675         if (lprbbi->fMask & RBBIM_HEADERSIZE)
    676             lprbbi->cxHeader = lpBand->cxHeader;
     670        if (lprbbi->fMask & RBBIM_IDEALSIZE)
     671            lprbbi->cxIdeal = lpBand->cxIdeal;
     672
     673        if (lprbbi->fMask & RBBIM_LPARAM)
     674            lprbbi->lParam = lpBand->lParam;
     675
     676        if (lprbbi->fMask & RBBIM_HEADERSIZE)
     677            lprbbi->cxHeader = lpBand->cxHeader;
    677678    }
    678679
     
    689690
    690691    if (lprbbi == NULL)
    691         return FALSE;
     692        return FALSE;
    692693    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
    693         return FALSE;
     694        return FALSE;
    694695    if ((UINT)wParam >= infoPtr->uNumBands)
    695         return FALSE;
     696        return FALSE;
    696697
    697698//    TRACE (rebar, "index %u\n", (UINT)wParam);
     
    701702
    702703    if (lprbbi->fMask & RBBIM_STYLE)
    703         lprbbi->fStyle = lpBand->fStyle;
     704        lprbbi->fStyle = lpBand->fStyle;
    704705
    705706    if (lprbbi->fMask & RBBIM_COLORS) {
    706         lprbbi->clrFore = lpBand->clrFore;
    707         lprbbi->clrBack = lpBand->clrBack;
    708     }
    709 
    710     if ((lprbbi->fMask & RBBIM_TEXT) && 
    711         (lprbbi->lpText) && (lpBand->lpText)) {
    712             lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
     707        lprbbi->clrFore = lpBand->clrFore;
     708        lprbbi->clrBack = lpBand->clrBack;
     709    }
     710
     711    if ((lprbbi->fMask & RBBIM_TEXT) &&
     712        (lprbbi->lpText) && (lpBand->lpText)) {
     713            lstrcpynW (lprbbi->lpText, lpBand->lpText, MIN(lprbbi->cch,lstrlenW(lpBand->lpText)));
    713714    }
    714715
    715716    if (lprbbi->fMask & RBBIM_IMAGE)
    716         lprbbi->iImage = lpBand->iImage;
     717        lprbbi->iImage = lpBand->iImage;
    717718
    718719    if (lprbbi->fMask & RBBIM_CHILD)
    719         lprbbi->hwndChild = lpBand->hwndChild;
     720        lprbbi->hwndChild = lpBand->hwndChild;
    720721
    721722    if (lprbbi->fMask & RBBIM_CHILDSIZE) {
    722         lprbbi->cxMinChild = lpBand->cxMinChild;
    723         lprbbi->cyMinChild = lpBand->cyMinChild;
    724         lprbbi->cyMaxChild = lpBand->cyMaxChild;
    725         lprbbi->cyChild    = lpBand->cyChild;
    726         lprbbi->cyIntegral = lpBand->cyIntegral;
     723        lprbbi->cxMinChild = lpBand->cxMinChild;
     724        lprbbi->cyMinChild = lpBand->cyMinChild;
     725        lprbbi->cyMaxChild = lpBand->cyMaxChild;
     726        lprbbi->cyChild    = lpBand->cyChild;
     727        lprbbi->cyIntegral = lpBand->cyIntegral;
    727728    }
    728729
    729730    if (lprbbi->fMask & RBBIM_SIZE)
    730         lprbbi->cx = lpBand->cx;
     731        lprbbi->cx = lpBand->cx;
    731732
    732733    if (lprbbi->fMask & RBBIM_BACKGROUND)
    733         lprbbi->hbmBack = lpBand->hbmBack;
     734        lprbbi->hbmBack = lpBand->hbmBack;
    734735
    735736    if (lprbbi->fMask & RBBIM_ID)
    736         lprbbi->wID = lpBand->wID;
     737        lprbbi->wID = lpBand->wID;
    737738
    738739    /* check for additional data */
    739740    if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
    740         if (lprbbi->fMask & RBBIM_IDEALSIZE)
    741             lprbbi->cxIdeal = lpBand->cxIdeal;
    742 
    743         if (lprbbi->fMask & RBBIM_LPARAM)
    744             lprbbi->lParam = lpBand->lParam;
    745 
    746         if (lprbbi->fMask & RBBIM_HEADERSIZE)
    747             lprbbi->cxHeader = lpBand->cxHeader;
     741        if (lprbbi->fMask & RBBIM_IDEALSIZE)
     742            lprbbi->cxIdeal = lpBand->cxIdeal;
     743
     744        if (lprbbi->fMask & RBBIM_LPARAM)
     745            lprbbi->lParam = lpBand->lParam;
     746
     747        if (lprbbi->fMask & RBBIM_HEADERSIZE)
     748            lprbbi->cxHeader = lpBand->cxHeader;
    748749    }
    749750
     
    762763
    763764    if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER)
    764         nHeight += (2 * GetSystemMetrics(SM_CYEDGE));
     765        nHeight += (2 * GetSystemMetrics(SM_CYEDGE));
    765766
    766767
     
    778779
    779780    if (lpInfo == NULL)
    780         return FALSE;
     781        return FALSE;
    781782
    782783    if (lpInfo->cbSize < sizeof (REBARINFO))
    783         return FALSE;
     784        return FALSE;
    784785
    785786//    TRACE (rebar, "getting bar info!\n");
    786787
    787788    if (infoPtr->himl) {
    788         lpInfo->himl = infoPtr->himl;
    789         lpInfo->fMask |= RBIM_IMAGELIST;
     789        lpInfo->himl = infoPtr->himl;
     790        lpInfo->fMask |= RBIM_IMAGELIST;
    790791    }
    791792
     
    827828
    828829    if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
    829         return FALSE;
     830        return FALSE;
    830831    if (!lprc)
    831         return FALSE;
     832        return FALSE;
    832833
    833834//    TRACE (rebar, "band %d\n", iBand);
     
    899900{
    900901    /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
    901     LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam; 
     902    LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
    902903
    903904    if (!lprbht)
    904         return -1;
     905        return -1;
    905906
    906907    REBAR_InternalHitTest (hwnd, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
     
    917918
    918919    if (infoPtr == NULL)
    919         return -1;
     920        return -1;
    920921
    921922    if (infoPtr->uNumBands < 1)
    922         return -1;
     923        return -1;
    923924
    924925//    TRACE (rebar, "id %u\n", (UINT)wParam);
    925926
    926927    for (i = 0; i < infoPtr->uNumBands; i++) {
    927         if (infoPtr->bands[i].wID == (UINT)wParam) {
    928 //          TRACE (rebar, "band %u found!\n", i);
    929             return i;
    930         }
     928        if (infoPtr->bands[i].wID == (UINT)wParam) {
     929//          TRACE (rebar, "band %u found!\n", i);
     930            return i;
     931        }
    931932    }
    932933
     
    945946
    946947    if (infoPtr == NULL)
    947         return FALSE;
     948        return FALSE;
    948949    if (lprbbi == NULL)
    949         return FALSE;
     950        return FALSE;
    950951    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
    951         return FALSE;
     952        return FALSE;
    952953
    953954//    TRACE (rebar, "insert band at %u!\n", uIndex);
    954955
    955956    if (infoPtr->uNumBands == 0) {
    956         infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
    957         uIndex = 0;
     957        infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
     958        uIndex = 0;
    958959    }
    959960    else {
    960         REBAR_BAND *oldBands = infoPtr->bands;
    961         infoPtr->bands =
    962             (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
    963         if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
    964             uIndex = infoPtr->uNumBands;
    965 
    966         /* pre insert copy */
    967         if (uIndex > 0) {
    968             memcpy (&infoPtr->bands[0], &oldBands[0],
    969                     uIndex * sizeof(REBAR_BAND));
    970         }
    971 
    972         /* post copy */
    973         if (uIndex < infoPtr->uNumBands - 1) {
    974             memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
    975                     (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
    976         }
    977 
    978         COMCTL32_Free (oldBands);
     961        REBAR_BAND *oldBands = infoPtr->bands;
     962        infoPtr->bands =
     963            (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
     964        if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
     965            uIndex = infoPtr->uNumBands;
     966
     967        /* pre insert copy */
     968        if (uIndex > 0) {
     969            memcpy (&infoPtr->bands[0], &oldBands[0],
     970                    uIndex * sizeof(REBAR_BAND));
     971        }
     972
     973        /* post copy */
     974        if (uIndex < infoPtr->uNumBands - 1) {
     975            memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
     976                    (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
     977        }
     978
     979        COMCTL32_Free (oldBands);
    979980    }
    980981
     
    987988
    988989    if (lprbbi->fMask & RBBIM_STYLE)
    989         lpBand->fStyle = lprbbi->fStyle;
     990        lpBand->fStyle = lprbbi->fStyle;
    990991
    991992    if (lprbbi->fMask & RBBIM_COLORS) {
    992         lpBand->clrFore = lprbbi->clrFore;
    993         lpBand->clrBack = lprbbi->clrBack;
     993        lpBand->clrFore = lprbbi->clrFore;
     994        lpBand->clrBack = lprbbi->clrBack;
    994995    }
    995996    else {
    996         lpBand->clrFore = CLR_NONE;
    997         lpBand->clrBack = CLR_NONE;
     997        lpBand->clrFore = CLR_NONE;
     998        lpBand->clrBack = CLR_NONE;
    998999    }
    9991000
    10001001    if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
    1001         INT len = lstrlenA (lprbbi->lpText);
    1002         if (len > 0) {
    1003             lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    1004             lstrcpyAtoW (lpBand->lpText, lprbbi->lpText);
    1005         }
     1002        INT len = lstrlenA (lprbbi->lpText);
     1003        if (len > 0) {
     1004            lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     1005            lstrcpyAtoW (lpBand->lpText, lprbbi->lpText);
     1006        }
    10061007    }
    10071008
    10081009    if (lprbbi->fMask & RBBIM_IMAGE)
    1009         lpBand->iImage = lprbbi->iImage;
     1010        lpBand->iImage = lprbbi->iImage;
    10101011    else
    1011         lpBand->iImage = -1;
     1012        lpBand->iImage = -1;
    10121013
    10131014    if (lprbbi->fMask & RBBIM_CHILD) {
    1014 //      TRACE (rebar, "hwndChild = %x\n", lprbbi->hwndChild);
    1015         lpBand->hwndChild = lprbbi->hwndChild;
    1016         lpBand->hwndPrevParent =
    1017             SetParent (lpBand->hwndChild, hwnd);
     1015//      TRACE (rebar, "hwndChild = %x\n", lprbbi->hwndChild);
     1016        lpBand->hwndChild = lprbbi->hwndChild;
     1017        lpBand->hwndPrevParent =
     1018            SetParent (lpBand->hwndChild, hwnd);
    10181019    }
    10191020
    10201021    if (lprbbi->fMask & RBBIM_CHILDSIZE) {
    1021         lpBand->cxMinChild = lprbbi->cxMinChild;
    1022         lpBand->cyMinChild = lprbbi->cyMinChild;
    1023         lpBand->cyMaxChild = lprbbi->cyMaxChild;
    1024         lpBand->cyChild    = lprbbi->cyChild;
    1025         lpBand->cyIntegral = lprbbi->cyIntegral;
     1022        lpBand->cxMinChild = lprbbi->cxMinChild;
     1023        lpBand->cyMinChild = lprbbi->cyMinChild;
     1024        lpBand->cyMaxChild = lprbbi->cyMaxChild;
     1025        lpBand->cyChild    = lprbbi->cyChild;
     1026        lpBand->cyIntegral = lprbbi->cyIntegral;
    10261027    }
    10271028    else {
    1028         lpBand->cxMinChild = -1;
    1029         lpBand->cyMinChild = -1;
    1030         lpBand->cyMaxChild = -1;
    1031         lpBand->cyChild    = -1;
    1032         lpBand->cyIntegral = -1;
     1029        lpBand->cxMinChild = -1;
     1030        lpBand->cyMinChild = -1;
     1031        lpBand->cyMaxChild = -1;
     1032        lpBand->cyChild    = -1;
     1033        lpBand->cyIntegral = -1;
    10331034    }
    10341035
    10351036    if (lprbbi->fMask & RBBIM_SIZE)
    1036         lpBand->cx = lprbbi->cx;
     1037        lpBand->cx = lprbbi->cx;
    10371038    else
    1038         lpBand->cx = -1;
     1039        lpBand->cx = -1;
    10391040
    10401041    if (lprbbi->fMask & RBBIM_BACKGROUND)
    1041         lpBand->hbmBack = lprbbi->hbmBack;
     1042        lpBand->hbmBack = lprbbi->hbmBack;
    10421043
    10431044    if (lprbbi->fMask & RBBIM_ID)
    1044         lpBand->wID = lprbbi->wID;
     1045        lpBand->wID = lprbbi->wID;
    10451046
    10461047    /* check for additional data */
    10471048    if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
    1048         if (lprbbi->fMask & RBBIM_IDEALSIZE)
    1049             lpBand->cxIdeal = lprbbi->cxIdeal;
    1050 
    1051         if (lprbbi->fMask & RBBIM_LPARAM)
    1052             lpBand->lParam = lprbbi->lParam;
    1053 
    1054         if (lprbbi->fMask & RBBIM_HEADERSIZE)
    1055             lpBand->cxHeader = lprbbi->cxHeader;
     1049        if (lprbbi->fMask & RBBIM_IDEALSIZE)
     1050            lpBand->cxIdeal = lprbbi->cxIdeal;
     1051
     1052        if (lprbbi->fMask & RBBIM_LPARAM)
     1053            lpBand->lParam = lprbbi->lParam;
     1054
     1055        if (lprbbi->fMask & RBBIM_HEADERSIZE)
     1056            lpBand->cxHeader = lprbbi->cxHeader;
    10561057    }
    10571058
     
    10741075
    10751076    if (infoPtr == NULL)
    1076         return FALSE;
     1077        return FALSE;
    10771078    if (lprbbi == NULL)
    1078         return FALSE;
     1079        return FALSE;
    10791080    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
    1080         return FALSE;
     1081        return FALSE;
    10811082
    10821083//    TRACE (rebar, "insert band at %u!\n", uIndex);
    10831084
    10841085    if (infoPtr->uNumBands == 0) {
    1085         infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
    1086         uIndex = 0;
     1086        infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
     1087        uIndex = 0;
    10871088    }
    10881089    else {
    1089         REBAR_BAND *oldBands = infoPtr->bands;
    1090         infoPtr->bands =
    1091             (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
    1092         if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
    1093             uIndex = infoPtr->uNumBands;
    1094 
    1095         /* pre insert copy */
    1096         if (uIndex > 0) {
    1097             memcpy (&infoPtr->bands[0], &oldBands[0],
    1098                     uIndex * sizeof(REBAR_BAND));
    1099         }
    1100 
    1101         /* post copy */
    1102         if (uIndex < infoPtr->uNumBands - 1) {
    1103             memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
    1104                     (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
    1105         }
    1106 
    1107         COMCTL32_Free (oldBands);
     1090        REBAR_BAND *oldBands = infoPtr->bands;
     1091        infoPtr->bands =
     1092            (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
     1093        if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
     1094            uIndex = infoPtr->uNumBands;
     1095
     1096        /* pre insert copy */
     1097        if (uIndex > 0) {
     1098            memcpy (&infoPtr->bands[0], &oldBands[0],
     1099                    uIndex * sizeof(REBAR_BAND));
     1100        }
     1101
     1102        /* post copy */
     1103        if (uIndex < infoPtr->uNumBands - 1) {
     1104            memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
     1105                    (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
     1106        }
     1107
     1108        COMCTL32_Free (oldBands);
    11081109    }
    11091110
     
    11161117
    11171118    if (lprbbi->fMask & RBBIM_STYLE)
    1118         lpBand->fStyle = lprbbi->fStyle;
     1119        lpBand->fStyle = lprbbi->fStyle;
    11191120
    11201121    if (lprbbi->fMask & RBBIM_COLORS) {
    1121         lpBand->clrFore = lprbbi->clrFore;
    1122         lpBand->clrBack = lprbbi->clrBack;
     1122        lpBand->clrFore = lprbbi->clrFore;
     1123        lpBand->clrBack = lprbbi->clrBack;
    11231124    }
    11241125    else {
    1125         lpBand->clrFore = CLR_NONE;
    1126         lpBand->clrBack = CLR_NONE;
     1126        lpBand->clrFore = CLR_NONE;
     1127        lpBand->clrBack = CLR_NONE;
    11271128    }
    11281129
    11291130    if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
    1130         INT len = lstrlenW (lprbbi->lpText);
    1131         if (len > 0) {
    1132             lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    1133             lstrcpyW (lpBand->lpText, lprbbi->lpText);
    1134         }
     1131        INT len = lstrlenW (lprbbi->lpText);
     1132        if (len > 0) {
     1133            lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     1134            lstrcpyW (lpBand->lpText, lprbbi->lpText);
     1135        }
    11351136    }
    11361137
    11371138    if (lprbbi->fMask & RBBIM_IMAGE)
    1138         lpBand->iImage = lprbbi->iImage;
     1139        lpBand->iImage = lprbbi->iImage;
    11391140    else
    1140         lpBand->iImage = -1;
     1141        lpBand->iImage = -1;
    11411142
    11421143    if (lprbbi->fMask & RBBIM_CHILD) {
    1143 //      TRACE (rebar, "hwndChild = %x\n", lprbbi->hwndChild);
    1144         lpBand->hwndChild = lprbbi->hwndChild;
    1145         lpBand->hwndPrevParent =
    1146             SetParent (lpBand->hwndChild, hwnd);
     1144//      TRACE (rebar, "hwndChild = %x\n", lprbbi->hwndChild);
     1145        lpBand->hwndChild = lprbbi->hwndChild;
     1146        lpBand->hwndPrevParent =
     1147            SetParent (lpBand->hwndChild, hwnd);
    11471148    }
    11481149
    11491150    if (lprbbi->fMask & RBBIM_CHILDSIZE) {
    1150         lpBand->cxMinChild = lprbbi->cxMinChild;
    1151         lpBand->cyMinChild = lprbbi->cyMinChild;
    1152         lpBand->cyMaxChild = lprbbi->cyMaxChild;
    1153         lpBand->cyChild    = lprbbi->cyChild;
    1154         lpBand->cyIntegral = lprbbi->cyIntegral;
     1151        lpBand->cxMinChild = lprbbi->cxMinChild;
     1152        lpBand->cyMinChild = lprbbi->cyMinChild;
     1153        lpBand->cyMaxChild = lprbbi->cyMaxChild;
     1154        lpBand->cyChild    = lprbbi->cyChild;
     1155        lpBand->cyIntegral = lprbbi->cyIntegral;
    11551156    }
    11561157    else {
    1157         lpBand->cxMinChild = -1;
    1158         lpBand->cyMinChild = -1;
    1159         lpBand->cyMaxChild = -1;
    1160         lpBand->cyChild    = -1;
    1161         lpBand->cyIntegral = -1;
     1158        lpBand->cxMinChild = -1;
     1159        lpBand->cyMinChild = -1;
     1160        lpBand->cyMaxChild = -1;
     1161        lpBand->cyChild    = -1;
     1162        lpBand->cyIntegral = -1;
    11621163    }
    11631164
    11641165    if (lprbbi->fMask & RBBIM_SIZE)
    1165         lpBand->cx = lprbbi->cx;
     1166        lpBand->cx = lprbbi->cx;
    11661167    else
    1167         lpBand->cx = -1;
     1168        lpBand->cx = -1;
    11681169
    11691170    if (lprbbi->fMask & RBBIM_BACKGROUND)
    1170         lpBand->hbmBack = lprbbi->hbmBack;
     1171        lpBand->hbmBack = lprbbi->hbmBack;
    11711172
    11721173    if (lprbbi->fMask & RBBIM_ID)
    1173         lpBand->wID = lprbbi->wID;
     1174        lpBand->wID = lprbbi->wID;
    11741175
    11751176    /* check for additional data */
    11761177    if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
    1177         if (lprbbi->fMask & RBBIM_IDEALSIZE)
    1178             lpBand->cxIdeal = lprbbi->cxIdeal;
    1179 
    1180         if (lprbbi->fMask & RBBIM_LPARAM)
    1181             lpBand->lParam = lprbbi->lParam;
    1182 
    1183         if (lprbbi->fMask & RBBIM_HEADERSIZE)
    1184             lpBand->cxHeader = lprbbi->cxHeader;
     1178        if (lprbbi->fMask & RBBIM_IDEALSIZE)
     1179            lpBand->cxIdeal = lprbbi->cxIdeal;
     1180
     1181        if (lprbbi->fMask & RBBIM_LPARAM)
     1182            lpBand->lParam = lprbbi->lParam;
     1183
     1184        if (lprbbi->fMask & RBBIM_HEADERSIZE)
     1185            lpBand->cxHeader = lprbbi->cxHeader;
    11851186    }
    11861187
     
    12001201
    12011202//    FIXME (rebar, "(uBand = %u fIdeal = %s)\n",
    1202 //         (UINT)wParam, lParam ? "TRUE" : "FALSE");
    1203 
    1204  
     1203//         (UINT)wParam, lParam ? "TRUE" : "FALSE");
     1204
     1205
    12051206    return 0;
    12061207}
     
    12141215//    FIXME (rebar, "(uBand = %u)\n", (UINT)wParam);
    12151216
    1216  
     1217
    12171218    return 0;
    12181219}
     
    12251226
    12261227//    FIXME (rebar, "(iFrom = %u iTof = %u)\n",
    1227 //         (UINT)wParam, (UINT)lParam);
    1228 
    1229  
     1228//         (UINT)wParam, (UINT)lParam);
     1229
     1230
    12301231    return FALSE;
    12311232}
     
    12401241
    12411242    if (lprbbi == NULL)
    1242         return FALSE;
     1243        return FALSE;
    12431244    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
    1244         return FALSE;
     1245        return FALSE;
    12451246    if ((UINT)wParam >= infoPtr->uNumBands)
    1246         return FALSE;
     1247        return FALSE;
    12471248
    12481249//    TRACE (rebar, "index %u\n", (UINT)wParam);
     
    12521253
    12531254    if (lprbbi->fMask & RBBIM_STYLE)
    1254         lpBand->fStyle = lprbbi->fStyle;
     1255        lpBand->fStyle = lprbbi->fStyle;
    12551256
    12561257    if (lprbbi->fMask & RBBIM_COLORS) {
    1257         lpBand->clrFore = lprbbi->clrFore;
    1258         lpBand->clrBack = lprbbi->clrBack;
     1258        lpBand->clrFore = lprbbi->clrFore;
     1259        lpBand->clrBack = lprbbi->clrBack;
    12591260    }
    12601261
    12611262    if (lprbbi->fMask & RBBIM_TEXT) {
    1262         if (lpBand->lpText) {
    1263             COMCTL32_Free (lpBand->lpText);
    1264             lpBand->lpText = NULL;
    1265         }
    1266         if (lprbbi->lpText) {
    1267             INT len = lstrlenA (lprbbi->lpText);
    1268             lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    1269             lstrcpyAtoW (lpBand->lpText, lprbbi->lpText);
    1270         }
     1263        if (lpBand->lpText) {
     1264            COMCTL32_Free (lpBand->lpText);
     1265            lpBand->lpText = NULL;
     1266        }
     1267        if (lprbbi->lpText) {
     1268            INT len = lstrlenA (lprbbi->lpText);
     1269            lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     1270            lstrcpyAtoW (lpBand->lpText, lprbbi->lpText);
     1271        }
    12711272    }
    12721273
    12731274    if (lprbbi->fMask & RBBIM_IMAGE)
    1274         lpBand->iImage = lprbbi->iImage;
     1275        lpBand->iImage = lprbbi->iImage;
    12751276
    12761277    if (lprbbi->fMask & RBBIM_CHILD) {
    1277         if (lprbbi->hwndChild) {
    1278             lpBand->hwndChild = lprbbi->hwndChild;
    1279             lpBand->hwndPrevParent =
    1280                 SetParent (lpBand->hwndChild, hwnd);
    1281         }
    1282         else {
    1283 //          TRACE (rebar, "child: 0x%x  prev parent: 0x%x\n",
    1284 //                 lpBand->hwndChild, lpBand->hwndPrevParent);
    1285             lpBand->hwndChild = 0;
    1286             lpBand->hwndPrevParent = 0;
    1287         }
     1278        if (lprbbi->hwndChild) {
     1279            lpBand->hwndChild = lprbbi->hwndChild;
     1280            lpBand->hwndPrevParent =
     1281                SetParent (lpBand->hwndChild, hwnd);
     1282        }
     1283        else {
     1284//          TRACE (rebar, "child: 0x%x  prev parent: 0x%x\n",
     1285//                 lpBand->hwndChild, lpBand->hwndPrevParent);
     1286            lpBand->hwndChild = 0;
     1287            lpBand->hwndPrevParent = 0;
     1288        }
    12881289    }
    12891290
    12901291    if (lprbbi->fMask & RBBIM_CHILDSIZE) {
    1291         lpBand->cxMinChild = lprbbi->cxMinChild;
    1292         lpBand->cyMinChild = lprbbi->cyMinChild;
    1293         lpBand->cyMaxChild = lprbbi->cyMaxChild;
    1294         lpBand->cyChild    = lprbbi->cyChild;
    1295         lpBand->cyIntegral = lprbbi->cyIntegral;
     1292        lpBand->cxMinChild = lprbbi->cxMinChild;
     1293        lpBand->cyMinChild = lprbbi->cyMinChild;
     1294        lpBand->cyMaxChild = lprbbi->cyMaxChild;
     1295        lpBand->cyChild    = lprbbi->cyChild;
     1296        lpBand->cyIntegral = lprbbi->cyIntegral;
    12961297    }
    12971298
    12981299    if (lprbbi->fMask & RBBIM_SIZE)
    1299         lpBand->cx = lprbbi->cx;
     1300        lpBand->cx = lprbbi->cx;
    13001301
    13011302    if (lprbbi->fMask & RBBIM_BACKGROUND)
    1302         lpBand->hbmBack = lprbbi->hbmBack;
     1303        lpBand->hbmBack = lprbbi->hbmBack;
    13031304
    13041305    if (lprbbi->fMask & RBBIM_ID)
    1305         lpBand->wID = lprbbi->wID;
     1306        lpBand->wID = lprbbi->wID;
    13061307
    13071308    /* check for additional data */
    13081309    if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
    1309         if (lprbbi->fMask & RBBIM_IDEALSIZE)
    1310             lpBand->cxIdeal = lprbbi->cxIdeal;
    1311 
    1312         if (lprbbi->fMask & RBBIM_LPARAM)
    1313             lpBand->lParam = lprbbi->lParam;
    1314 
    1315         if (lprbbi->fMask & RBBIM_HEADERSIZE)
    1316             lpBand->cxHeader = lprbbi->cxHeader;
     1310        if (lprbbi->fMask & RBBIM_IDEALSIZE)
     1311            lpBand->cxIdeal = lprbbi->cxIdeal;
     1312
     1313        if (lprbbi->fMask & RBBIM_LPARAM)
     1314            lpBand->lParam = lprbbi->lParam;
     1315
     1316        if (lprbbi->fMask & RBBIM_HEADERSIZE)
     1317            lpBand->cxHeader = lprbbi->cxHeader;
    13171318    }
    13181319
     
    13331334
    13341335    if (lprbbi == NULL)
    1335         return FALSE;
     1336        return FALSE;
    13361337    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
    1337         return FALSE;
     1338        return FALSE;
    13381339    if ((UINT)wParam >= infoPtr->uNumBands)
    1339         return FALSE;
     1340        return FALSE;
    13401341
    13411342//    TRACE (rebar, "index %u\n", (UINT)wParam);
     
    13451346
    13461347    if (lprbbi->fMask & RBBIM_STYLE)
    1347         lpBand->fStyle = lprbbi->fStyle;
     1348        lpBand->fStyle = lprbbi->fStyle;
    13481349
    13491350    if (lprbbi->fMask & RBBIM_COLORS) {
    1350         lpBand->clrFore = lprbbi->clrFore;
    1351         lpBand->clrBack = lprbbi->clrBack;
     1351        lpBand->clrFore = lprbbi->clrFore;
     1352        lpBand->clrBack = lprbbi->clrBack;
    13521353    }
    13531354
    13541355    if (lprbbi->fMask & RBBIM_TEXT) {
    1355         if (lpBand->lpText) {
    1356             COMCTL32_Free (lpBand->lpText);
    1357             lpBand->lpText = NULL;
    1358         }
    1359         if (lprbbi->lpText) {
    1360             INT len = lstrlenW (lprbbi->lpText);
    1361             lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    1362             lstrcpyW (lpBand->lpText, lprbbi->lpText);
    1363         }
     1356        if (lpBand->lpText) {
     1357            COMCTL32_Free (lpBand->lpText);
     1358            lpBand->lpText = NULL;
     1359        }
     1360        if (lprbbi->lpText) {
     1361            INT len = lstrlenW (lprbbi->lpText);
     1362            lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     1363            lstrcpyW (lpBand->lpText, lprbbi->lpText);
     1364        }
    13641365    }
    13651366
    13661367    if (lprbbi->fMask & RBBIM_IMAGE)
    1367         lpBand->iImage = lprbbi->iImage;
     1368        lpBand->iImage = lprbbi->iImage;
    13681369
    13691370    if (lprbbi->fMask & RBBIM_CHILD) {
    1370         if (lprbbi->hwndChild) {
    1371             lpBand->hwndChild = lprbbi->hwndChild;
    1372             lpBand->hwndPrevParent =
    1373                 SetParent (lpBand->hwndChild, hwnd);
    1374         }
    1375         else {
    1376 //          TRACE (rebar, "child: 0x%x  prev parent: 0x%x\n",
    1377 //                 lpBand->hwndChild, lpBand->hwndPrevParent);
    1378             lpBand->hwndChild = 0;
    1379             lpBand->hwndPrevParent = 0;
    1380         }
     1371        if (lprbbi->hwndChild) {
     1372            lpBand->hwndChild = lprbbi->hwndChild;
     1373            lpBand->hwndPrevParent =
     1374                SetParent (lpBand->hwndChild, hwnd);
     1375        }
     1376        else {
     1377//          TRACE (rebar, "child: 0x%x  prev parent: 0x%x\n",
     1378//                 lpBand->hwndChild, lpBand->hwndPrevParent);
     1379            lpBand->hwndChild = 0;
     1380            lpBand->hwndPrevParent = 0;
     1381        }
    13811382    }
    13821383
    13831384    if (lprbbi->fMask & RBBIM_CHILDSIZE) {
    1384         lpBand->cxMinChild = lprbbi->cxMinChild;
    1385         lpBand->cyMinChild = lprbbi->cyMinChild;
    1386         lpBand->cyMaxChild = lprbbi->cyMaxChild;
    1387         lpBand->cyChild    = lprbbi->cyChild;
    1388         lpBand->cyIntegral = lprbbi->cyIntegral;
     1385        lpBand->cxMinChild = lprbbi->cxMinChild;
     1386        lpBand->cyMinChild = lprbbi->cyMinChild;
     1387        lpBand->cyMaxChild = lprbbi->cyMaxChild;
     1388        lpBand->cyChild    = lprbbi->cyChild;
     1389        lpBand->cyIntegral = lprbbi->cyIntegral;
    13891390    }
    13901391
    13911392    if (lprbbi->fMask & RBBIM_SIZE)
    1392         lpBand->cx = lprbbi->cx;
     1393        lpBand->cx = lprbbi->cx;
    13931394
    13941395    if (lprbbi->fMask & RBBIM_BACKGROUND)
    1395         lpBand->hbmBack = lprbbi->hbmBack;
     1396        lpBand->hbmBack = lprbbi->hbmBack;
    13961397
    13971398    if (lprbbi->fMask & RBBIM_ID)
    1398         lpBand->wID = lprbbi->wID;
     1399        lpBand->wID = lprbbi->wID;
    13991400
    14001401    /* check for additional data */
    14011402    if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
    1402         if (lprbbi->fMask & RBBIM_IDEALSIZE)
    1403             lpBand->cxIdeal = lprbbi->cxIdeal;
    1404 
    1405         if (lprbbi->fMask & RBBIM_LPARAM)
    1406             lpBand->lParam = lprbbi->lParam;
    1407 
    1408         if (lprbbi->fMask & RBBIM_HEADERSIZE)
    1409             lpBand->cxHeader = lprbbi->cxHeader;
     1403        if (lprbbi->fMask & RBBIM_IDEALSIZE)
     1404            lpBand->cxIdeal = lprbbi->cxIdeal;
     1405
     1406        if (lprbbi->fMask & RBBIM_LPARAM)
     1407            lpBand->lParam = lprbbi->lParam;
     1408
     1409        if (lprbbi->fMask & RBBIM_HEADERSIZE)
     1410            lpBand->cxHeader = lprbbi->cxHeader;
    14101411    }
    14111412
     
    14251426
    14261427    if (lpInfo == NULL)
    1427         return FALSE;
     1428        return FALSE;
    14281429
    14291430    if (lpInfo->cbSize < sizeof (REBARINFO))
    1430         return FALSE;
     1431        return FALSE;
    14311432
    14321433//    TRACE (rebar, "setting bar info!\n");
    14331434
    14341435    if (lpInfo->fMask & RBIM_IMAGELIST) {
    1435         infoPtr->himl = lpInfo->himl;
    1436         if (infoPtr->himl) {
    1437             ImageList_GetIconSize (infoPtr->himl, &infoPtr->imageSize.cx,
    1438                                    &infoPtr->imageSize.cy);
    1439         }
    1440         else {
    1441             infoPtr->imageSize.cx = 0;
    1442             infoPtr->imageSize.cy = 0;
    1443         }
     1436        infoPtr->himl = lpInfo->himl;
     1437        if (infoPtr->himl) {
     1438            ImageList_GetIconSize (infoPtr->himl, &infoPtr->imageSize.cx,
     1439                                   &infoPtr->imageSize.cy);
     1440        }
     1441        else {
     1442            infoPtr->imageSize.cx = 0;
     1443            infoPtr->imageSize.cy = 0;
     1444        }
    14441445    }
    14451446
     
    15141515
    15151516    if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
    1516         return FALSE;
     1517        return FALSE;
    15171518
    15181519    lpBand = &infoPtr->bands[(INT)wParam];
    15191520
    15201521    if ((BOOL)lParam) {
    1521 //      TRACE (rebar, "show band %d\n", (INT)wParam);
    1522         lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
    1523         if (IsWindow (lpBand->hwndChild))
    1524             ShowWindow (lpBand->hwndChild, SW_SHOW);
     1522//      TRACE (rebar, "show band %d\n", (INT)wParam);
     1523        lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
     1524        if (IsWindow (lpBand->hwndChild))
     1525            ShowWindow (lpBand->hwndChild, SW_SHOW);
    15251526    }
    15261527    else {
    1527 //      TRACE (rebar, "hide band %d\n", (INT)wParam);
    1528         lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
    1529         if (IsWindow (lpBand->hwndChild))
    1530             ShowWindow (lpBand->hwndChild, SW_SHOW);
     1528//      TRACE (rebar, "hide band %d\n", (INT)wParam);
     1529        lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
     1530        if (IsWindow (lpBand->hwndChild))
     1531            ShowWindow (lpBand->hwndChild, SW_SHOW);
    15311532    }
    15321533
     
    15461547
    15471548    if (lpRect == NULL)
    1548         return FALSE;
     1549        return FALSE;
    15491550
    15501551//    FIXME (rebar, "layout change not implemented!\n");
    15511552//    FIXME (rebar, "[%d %d %d %d]\n",
    1552 //         lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
     1553//         lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
    15531554
    15541555#if 0
    15551556    SetWindowPos (hwnd, 0, lpRect->left, lpRect->top,
    1556                     lpRect->right - lpRect->left, lpRect->bottom - lpRect->top,
    1557                     SWP_NOZORDER);
     1557                    lpRect->right - lpRect->left, lpRect->bottom - lpRect->top,
     1558                    SWP_NOZORDER);
    15581559#endif
    15591560
     
    15891590
    15901591//    if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_AUTOSIZE)
    1591 //      FIXME (rebar, "style RBS_AUTOSIZE set!\n");
     1592//      FIXME (rebar, "style RBS_AUTOSIZE set!\n");
    15921593
    15931594#if 0
     
    16101611    /* free rebar bands */
    16111612    if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
    1612         /* clean up each band */
    1613         for (i = 0; i < infoPtr->uNumBands; i++) {
    1614             lpBand = &infoPtr->bands[i];
    1615 
    1616             /* delete text strings */
    1617             if (lpBand->lpText) {
    1618                 COMCTL32_Free (lpBand->lpText);
    1619                 lpBand->lpText = NULL;
    1620             }
    1621             /* destroy child window */
    1622             DestroyWindow (lpBand->hwndChild);
    1623         }
    1624 
    1625         /* free band array */
    1626         COMCTL32_Free (infoPtr->bands);
    1627         infoPtr->bands = NULL;
     1613        /* clean up each band */
     1614        for (i = 0; i < infoPtr->uNumBands; i++) {
     1615            lpBand = &infoPtr->bands[i];
     1616
     1617            /* delete text strings */
     1618            if (lpBand->lpText) {
     1619                COMCTL32_Free (lpBand->lpText);
     1620                lpBand->lpText = NULL;
     1621            }
     1622            /* destroy child window */
     1623            DestroyWindow (lpBand->hwndChild);
     1624        }
     1625
     1626        /* free band array */
     1627        COMCTL32_Free (infoPtr->bands);
     1628        infoPtr->bands = NULL;
    16281629    }
    16291630
     
    16711672{
    16721673    if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER) {
    1673         ((LPRECT)lParam)->left   += GetSystemMetrics(SM_CXEDGE);
    1674         ((LPRECT)lParam)->top    += GetSystemMetrics(SM_CYEDGE);
    1675         ((LPRECT)lParam)->right  -= GetSystemMetrics(SM_CXEDGE);
    1676         ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE);
     1674        ((LPRECT)lParam)->left   += GetSystemMetrics(SM_CXEDGE);
     1675        ((LPRECT)lParam)->top    += GetSystemMetrics(SM_CYEDGE);
     1676        ((LPRECT)lParam)->right  -= GetSystemMetrics(SM_CXEDGE);
     1677        ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE);
    16771678    }
    16781679
     
    16891690
    16901691    if (dwStyle & WS_MINIMIZE)
    1691         return 0; /* Nothing to do */
     1692        return 0; /* Nothing to do */
    16921693
    16931694    DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
    16941695
    16951696    if (!(hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW )))
    1696         return 0;
     1697        return 0;
    16971698
    16981699    if (dwStyle & WS_BORDER) {
    1699         GetWindowRect (hwnd, &rcWindow);
    1700         OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
    1701         DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
     1700        GetWindowRect (hwnd, &rcWindow);
     1701        OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
     1702        DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
    17021703    }
    17031704
     
    17171718    REBAR_Refresh (hwnd, hdc);
    17181719    if (!wParam)
    1719         EndPaint (hwnd, &ps);
     1720        EndPaint (hwnd, &ps);
    17201721    return 0;
    17211722}
     
    17381739
    17391740    if (flags == RBHT_GRABBER) {
    1740         if ((dwStyle & CCS_VERT) &&
    1741             !(dwStyle & RBS_VERTICALGRIPPER))
    1742             SetCursor (infoPtr->hcurVert);
    1743         else
    1744             SetCursor (infoPtr->hcurHorz);
     1741        if ((dwStyle & CCS_VERT) &&
     1742            !(dwStyle & RBS_VERTICALGRIPPER))
     1743            SetCursor (infoPtr->hcurVert);
     1744        else
     1745            SetCursor (infoPtr->hcurHorz);
    17451746    }
    17461747    else if (flags != RBHT_CLIENT)
    1747         SetCursor (infoPtr->hcurArrow);
     1748        SetCursor (infoPtr->hcurArrow);
    17481749
    17491750    return 0;
     
    17551756{
    17561757    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    1757    
     1758
    17581759    /* TEXTMETRIC32A tm; */
    17591760    HFONT hFont /*, hOldFont */;
     
    17931794    /* auto resize deadlock check */
    17941795    if (infoPtr->bAutoResize) {
    1795         infoPtr->bAutoResize = FALSE;
    1796         return 0;
     1796        infoPtr->bAutoResize = FALSE;
     1797        return 0;
    17971798    }
    17981799
     
    18051806
    18061807    if (dwStyle & CCS_VERT) {
    1807         if (dwStyle & CCS_LEFT == CCS_LEFT) {
    1808             x = rcParent.left;
    1809             y = rcParent.top;
    1810             cx = infoPtr->calcSize.cx;
    1811             cy = infoPtr->calcSize.cy;
    1812         }
    1813         else {
    1814             x = rcParent.right - infoPtr->calcSize.cx;
    1815             y = rcParent.top;
    1816             cx = infoPtr->calcSize.cx;
    1817             cy = infoPtr->calcSize.cy;
    1818         }
     1808        if (dwStyle & CCS_LEFT == CCS_LEFT) {
     1809            x = rcParent.left;
     1810            y = rcParent.top;
     1811            cx = infoPtr->calcSize.cx;
     1812            cy = infoPtr->calcSize.cy;
     1813        }
     1814        else {
     1815            x = rcParent.right - infoPtr->calcSize.cx;
     1816            y = rcParent.top;
     1817            cx = infoPtr->calcSize.cx;
     1818            cy = infoPtr->calcSize.cy;
     1819        }
    18191820    }
    18201821    else {
    1821         if (dwStyle & CCS_TOP) {
    1822             x = rcParent.left;
    1823             y = rcParent.top;
    1824             cx = infoPtr->calcSize.cx;
    1825             cy = infoPtr->calcSize.cy;
    1826         }
    1827         else {
    1828             x = rcParent.left;
    1829             y = rcParent.bottom - infoPtr->calcSize.cy;
    1830             cx = infoPtr->calcSize.cx;
    1831             cy = infoPtr->calcSize.cy;
    1832         }
     1822        if (dwStyle & CCS_TOP) {
     1823            x = rcParent.left;
     1824            y = rcParent.top;
     1825            cx = infoPtr->calcSize.cx;
     1826            cy = infoPtr->calcSize.cy;
     1827        }
     1828        else {
     1829            x = rcParent.left;
     1830            y = rcParent.bottom - infoPtr->calcSize.cy;
     1831            cx = infoPtr->calcSize.cx;
     1832            cy = infoPtr->calcSize.cy;
     1833        }
    18331834    }
    18341835
    18351836    SetWindowPos32 (hwnd, 0, x, y, cx, cy,
    1836                     SWP_NOZORDER | SWP_SHOWWINDOW);
     1837                    SWP_NOZORDER | SWP_SHOWWINDOW);
    18371838*/
    18381839    REBAR_Layout (hwnd, NULL);
     
    18491850    switch (uMsg)
    18501851    {
    1851 /*      case RB_BEGINDRAG: */
    1852 
    1853         case RB_DELETEBAND:
    1854             return REBAR_DeleteBand (hwnd, wParam, lParam);
    1855 
    1856 /*      case RB_DRAGMOVE: */
    1857 /*      case RB_ENDDRAG: */
    1858 
    1859         case RB_GETBANDBORDERS:
    1860             return REBAR_GetBandBorders (hwnd, wParam, lParam);
    1861 
    1862         case RB_GETBANDCOUNT:
    1863             return REBAR_GetBandCount (hwnd);
    1864 
    1865 /*      case RB_GETBANDINFO32:  */ /* outdated, just for compatibility */
    1866 
    1867         case RB_GETBANDINFOA:
    1868             return REBAR_GetBandInfoA (hwnd, wParam, lParam);
    1869 
    1870         case RB_GETBANDINFOW:
    1871             return REBAR_GetBandInfoW (hwnd, wParam, lParam);
    1872 
    1873         case RB_GETBARHEIGHT:
    1874             return REBAR_GetBarHeight (hwnd, wParam, lParam);
    1875 
    1876         case RB_GETBARINFO:
    1877             return REBAR_GetBarInfo (hwnd, wParam, lParam);
    1878 
    1879         case RB_GETBKCOLOR:
    1880             return REBAR_GetBkColor (hwnd);
    1881 
    1882 /*      case RB_GETCOLORSCHEME: */
    1883 /*      case RB_GETDROPTARGET: */
    1884 
    1885         case RB_GETPALETTE:
    1886             return REBAR_GetPalette (hwnd, wParam, lParam);
    1887 
    1888         case RB_GETRECT:
    1889             return REBAR_GetRect (hwnd, wParam, lParam);
    1890 
    1891         case RB_GETROWCOUNT:
    1892             return REBAR_GetRowCount (hwnd);
    1893 
    1894         case RB_GETROWHEIGHT:
    1895             return REBAR_GetRowHeight (hwnd, wParam, lParam);
    1896 
    1897         case RB_GETTEXTCOLOR:
    1898             return REBAR_GetTextColor (hwnd);
    1899 
    1900         case RB_GETTOOLTIPS:
    1901             return REBAR_GetToolTips (hwnd);
    1902 
    1903         case RB_GETUNICODEFORMAT:
    1904             return REBAR_GetUnicodeFormat (hwnd);
    1905 
    1906         case RB_HITTEST:
    1907             return REBAR_HitTest (hwnd, wParam, lParam);
    1908 
    1909         case RB_IDTOINDEX:
    1910             return REBAR_IdToIndex (hwnd, wParam, lParam);
    1911 
    1912         case RB_INSERTBANDA:
    1913             return REBAR_InsertBandA (hwnd, wParam, lParam);
    1914 
    1915         case RB_INSERTBANDW:
    1916             return REBAR_InsertBandW (hwnd, wParam, lParam);
    1917 
    1918         case RB_MAXIMIZEBAND:
    1919             return REBAR_MaximizeBand (hwnd, wParam, lParam);
    1920 
    1921         case RB_MINIMIZEBAND:
    1922             return REBAR_MinimizeBand (hwnd, wParam, lParam);
    1923 
    1924         case RB_MOVEBAND:
    1925             return REBAR_MoveBand (hwnd, wParam, lParam);
    1926 
    1927         case RB_SETBANDINFOA:
    1928             return REBAR_SetBandInfoA (hwnd, wParam, lParam);
    1929 
    1930         case RB_SETBANDINFOW:
    1931             return REBAR_SetBandInfoW (hwnd, wParam, lParam);
    1932 
    1933         case RB_SETBARINFO:
    1934             return REBAR_SetBarInfo (hwnd, wParam, lParam);
    1935 
    1936         case RB_SETBKCOLOR:
    1937             return REBAR_SetBkColor (hwnd, wParam, lParam);
    1938 
    1939 /*      case RB_SETCOLORSCHEME: */
    1940 /*      case RB_SETPALETTE: */
    1941 /*          return REBAR_GetPalette (hwnd, wParam, lParam); */
    1942 
    1943         case RB_SETPARENT:
    1944             return REBAR_SetParent (hwnd, wParam, lParam);
    1945 
    1946         case RB_SETTEXTCOLOR:
    1947             return REBAR_SetTextColor (hwnd, wParam, lParam);
    1948 
    1949 /*      case RB_SETTOOLTIPS: */
    1950 
    1951         case RB_SETUNICODEFORMAT:
    1952             return REBAR_SetUnicodeFormat (hwnd, wParam);
    1953 
    1954         case RB_SHOWBAND:
    1955             return REBAR_ShowBand (hwnd, wParam, lParam);
    1956 
    1957         case RB_SIZETORECT:
    1958             return REBAR_SizeToRect (hwnd, wParam, lParam);
    1959 
    1960 
    1961         case WM_COMMAND:
    1962             return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
    1963 
    1964         case WM_CREATE:
    1965             return REBAR_Create (hwnd, wParam, lParam);
    1966 
    1967         case WM_DESTROY:
    1968             return REBAR_Destroy (hwnd, wParam, lParam);
    1969 
    1970         case WM_GETFONT:
    1971             return REBAR_GetFont (hwnd, wParam, lParam);
    1972 
    1973 /*      case WM_MOUSEMOVE: */
    1974 /*          return REBAR_MouseMove (hwnd, wParam, lParam); */
    1975 
    1976         case WM_NCCALCSIZE:
    1977             return REBAR_NCCalcSize (hwnd, wParam, lParam);
    1978 
    1979         case WM_NCPAINT:
    1980             return REBAR_NCPaint (hwnd, wParam, lParam);
    1981 
    1982         case WM_NOTIFY:
    1983             return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
    1984 
    1985         case WM_PAINT:
    1986             return REBAR_Paint (hwnd, wParam);
    1987 
    1988         case WM_SETCURSOR:
    1989             return REBAR_SetCursor (hwnd, wParam, lParam);
    1990 
    1991         case WM_SETFONT:
    1992             return REBAR_SetFont (hwnd, wParam, lParam);
    1993 
    1994         case WM_SIZE:
    1995             return REBAR_Size (hwnd, wParam, lParam);
    1996 
    1997 /*      case WM_TIMER: */
    1998 
    1999 /*      case WM_WININICHANGE: */
    2000 
    2001         default:
    2002 //          if (uMsg >= WM_USER)
    2003 //              ERR (rebar, "unknown msg %04x wp=%08x lp=%08lx\n",
    2004 //                   uMsg, wParam, lParam);
    2005             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     1852/*      case RB_BEGINDRAG: */
     1853
     1854        case RB_DELETEBAND:
     1855            return REBAR_DeleteBand (hwnd, wParam, lParam);
     1856
     1857/*      case RB_DRAGMOVE: */
     1858/*      case RB_ENDDRAG: */
     1859
     1860        case RB_GETBANDBORDERS:
     1861            return REBAR_GetBandBorders (hwnd, wParam, lParam);
     1862
     1863        case RB_GETBANDCOUNT:
     1864            return REBAR_GetBandCount (hwnd);
     1865
     1866/*      case RB_GETBANDINFO32:  */ /* outdated, just for compatibility */
     1867
     1868        case RB_GETBANDINFOA:
     1869            return REBAR_GetBandInfoA (hwnd, wParam, lParam);
     1870
     1871        case RB_GETBANDINFOW:
     1872            return REBAR_GetBandInfoW (hwnd, wParam, lParam);
     1873
     1874        case RB_GETBARHEIGHT:
     1875            return REBAR_GetBarHeight (hwnd, wParam, lParam);
     1876
     1877        case RB_GETBARINFO:
     1878            return REBAR_GetBarInfo (hwnd, wParam, lParam);
     1879
     1880        case RB_GETBKCOLOR:
     1881            return REBAR_GetBkColor (hwnd);
     1882
     1883/*      case RB_GETCOLORSCHEME: */
     1884/*      case RB_GETDROPTARGET: */
     1885
     1886        case RB_GETPALETTE:
     1887            return REBAR_GetPalette (hwnd, wParam, lParam);
     1888
     1889        case RB_GETRECT:
     1890            return REBAR_GetRect (hwnd, wParam, lParam);
     1891
     1892        case RB_GETROWCOUNT:
     1893            return REBAR_GetRowCount (hwnd);
     1894
     1895        case RB_GETROWHEIGHT:
     1896            return REBAR_GetRowHeight (hwnd, wParam, lParam);
     1897
     1898        case RB_GETTEXTCOLOR:
     1899            return REBAR_GetTextColor (hwnd);
     1900
     1901        case RB_GETTOOLTIPS:
     1902            return REBAR_GetToolTips (hwnd);
     1903
     1904        case RB_GETUNICODEFORMAT:
     1905            return REBAR_GetUnicodeFormat (hwnd);
     1906
     1907        case RB_HITTEST:
     1908            return REBAR_HitTest (hwnd, wParam, lParam);
     1909
     1910        case RB_IDTOINDEX:
     1911            return REBAR_IdToIndex (hwnd, wParam, lParam);
     1912
     1913        case RB_INSERTBANDA:
     1914            return REBAR_InsertBandA (hwnd, wParam, lParam);
     1915
     1916        case RB_INSERTBANDW:
     1917            return REBAR_InsertBandW (hwnd, wParam, lParam);
     1918
     1919        case RB_MAXIMIZEBAND:
     1920            return REBAR_MaximizeBand (hwnd, wParam, lParam);
     1921
     1922        case RB_MINIMIZEBAND:
     1923            return REBAR_MinimizeBand (hwnd, wParam, lParam);
     1924
     1925        case RB_MOVEBAND:
     1926            return REBAR_MoveBand (hwnd, wParam, lParam);
     1927
     1928        case RB_SETBANDINFOA:
     1929            return REBAR_SetBandInfoA (hwnd, wParam, lParam);
     1930
     1931        case RB_SETBANDINFOW:
     1932            return REBAR_SetBandInfoW (hwnd, wParam, lParam);
     1933
     1934        case RB_SETBARINFO:
     1935            return REBAR_SetBarInfo (hwnd, wParam, lParam);
     1936
     1937        case RB_SETBKCOLOR:
     1938            return REBAR_SetBkColor (hwnd, wParam, lParam);
     1939
     1940/*      case RB_SETCOLORSCHEME: */
     1941/*      case RB_SETPALETTE: */
     1942/*          return REBAR_GetPalette (hwnd, wParam, lParam); */
     1943
     1944        case RB_SETPARENT:
     1945            return REBAR_SetParent (hwnd, wParam, lParam);
     1946
     1947        case RB_SETTEXTCOLOR:
     1948            return REBAR_SetTextColor (hwnd, wParam, lParam);
     1949
     1950/*      case RB_SETTOOLTIPS: */
     1951
     1952        case RB_SETUNICODEFORMAT:
     1953            return REBAR_SetUnicodeFormat (hwnd, wParam);
     1954
     1955        case RB_SHOWBAND:
     1956            return REBAR_ShowBand (hwnd, wParam, lParam);
     1957
     1958        case RB_SIZETORECT:
     1959            return REBAR_SizeToRect (hwnd, wParam, lParam);
     1960
     1961
     1962        case WM_COMMAND:
     1963            return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
     1964
     1965        case WM_CREATE:
     1966            return REBAR_Create (hwnd, wParam, lParam);
     1967
     1968        case WM_DESTROY:
     1969            return REBAR_Destroy (hwnd, wParam, lParam);
     1970
     1971        case WM_GETFONT:
     1972            return REBAR_GetFont (hwnd, wParam, lParam);
     1973
     1974/*      case WM_MOUSEMOVE: */
     1975/*          return REBAR_MouseMove (hwnd, wParam, lParam); */
     1976
     1977        case WM_NCCALCSIZE:
     1978            return REBAR_NCCalcSize (hwnd, wParam, lParam);
     1979
     1980        case WM_NCPAINT:
     1981            return REBAR_NCPaint (hwnd, wParam, lParam);
     1982
     1983        case WM_NOTIFY:
     1984            return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
     1985
     1986        case WM_PAINT:
     1987            return REBAR_Paint (hwnd, wParam);
     1988
     1989        case WM_SETCURSOR:
     1990            return REBAR_SetCursor (hwnd, wParam, lParam);
     1991
     1992        case WM_SETFONT:
     1993            return REBAR_SetFont (hwnd, wParam, lParam);
     1994
     1995        case WM_SIZE:
     1996            return REBAR_Size (hwnd, wParam, lParam);
     1997
     1998/*      case WM_TIMER: */
     1999
     2000/*      case WM_WININICHANGE: */
     2001
     2002        default:
     2003//          if (uMsg >= WM_USER)
     2004//              ERR (rebar, "unknown msg %04x wp=%08x lp=%08lx\n",
     2005//                   uMsg, wParam, lParam);
     2006            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    20062007    }
    20072008    return 0;
     
    20242025    wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
    20252026    wndClass.lpszClassName = REBARCLASSNAMEA;
    2026  
     2027
    20272028    RegisterClassA (&wndClass);
    20282029}
     
    20332034{
    20342035    if (GlobalFindAtomA (REBARCLASSNAMEA))
    2035         UnregisterClassA (REBARCLASSNAMEA, (HINSTANCE)NULL);
    2036 }
    2037 
     2036        UnregisterClassA (REBARCLASSNAMEA, (HINSTANCE)NULL);
     2037}
     2038
  • trunk/src/comctl32/status.c

    r164 r236  
    1 /* $Id: status.c,v 1.5 1999-06-23 19:45:01 achimha Exp $ */
     1/* $Id: status.c,v 1.6 1999-06-28 15:46:26 cbratschi Exp $ */
    22/*
    33 * Interface code to StatusWindow widget/control
     
    192192    else {
    193193        for (i = 0; i < infoPtr->numParts; i++) {
    194             if (infoPtr->parts[i].style & SBT_OWNERDRAW) {
     194            if (infoPtr->parts[i].style & SBT_OWNERDRAW) {
    195195                DRAWITEMSTRUCT dis;
    196196
     
    441441
    442442        if (ti.lpszText)
    443             lstrcpynA ((LPSTR)lParam, ti.lpszText, HIWORD(wParam));
     443            lstrcpynA ((LPSTR)lParam, ti.lpszText, MIN(HIWORD(wParam),lstrlenA(ti.lpszText)));
    444444    }
    445445
     
    461461
    462462        if (ti.lpszText)
    463             lstrcpynW ((LPWSTR)lParam, ti.lpszText, HIWORD(wParam));
     463            lstrcpynW ((LPWSTR)lParam, ti.lpszText, MIN(HIWORD(wParam),lstrlenW(ti.lpszText)));
    464464    }
    465465
     
    571571    if (oldNumParts > self->numParts) {
    572572        for (i = self->numParts ; i < oldNumParts; i++) {
    573             if (self->parts[i].text && !(self->parts[i].style & SBT_OWNERDRAW))
     573            if (self->parts[i].text && !(self->parts[i].style & SBT_OWNERDRAW))
    574574                COMCTL32_Free (self->parts[i].text);
    575575        }
     
    635635    STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
    636636    STATUSWINDOWPART *part;
    637     int part_num;
    638     int style;
     637    int part_num;
     638    int style;
    639639    LPSTR text;
    640     int len;
     640    int len;
    641641    HDC hdc;
    642642
     
    646646
    647647    if ((self->simple) || (self->parts==NULL) || (part_num==255))
    648         part = &self->part0;
     648        part = &self->part0;
    649649    else
    650         part = &self->parts[part_num];
     650        part = &self->parts[part_num];
    651651    if (!part) return FALSE;
    652652
    653653    if (!(part->style & SBT_OWNERDRAW) && part->text)
    654         COMCTL32_Free (part->text);
     654        COMCTL32_Free (part->text);
    655655    part->text = 0;
    656656
    657657    if (style & SBT_OWNERDRAW) {
    658         part->text = (LPWSTR)text;
     658        part->text = (LPWSTR)text;
    659659    }
    660660    else {
    661         /* duplicate string */
    662         if (text && (len = lstrlenA(text))) {
    663             part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    664             lstrcpyAtoW (part->text, text);
    665         }
     661        /* duplicate string */
     662        if (text && (len = lstrlenA(text))) {
     663            part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     664            lstrcpyAtoW (part->text, text);
     665        }
    666666    }
    667667    part->style = style;
     
    689689
    690690    if ((self->simple) || (self->parts==NULL) || (part_num==255))
    691         part = &self->part0;
     691        part = &self->part0;
    692692    else
    693         part = &self->parts[part_num];
     693        part = &self->parts[part_num];
    694694    if (!part) return FALSE;
    695695
    696696    if (!(part->style & SBT_OWNERDRAW) && part->text)
    697         COMCTL32_Free (part->text);
     697        COMCTL32_Free (part->text);
    698698    part->text = 0;
    699699
    700700    if (style & SBT_OWNERDRAW) {
    701         part->text = text;
     701        part->text = text;
    702702    }
    703703    else {
    704         /* duplicate string */
    705         if (text && (len = lstrlenW(text))) {
    706             part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    707             lstrcpyW(part->text, text);
    708         }
     704        /* duplicate string */
     705        if (text && (len = lstrlenW(text))) {
     706            part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     707            lstrcpyW(part->text, text);
     708        }
    709709    }
    710710    part->style = style;
     
    896896{
    897897    STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
    898     int i;
     898    int i;
    899899
    900900    for (i = 0; i < self->numParts; i++) {
    901         if (self->parts[i].text && !(self->parts[i].style & SBT_OWNERDRAW))
    902             COMCTL32_Free (self->parts[i].text);
     901        if (self->parts[i].text && !(self->parts[i].style & SBT_OWNERDRAW))
     902            COMCTL32_Free (self->parts[i].text);
    903903    }
    904904    if (self->part0.text && !(self->part0.style & SBT_OWNERDRAW))
    905         COMCTL32_Free (self->part0.text);
     905        COMCTL32_Free (self->part0.text);
    906906    COMCTL32_Free (self->parts);
    907907
    908908    /* delete default font */
    909909    if (self->hDefaultFont)
    910         DeleteObject (self->hDefaultFont);
     910        DeleteObject (self->hDefaultFont);
    911911
    912912    /* delete tool tip control */
    913913    if (self->hwndToolTip)
    914         DestroyWindow (self->hwndToolTip);
     914        DestroyWindow (self->hwndToolTip);
    915915
    916916    COMCTL32_Free (self);
  • trunk/src/comctl32/tab.c

    r164 r236  
    1 /* $Id: tab.c,v 1.5 1999-06-23 19:45:01 achimha Exp $ */
     1/* $Id: tab.c,v 1.6 1999-06-28 15:46:26 cbratschi Exp $ */
    22/*
    33 * Tab control
     
    77 * Copyright 1999 Francis Beaudet
    88 * Copyright 1999 Achim Hasenmueller
     9 * Copyright 1999 Christoph Bratschi
    910 *
    1011 * TODO:
     
    8384{
    8485    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    85  
     86
    8687    return infoPtr->iSelected;
    8788}
     
    9192{
    9293    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    93  
     94
    9495    return infoPtr->uFocus;
    9596}
     
    111112  INT iItem=(INT) wParam;
    112113  INT prevItem;
    113  
     114
    114115  prevItem=-1;
    115116  if ((iItem >= 0) && (iItem < infoPtr->uNumItem)) {
     
    125126  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    126127  INT iItem=(INT) wParam;
    127  
     128
    128129  if ((iItem < 0) || (iItem > infoPtr->uNumItem)) return 0;
    129130
     
    131132  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS) {
    132133//    FIXME (tab,"Should set input focus\n");
    133   } else { 
     134  } else {
    134135    if (infoPtr->iSelected != iItem) {
    135136      if (TAB_SendSimpleNotify(hwnd, TCN_SELCHANGING)!=TRUE)  {
     
    137138        TAB_SendSimpleNotify(hwnd, TCN_SELCHANGE);
    138139
    139         TAB_EnsureSelectionVisible(hwnd, infoPtr);
    140         TAB_InvalidateTabArea(hwnd, infoPtr);
     140        TAB_EnsureSelectionVisible(hwnd, infoPtr);
     141        TAB_InvalidateTabArea(hwnd, infoPtr);
    141142      }
    142143    }
     
    176177   * Perform a sanity check and a trivial visibility check.
    177178   */
    178   if ( (infoPtr->uNumItem <=0) ||
     179  if ( (infoPtr->uNumItem == 0) ||
    179180       (itemIndex >= infoPtr->uNumItem) ||
    180181       (itemIndex < infoPtr->leftmostVisible) )
     
    187188  if (itemRect==NULL)
    188189    itemRect = &tmpItemRect;
    189  
     190
    190191  /*
    191192   * Retrieve the unmodified item rect.
     
    194195
    195196  /*
    196    * "scroll" it to make sure the item at the very left of the 
     197   * "scroll" it to make sure the item at the very left of the
    197198   * tab control is the leftmost visible tab.
    198199   */
    199200  OffsetRect(itemRect,
    200              -infoPtr->items[infoPtr->leftmostVisible].rect.left,
    201              0);
    202 
    203   /*
    204    * Move the rectangle so the first item is slightly offset from 
     201             -infoPtr->items[infoPtr->leftmostVisible].rect.left,
     202             0);
     203
     204  /*
     205   * Move the rectangle so the first item is slightly offset from
    205206   * the left of the tab control.
    206207   */
    207208  OffsetRect(itemRect,
    208              SELECTED_TAB_OFFSET,
    209              0);
     209             SELECTED_TAB_OFFSET,
     210             0);
    210211
    211212
     
    225226     * If it also a bit higher.
    226227     */
    227     if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 
    228     {     
     228    if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM)
     229    {
    229230      selectedRect->top    -=2; /* the border is thicker on the bottom */
    230231      selectedRect->bottom +=SELECTED_TAB_OFFSET;
     
    242243static BOOL TAB_GetItemRect(HWND hwnd, WPARAM wParam, LPARAM lParam)
    243244{
    244   return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam, 
     245  return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam,
    245246                                 (LPRECT)lParam, (LPRECT)NULL);
    246247}
     
    252253 */
    253254static LRESULT TAB_KeyUp(
    254   HWND   hwnd, 
     255  HWND   hwnd,
    255256  WPARAM keyCode)
    256257{
     
    267268      break;
    268269  }
    269  
     270
    270271  /*
    271272   * If we changed to a valid item, change the selection
     
    296297 */
    297298static LRESULT TAB_FocusChanging(
    298   HWND   hwnd, 
    299   UINT   uMsg, 
    300   WPARAM wParam, 
     299  HWND   hwnd,
     300  UINT   uMsg,
     301  WPARAM wParam,
    301302  LPARAM lParam)
    302303{
     
    309310   */
    310311  isVisible = TAB_InternalGetItemRect(hwnd,
    311                                       infoPtr,
    312                                       infoPtr->uFocus,
    313                                       NULL,
    314                                       &selectedRect);
    315  
     312                                      infoPtr,
     313                                      infoPtr->uFocus,
     314                                      NULL,
     315                                      &selectedRect);
     316
    316317  /*
    317318   * If the rectangle is not completely invisible, invalidate that
     
    331332static HWND TAB_InternalHitTest (
    332333  HWND      hwnd,
    333   TAB_INFO* infoPtr, 
    334   POINT     pt, 
     334  TAB_INFO* infoPtr,
     335  POINT     pt,
    335336  UINT*     flags)
    336337
    337338{
    338339  RECT rect;
    339   int iCount; 
    340  
    341   for (iCount = 0; iCount < infoPtr->uNumItem; iCount++) 
     340  int iCount;
     341
     342  for (iCount = 0; iCount < infoPtr->uNumItem; iCount++)
    342343  {
    343344    TAB_InternalGetItemRect(hwnd,
    344                             infoPtr,
    345                             iCount,
    346                             &rect,
    347                             NULL);
     345                            infoPtr,
     346                            iCount,
     347                            &rect,
     348                            NULL);
    348349
    349350    if (PtInRect (&rect, pt))
     
    363364  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    364365  LPTCHITTESTINFO lptest=(LPTCHITTESTINFO) lParam;
    365  
     366
    366367  return TAB_InternalHitTest (hwnd, infoPtr,lptest->pt,&lptest->flags);
    367368}
     
    375376  if (infoPtr->hwndToolTip)
    376377    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    377                     WM_LBUTTONDOWN, wParam, lParam);
     378                    WM_LBUTTONDOWN, wParam, lParam);
    378379
    379380  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_FOCUSONBUTTONDOWN ) {
     
    389390  POINT pt;
    390391  INT newItem,dummy;
    391  
     392
    392393  if (infoPtr->hwndToolTip)
    393394    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    394                     WM_LBUTTONDOWN, wParam, lParam);
    395  
     395                    WM_LBUTTONDOWN, wParam, lParam);
     396
    396397  pt.x = (INT)LOWORD(lParam);
    397398  pt.y = (INT)HIWORD(lParam);
    398  
     399
    399400  newItem=TAB_InternalHitTest (hwnd, infoPtr,pt,(unsigned int*)&dummy);
    400  
     401
    401402//  TRACE(tab, "On Tab, item %d\n", newItem);
    402    
     403
    403404  if ( (newItem!=-1) &&
    404405       (infoPtr->iSelected != newItem) )
     
    434435  if (infoPtr->hwndToolTip)
    435436    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    436                     WM_LBUTTONDOWN, wParam, lParam);
     437                    WM_LBUTTONDOWN, wParam, lParam);
    437438  return 0;
    438439}
     
    445446 */
    446447static LRESULT TAB_AdjustRect(
    447   HWND   hwnd, 
    448   WPARAM fLarger, 
     448  HWND   hwnd,
     449  WPARAM fLarger,
    449450  LPRECT prc)
    450451{
    451452  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    452453
    453   if (fLarger) 
     454  if (fLarger)
    454455  {
    455456    /*
     
    460461     * Add the height of the tabs.
    461462     */
    462     if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 
     463    if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM)
    463464      prc->bottom += infoPtr->tabHeight;
    464465    else
     
    475476    InflateRect(prc, CONTROL_BORDER_SIZEX, CONTROL_BORDER_SIZEX);
    476477  }
    477   else 
     478  else
    478479  {
    479480    /*
    480481     * Go from window rectangle.
    481482     */
    482  
     483
    483484    /*
    484485     * Deflate the rectangle for the border
     
    494495     * Remove the height of the tabs.
    495496     */
    496     if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 
     497    if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM)
    497498      prc->bottom -= infoPtr->tabHeight;
    498499    else
     
    500501
    501502  }
    502  
     503
    503504  return 0;
    504505}
     
    511512 */
    512513static LRESULT TAB_OnHScroll(
    513   HWND    hwnd, 
     514  HWND    hwnd,
    514515  int     nScrollCode,
    515516  int     nPos,
     
    543544 * TAB_SetupScroling
    544545 *
    545  * This method will check the current scrolling state and make sure the 
     546 * This method will check the current scrolling state and make sure the
    546547 * scrolling control is displayed (or not).
    547548 */
     
    561562    controlPos.left  = controlPos.right - 2*GetSystemMetrics(SM_CXHSCROLL);
    562563
    563     if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 
     564    if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM)
    564565    {
    565566      controlPos.top    = clientRect->bottom - infoPtr->tabHeight;
     
    583584       */
    584585      infoPtr->hwndUpDown = CreateWindowA("ScrollBar",
    585                                           "",
    586                                           WS_VISIBLE | WS_CHILD | WS_OVERLAPPED | SBS_HORZ,
    587                                           controlPos.left, controlPos.top,
    588                                           controlPos.right - controlPos.left,
    589                                           controlPos.bottom - controlPos.top,
    590                                           hwnd,
    591                                           (HMENU)NULL,
    592                                           (HINSTANCE)NULL,
    593                                           NULL);       
     586                                          "",
     587                                          WS_VISIBLE | WS_CHILD | WS_OVERLAPPED | SBS_HORZ,
     588                                          controlPos.left, controlPos.top,
     589                                          controlPos.right - controlPos.left,
     590                                          controlPos.bottom - controlPos.top,
     591                                          hwnd,
     592                                          (HMENU)NULL,
     593                                          (HINSTANCE)NULL,
     594                                          NULL);
    594595    }
    595596    else
    596597    {
    597       SetWindowPos(infoPtr->hwndUpDown, 
    598                    (HWND)NULL,
    599                    controlPos.left, controlPos.top,
    600                    controlPos.right - controlPos.left,
    601                    controlPos.bottom - controlPos.top,
    602                    SWP_SHOWWINDOW | SWP_NOZORDER);                 
     598      SetWindowPos(infoPtr->hwndUpDown,
     599                   (HWND)NULL,
     600                   controlPos.left, controlPos.top,
     601                   controlPos.right - controlPos.left,
     602                   controlPos.bottom - controlPos.top,
     603                   SWP_SHOWWINDOW | SWP_NOZORDER);
    603604    }
    604605  }
     
    641642   * a font.
    642643   */
    643   hdc = GetDC(hwnd); 
    644    
     644  hdc = GetDC(hwnd);
     645
    645646  hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
    646647  hOldFont = SelectObject (hdc, hFont);
     
    651652   */
    652653  GetClientRect(hwnd, &clientRect);
    653  
     654
    654655  /*
    655656   * The leftmost item will be "0" aligned
     
    665666
    666667    /*
    667      * Make sure there is enough space for the letters + growing the 
    668      * selected item + extra space for the selected item.   
    669      */
    670     infoPtr->tabHeight = fontMetrics.tmHeight + 2*VERTICAL_ITEM_PADDING + 
     668     * Make sure there is enough space for the letters + growing the
     669     * selected item + extra space for the selected item.
     670     */
     671    infoPtr->tabHeight = fontMetrics.tmHeight + 2*VERTICAL_ITEM_PADDING +
    671672      SELECTED_TAB_OFFSET;
    672673  }
     
    677678     * Calculate the vertical position of the tab
    678679     */
    679     if (lStyle & TCS_BOTTOM) 
    680     {
    681       infoPtr->items[curItem].rect.bottom = clientRect.bottom - 
     680    if (lStyle & TCS_BOTTOM)
     681    {
     682      infoPtr->items[curItem].rect.bottom = clientRect.bottom -
    682683                                            SELECTED_TAB_OFFSET;
    683       infoPtr->items[curItem].rect.top = clientRect.bottom - 
     684      infoPtr->items[curItem].rect.top = clientRect.bottom -
    684685                                         infoPtr->tabHeight;
    685686    }
    686     else 
    687     {
    688       infoPtr->items[curItem].rect.top = clientRect.top + 
     687    else
     688    {
     689      infoPtr->items[curItem].rect.top = clientRect.top +
    689690                                         SELECTED_TAB_OFFSET;
    690       infoPtr->items[curItem].rect.bottom = clientRect.top + 
     691      infoPtr->items[curItem].rect.bottom = clientRect.top +
    691692                                            infoPtr->tabHeight;
    692693    }
     
    708709       * Calculate how wide the tab is depending on the text it contains
    709710       */
    710       GetTextExtentPoint32A(hdc, infoPtr->items[curItem].pszText, 
     711      GetTextExtentPoint32A(hdc, infoPtr->items[curItem].pszText,
    711712                            lstrlenA(infoPtr->items[curItem].pszText), &size);
    712      
     713
    713714      infoPtr->items[curItem].rect.right = infoPtr->items[curItem].rect.left +
    714715                                           size.cx + 2*HORIZONTAL_ITEM_PADDING;
     
    716717
    717718//    TRACE(tab, "TextSize: %i\n ", size.cx);
    718 //    TRACE(tab, "Rect: T %i, L %i, B %i, R %i\n", 
    719 //        infoPtr->items[curItem].rect.top,
    720 //        infoPtr->items[curItem].rect.left,
    721 //        infoPtr->items[curItem].rect.bottom,
    722 //        infoPtr->items[curItem].rect.right); 
     719//    TRACE(tab, "Rect: T %i, L %i, B %i, R %i\n",
     720//        infoPtr->items[curItem].rect.top,
     721//        infoPtr->items[curItem].rect.left,
     722//        infoPtr->items[curItem].rect.bottom,
     723//        infoPtr->items[curItem].rect.right);
    723724
    724725    /*
     
    735736   * Check if we need a scrolling control.
    736737   */
    737   infoPtr->needsScrolling = (curItemLeftPos + (2*SELECTED_TAB_OFFSET) > 
     738  infoPtr->needsScrolling = (curItemLeftPos + (2*SELECTED_TAB_OFFSET) >
    738739                             clientRect.right);
    739740
    740   TAB_SetupScrolling(hwnd, infoPtr, &clientRect);     
    741  
     741  TAB_SetupScrolling(hwnd, infoPtr, &clientRect);
     742
    742743  /*
    743744   * Cleanup
     
    751752 *
    752753 * This method is used to draw a single tab into the tab control.
    753  */         
     754 */
    754755static void TAB_DrawItem(
    755   HWND hwnd, 
    756   HDC  hdc, 
     756  HWND hwnd,
     757  HDC  hdc,
    757758  INT  iItem)
    758759{
     
    768769   */
    769770  isVisible = TAB_InternalGetItemRect(hwnd,
    770                                       infoPtr,
    771                                       iItem,
    772                                       &itemRect,
    773                                       &selectedRect);
     771                                      infoPtr,
     772                                      iItem,
     773                                      &itemRect,
     774                                      &selectedRect);
    774775
    775776  if (isVisible)
    776777  {
    777     HBRUSH hbr       = CreateSolidBrush (GetSysColor(COLOR_BTNFACE));   
     778    HBRUSH hbr       = CreateSolidBrush (GetSysColor(COLOR_BTNFACE));
    778779    HPEN   hwPen     = GetSysColorPen (COLOR_3DHILIGHT);
    779780    HPEN   hbPen     = GetSysColorPen (COLOR_BTNSHADOW);
     
    782783    HPEN   holdPen;
    783784    INT    oldBkMode;
    784     INT    cx,cy; 
     785    INT    cx,cy;
    785786
    786787    if (lStyle & TCS_BUTTONS)
    787788    {
    788       /* 
     789      /*
    789790       * Get item rectangle.
    790791       */
     
    795796      if (iItem == infoPtr->iSelected)
    796797      {
    797         /* 
    798          * Background color. 
     798        /*
     799         * Background color.
    799800         */
    800801        if (!(lStyle & TCS_OWNERDRAWFIXED))
    801           hbr = CreateSolidBrush(GetSysColor(COLOR_3DHILIGHT));   
     802          hbr = CreateSolidBrush(GetSysColor(COLOR_3DHILIGHT));
    802803
    803804        /*
    804805         * Erase the background.
    805          */     
     806         */
    806807        FillRect(hdc, &r, hbr);
    807808
     
    819820        LineTo   (hdc, r.right, r.bottom);
    820821        LineTo   (hdc, r.right, r.top);
    821        
     822
    822823        /* shadow */
    823824        SelectObject(hdc, hbPen);
     
    829830        /*
    830831         * Erase the background.
    831          */     
     832         */
    832833        FillRect(hdc, &r, hbr);
    833834
     
    836837        LineTo   (hdc, r.left, r.top);
    837838        LineTo   (hdc, r.right, r.top);
    838        
     839
    839840        /* shadow */
    840841        SelectObject(hdc, hbPen);
     
    845846    else
    846847    {
    847       /* 
    848        * Background color. 
     848      /*
     849       * Background color.
    849850       */
    850       hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));   
     851      hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
    851852
    852853      /*
     
    861862      /*
    862863       * Erase the background.
    863        * This is necessary when drawing the selected item since it is larger 
    864        * than the others, it might overlap with stuff already drawn by the 
     864       * This is necessary when drawing the selected item since it is larger
     865       * than the others, it might overlap with stuff already drawn by the
    865866       * other tabs
    866        */     
     867       */
    867868      FillRect(hdc, &r, hbr);
    868869
     
    875876      r.right--;
    876877      r.bottom--;
    877      
     878
    878879      holdPen = SelectObject (hdc, hwPen);
    879880
    880       if (lStyle & TCS_BOTTOM) 
     881      if (lStyle & TCS_BOTTOM)
    881882      {
    882883        /* highlight */
     
    884885        LineTo   (hdc, r.left, r.bottom - ROUND_CORNER_SIZE);
    885886        LineTo   (hdc, r.left + ROUND_CORNER_SIZE, r.bottom);
    886        
     887
    887888        /* shadow */
    888889        SelectObject(hdc, hbPen);
     
    891892        LineTo  (hdc, r.right, r.top);
    892893      }
    893       else 
     894      else
    894895      {
    895896        /* highlight */
     
    898899        LineTo   (hdc, r.left + ROUND_CORNER_SIZE, r.top);
    899900        LineTo   (hdc, r.right - ROUND_CORNER_SIZE, r.top);
    900        
     901
    901902        /* shadow */
    902903        SelectObject(hdc, hbPen);
     
    905906      }
    906907    }
    907  
     908
    908909    /*
    909910     * Text pen
    910911     */
    911     SelectObject(hdc, hsdPen); 
    912 
    913     oldBkMode = SetBkMode(hdc, TRANSPARENT); 
     912    SelectObject(hdc, hsdPen);
     913
     914    oldBkMode = SetBkMode(hdc, TRANSPARENT);
    914915    SetTextColor (hdc, COLOR_BTNTEXT);
    915916
     
    922923     * Draw the icon.
    923924     */
    924     if (infoPtr->himl) 
    925     {
    926       ImageList_Draw (infoPtr->himl, iItem, hdc, 
    927                       r.left, r.top+1, ILD_NORMAL);
     925    if (infoPtr->himl)
     926    {
     927      ImageList_Draw (infoPtr->himl, iItem, hdc,
     928                      r.left, r.top+1, ILD_NORMAL);
    928929      ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
    929930      r.left+=cx;
     
    934935     */
    935936    DrawTextA(hdc,
    936               infoPtr->items[iItem].pszText,
    937               lstrlenA(infoPtr->items[iItem].pszText),
    938               &r,
    939               DT_LEFT|DT_SINGLELINE|DT_VCENTER);
     937              infoPtr->items[iItem].pszText,
     938              lstrlenA(infoPtr->items[iItem].pszText),
     939              &r,
     940              DT_LEFT|DT_SINGLELINE|DT_VCENTER);
    940941
    941942    /*
     
    943944     */
    944945    if (((lStyle & TCS_FOCUSNEVER) == 0) &&
    945         (GetFocus() == hwnd) &&
    946         (iItem == infoPtr->uFocus) )
     946        (GetFocus() == hwnd) &&
     947        (iItem == infoPtr->uFocus) )
    947948    {
    948949      InflateRect(&r, FOCUS_RECT_HOFFSET, FOCUS_RECT_VOFFSET);
     
    951952
    952953      MoveToEx (hdc, r.left,    r.top, NULL);
    953       LineTo   (hdc, r.right-1, r.top); 
     954      LineTo   (hdc, r.right-1, r.top);
    954955      LineTo   (hdc, r.right-1, r.bottom -1);
    955956      LineTo   (hdc, r.left,    r.bottom -1);
     
    970971 * This method is used to draw the raised border around the tab control
    971972 * "content" area.
    972  */         
     973 */
    973974static void TAB_DrawBorder (HWND hwnd, HDC hdc)
    974975{
     
    985986   * Adjust for the style
    986987   */
    987   if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 
     988  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM)
    988989  {
    989990    rect.bottom -= infoPtr->tabHeight;
     
    10031004  /* highlight */
    10041005  htmPen = SelectObject (hdc, hwPen);
    1005  
     1006
    10061007  MoveToEx (hdc, rect.left, rect.bottom, NULL);
    1007   LineTo (hdc, rect.left, rect.top); 
     1008  LineTo (hdc, rect.left, rect.top);
    10081009  LineTo (hdc, rect.right, rect.top);
    10091010
     
    10261027 *
    10271028 * This method repaints the tab control..
    1028  */             
     1029 */
    10291030static void TAB_Refresh (HWND hwnd, HDC hdc)
    10301031{
     
    10401041  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS)
    10411042  {
    1042     for (i = 0; i < infoPtr->uNumItem; i++) 
    1043     {
    1044         TAB_DrawItem (hwnd, hdc, i);
     1043    for (i = 0; i < infoPtr->uNumItem; i++)
     1044    {
     1045        TAB_DrawItem (hwnd, hdc, i);
    10451046    }
    10461047  }
     
    10501051     * Draw all the non selected item first.
    10511052     */
    1052     for (i = 0; i < infoPtr->uNumItem; i++) 
     1053    for (i = 0; i < infoPtr->uNumItem; i++)
    10531054    {
    10541055      if (i != infoPtr->iSelected)
    1055         TAB_DrawItem (hwnd, hdc, i);
     1056        TAB_DrawItem (hwnd, hdc, i);
    10561057    }
    10571058
     
    10751076{
    10761077    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    1077  
     1078
    10781079  infoPtr->DoRedraw=(BOOL) wParam;
    10791080  return 0;
     
    10811082
    10821083static LRESULT TAB_EraseBackground(
    1083   HWND hwnd, 
     1084  HWND hwnd,
    10841085  HDC  givenDC)
    10851086{
     
    11351136  GetClientRect(infoPtr->hwndUpDown, &scrollerRect);
    11361137  visibleRect.right -= scrollerRect.right;
    1137  
     1138
    11381139  /*
    11391140   * Get the rectangle for the item
    11401141   */
    11411142  isVisible = TAB_InternalGetItemRect(hwnd,
    1142                                       infoPtr,
    1143                                       infoPtr->iSelected,
    1144                                       NULL,
    1145                                       &selectedRect);
     1143                                      infoPtr,
     1144                                      infoPtr->iSelected,
     1145                                      NULL,
     1146                                      &selectedRect);
    11461147
    11471148  /*
     
    11631164
    11641165  while ( (infoPtr->leftmostVisible < infoPtr->iSelected) &&
    1165           !isVisible)
     1166          !isVisible)
    11661167  {
    11671168    infoPtr->leftmostVisible++;
     
    11711172     */
    11721173    isVisible = TAB_InternalGetItemRect(hwnd,
    1173                                         infoPtr,
    1174                                         infoPtr->iSelected,
    1175                                         NULL,
    1176                                         &selectedRect);
     1174                                        infoPtr,
     1175                                        infoPtr->iSelected,
     1176                                        NULL,
     1177                                        &selectedRect);
    11771178
    11781179    /*
     
    11891190      pt2.x = selectedRect.right - 1;
    11901191      pt2.y = selectedRect.bottom - 1;
    1191      
     1192
    11921193      isVisible = PtInRect(&visibleRect, pt1) &&  PtInRect(&visibleRect, pt2);
    11931194    }
     
    12101211  GetClientRect(hwnd, &clientRect);
    12111212
    1212   if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 
     1213  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM)
    12131214  {
    12141215    clientRect.top = clientRect.bottom - (infoPtr->tabHeight + 1);
     
    12271228  HDC hdc;
    12281229  PAINTSTRUCT ps;
    1229    
     1230
    12301231  hdc = wParam== 0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
    12311232  TAB_Refresh (hwnd, hdc);
    1232    
     1233
    12331234  if(!wParam)
    12341235    EndPaint (hwnd, &ps);
     
    12391240static LRESULT
    12401241TAB_InsertItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1241 {   
     1242{
    12421243  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    12431244  TCITEMA *pti;
    12441245  INT iItem, len;
    12451246  RECT rect;
    1246  
     1247
    12471248  GetClientRect (hwnd, &rect);
    12481249//  TRACE(tab, "Rect: %x T %i, L %i, B %i, R %i\n", hwnd,
    1249 //        rect.top, rect.left, rect.bottom, rect.right); 
    1250  
     1250//        rect.top, rect.left, rect.bottom, rect.right);
     1251
    12511252  pti = (TCITEMA *)lParam;
    12521253  iItem = (INT)wParam;
    1253  
     1254
    12541255  if (iItem < 0) return -1;
    12551256  if (iItem > infoPtr->uNumItem)
    12561257    iItem = infoPtr->uNumItem;
    1257  
     1258
    12581259  if (infoPtr->uNumItem == 0) {
    12591260    infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM));
     
    12621263  else {
    12631264    TAB_ITEM *oldItems = infoPtr->items;
    1264    
     1265
    12651266    infoPtr->uNumItem++;
    12661267    infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM) * infoPtr->uNumItem);
    1267    
     1268
    12681269    /* pre insert copy */
    12691270    if (iItem > 0) {
    12701271      memcpy (&infoPtr->items[0], &oldItems[0],
    1271               iItem * sizeof(TAB_ITEM));
    1272     }
    1273    
     1272              iItem * sizeof(TAB_ITEM));
     1273    }
     1274
    12741275    /* post insert copy */
    12751276    if (iItem < infoPtr->uNumItem - 1) {
    12761277      memcpy (&infoPtr->items[iItem+1], &oldItems[iItem],
    1277               (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
    1278      
    1279     }
    1280    
     1278              (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
     1279
     1280    }
     1281
    12811282    COMCTL32_Free (oldItems);
    12821283  }
    1283  
     1284
    12841285  infoPtr->items[iItem].mask = pti->mask;
    12851286  if (pti->mask & TCIF_TEXT) {
     
    12891290    infoPtr->items[iItem].cchTextMax = pti->cchTextMax;
    12901291  }
    1291  
     1292
    12921293  if (pti->mask & TCIF_IMAGE)
    12931294    infoPtr->items[iItem].iImage = pti->iImage;
    1294  
     1295
    12951296  if (pti->mask & TCIF_PARAM)
    12961297    infoPtr->items[iItem].lParam = pti->lParam;
    1297  
     1298
    12981299  TAB_InvalidateTabArea(hwnd, infoPtr);
    1299  
     1300
    13001301//  TRACE(tab, "[%04x]: added item %d '%s'\n",
    1301 //      hwnd, iItem, infoPtr->items[iItem].pszText);
     1302//      hwnd, iItem, infoPtr->items[iItem].pszText);
    13021303
    13031304  TAB_SetItemBounds(hwnd);
     
    13051306}
    13061307
    1307 static LRESULT 
     1308static LRESULT
    13081309TAB_SetItemSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
    13091310{
     
    13221323}
    13231324
    1324 static LRESULT 
     1325static LRESULT
    13251326TAB_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    13261327{
    13271328  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    1328   TCITEMA *tabItem; 
    1329   TAB_ITEM *wineItem; 
     1329  TCITEMA *tabItem;
     1330  TAB_ITEM *wineItem;
    13301331  INT    iItem,len;
    13311332
     
    13371338  wineItem=& infoPtr->items[iItem];
    13381339
    1339   if (tabItem->mask & TCIF_IMAGE) 
     1340  if (tabItem->mask & TCIF_IMAGE)
    13401341    wineItem->iImage=tabItem->iImage;
    13411342
    1342   if (tabItem->mask & TCIF_PARAM) 
     1343  if (tabItem->mask & TCIF_PARAM)
    13431344    wineItem->lParam=tabItem->lParam;
    13441345
    1345 //  if (tabItem->mask & TCIF_RTLREADING) 
     1346//  if (tabItem->mask & TCIF_RTLREADING)
    13461347//    FIXME (tab,"TCIF_RTLREADING\n");
    13471348
    1348   if (tabItem->mask & TCIF_STATE) 
     1349  if (tabItem->mask & TCIF_STATE)
    13491350    wineItem->dwState=tabItem->dwState;
    13501351
    13511352  if (tabItem->mask & TCIF_TEXT) {
    1352    len=lstrlenA (tabItem->pszText);
    1353    if (len>wineItem->cchTextMax) 
    1354      wineItem->pszText= COMCTL32_ReAlloc (wineItem->pszText, len+1);
     1353   len = lstrlenA (tabItem->pszText);
     1354   if (len>wineItem->cchTextMax)
     1355     wineItem->pszText = COMCTL32_ReAlloc (wineItem->pszText, len+1);
    13551356   lstrcpynA (wineItem->pszText, tabItem->pszText, len);
    13561357  }
     
    13591360}
    13601361
    1361 static LRESULT 
     1362static LRESULT
    13621363TAB_GetItemCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
    13631364{
     
    13681369
    13691370
    1370 static LRESULT 
     1371static LRESULT
    13711372TAB_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    13721373{
     
    13831384  wineItem=& infoPtr->items[iItem];
    13841385
    1385   if (tabItem->mask & TCIF_IMAGE) 
     1386  if (tabItem->mask & TCIF_IMAGE)
    13861387    tabItem->iImage=wineItem->iImage;
    13871388
    1388   if (tabItem->mask & TCIF_PARAM) 
     1389  if (tabItem->mask & TCIF_PARAM)
    13891390    tabItem->lParam=wineItem->lParam;
    13901391
    1391 //  if (tabItem->mask & TCIF_RTLREADING) 
     1392//  if (tabItem->mask & TCIF_RTLREADING)
    13921393//    FIXME (tab, "TCIF_RTLREADING\n");
    13931394
    1394   if (tabItem->mask & TCIF_STATE) 
     1395  if (tabItem->mask & TCIF_STATE)
    13951396    tabItem->dwState=wineItem->dwState;
    13961397
    1397   if (tabItem->mask & TCIF_TEXT) 
     1398  if (tabItem->mask & TCIF_TEXT)
    13981399   lstrcpynA (tabItem->pszText, wineItem->pszText, tabItem->cchTextMax);
    13991400
     
    14011402}
    14021403
    1403 static LRESULT 
     1404static LRESULT
    14041405TAB_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
    14051406{
     
    14111412  {
    14121413    TAB_ITEM *oldItems = infoPtr->items;
    1413    
     1414
    14141415    infoPtr->uNumItem--;
    14151416    infoPtr->items = COMCTL32_Alloc(sizeof (TAB_ITEM) * infoPtr->uNumItem);
    1416    
    1417     if (iItem > 0) 
     1417
     1418    if (iItem > 0)
    14181419      memcpy(&infoPtr->items[0], &oldItems[0], iItem * sizeof(TAB_ITEM));
    1419    
    1420     if (iItem < infoPtr->uNumItem) 
     1420
     1421    if (iItem < infoPtr->uNumItem)
    14211422      memcpy(&infoPtr->items[iItem], &oldItems[iItem + 1],
    14221423              (infoPtr->uNumItem - iItem) * sizeof(TAB_ITEM));
    1423    
     1424
    14241425    COMCTL32_Free (oldItems);
    14251426
     
    14291430    if ((iItem == infoPtr->iSelected) && (iItem > 0))
    14301431      infoPtr->iSelected--;
    1431      
     1432
    14321433    if (iItem < infoPtr->iSelected)
    14331434      infoPtr->iSelected--;
     
    14451446}
    14461447
    1447 static LRESULT 
     1448static LRESULT
    14481449TAB_DeleteAllItems (HWND hwnd, WPARAM wParam, LPARAM lParam)
    14491450{
     
    14521453  COMCTL32_Free (infoPtr->items);
    14531454  infoPtr->uNumItem=0;
    1454  
     1455
    14551456  return TRUE;
    14561457}
     
    14711472{
    14721473  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    1473  
     1474
    14741475//  TRACE (tab,"%x %lx\n",wParam, lParam);
    1475  
     1476
    14761477  infoPtr->hFont = (HFONT)wParam;
    1477  
     1478
    14781479  TAB_SetItemBounds(hwnd);
    14791480
     
    15251526    cx=LOWORD (lParam);
    15261527    cy=HIWORD (lParam);
    1527     if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE) 
     1528    if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE)
    15281529        uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
    15291530
     
    15481549
    15491550
    1550 static LRESULT 
     1551static LRESULT
    15511552TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
    15521553{
     
    15591560
    15601561  SetWindowLongA(hwnd, 0, (DWORD)infoPtr);
    1561    
     1562
    15621563  infoPtr->uNumItem        = 0;
    15631564  infoPtr->hFont           = 0;
    15641565  infoPtr->items           = 0;
    15651566  infoPtr->hcurArrow       = LoadCursorA (0, IDC_ARROWA);
    1566   infoPtr->iSelected       = 0; 
    1567   infoPtr->uFocus          = 0; 
     1567  infoPtr->iSelected       = 0;
     1568  infoPtr->uFocus          = 0;
    15681569  infoPtr->hwndToolTip     = 0;
    15691570  infoPtr->DoRedraw        = TRUE;
     
    15711572  infoPtr->hwndUpDown      = 0;
    15721573  infoPtr->leftmostVisible = 0;
    1573  
    1574 //  TRACE(tab, "Created tab control, hwnd [%04x]\n", hwnd); 
     1574
     1575//  TRACE(tab, "Created tab control, hwnd [%04x]\n", hwnd);
    15751576  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_TOOLTIPS) {
    15761577    /* Create tooltip control */
    15771578    infoPtr->hwndToolTip =
    15781579      CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    1579                        CW_USEDEFAULT, CW_USEDEFAULT,
    1580                        CW_USEDEFAULT, CW_USEDEFAULT,
    1581                        hwnd, 0, 0, 0);
    1582    
     1580                       CW_USEDEFAULT, CW_USEDEFAULT,
     1581                       CW_USEDEFAULT, CW_USEDEFAULT,
     1582                       hwnd, 0, 0, 0);
     1583
    15831584    /* Send NM_TOOLTIPSCREATED notification */
    15841585    if (infoPtr->hwndToolTip) {
    15851586      NMTOOLTIPSCREATED nmttc;
    1586      
     1587
    15871588      nmttc.hdr.hwndFrom = hwnd;
    15881589      nmttc.hdr.idFrom = GetWindowLongA(hwnd, GWL_ID);
    15891590      nmttc.hdr.code = NM_TOOLTIPSCREATED;
    15901591      nmttc.hwndToolTips = infoPtr->hwndToolTip;
    1591      
     1592
    15921593      SendMessageA (GetParent (hwnd), WM_NOTIFY,
    1593                     (WPARAM)GetWindowLongA(hwnd, GWL_ID), (LPARAM)&nmttc);
    1594     }
    1595   } 
    1596    
     1594                    (WPARAM)GetWindowLongA(hwnd, GWL_ID), (LPARAM)&nmttc);
     1595    }
     1596  }
     1597
    15971598  /*
    15981599   * We need to get text information so we need a DC and we need to select
    15991600   * a font.
    16001601   */
    1601   hdc = GetDC(hwnd); 
     1602  hdc = GetDC(hwnd);
    16021603  hOldFont = SelectObject (hdc, GetStockObject (SYSTEM_FONT));
    16031604
     
    16081609
    16091610  /*
    1610    * Make sure there is enough space for the letters + growing the 
    1611    * selected item + extra space for the selected item.   
    1612    */
    1613   infoPtr->tabHeight = fontMetrics.tmHeight + 2*VERTICAL_ITEM_PADDING + 
     1611   * Make sure there is enough space for the letters + growing the
     1612   * selected item + extra space for the selected item.
     1613   */
     1614  infoPtr->tabHeight = fontMetrics.tmHeight + 2*VERTICAL_ITEM_PADDING +
    16141615                       SELECTED_TAB_OFFSET;
    16151616
     
    16341635    for (iItem = 0; iItem < infoPtr->uNumItem; iItem++) {
    16351636      if (infoPtr->items[iItem].pszText)
    1636         COMCTL32_Free (infoPtr->items[iItem].pszText);
     1637        COMCTL32_Free (infoPtr->items[iItem].pszText);
    16371638    }
    16381639    COMCTL32_Free (infoPtr->items);
    16391640  }
    1640  
    1641   if (infoPtr->hwndToolTip) 
     1641
     1642  if (infoPtr->hwndToolTip)
    16421643    DestroyWindow (infoPtr->hwndToolTip);
    1643  
     1644
    16441645  if (infoPtr->hwndUpDown)
    16451646    DestroyWindow(infoPtr->hwndUpDown);
     
    16561657    case TCM_GETIMAGELIST:
    16571658      return TAB_GetImageList (hwnd, wParam, lParam);
    1658      
     1659
    16591660    case TCM_SETIMAGELIST:
    16601661      return TAB_SetImageList (hwnd, wParam, lParam);
    1661      
     1662
    16621663    case TCM_GETITEMCOUNT:
    16631664      return TAB_GetItemCount (hwnd, wParam, lParam);
    1664      
     1665
    16651666    case TCM_GETITEMA:
    16661667      return TAB_GetItemA (hwnd, wParam, lParam);
    1667      
     1668
    16681669    case TCM_GETITEMW:
    16691670//      FIXME (tab, "Unimplemented msg TCM_GETITEMW\n");
    16701671      return 0;
    1671      
     1672
    16721673    case TCM_SETITEMA:
    16731674      return TAB_SetItemA (hwnd, wParam, lParam);
    1674      
     1675
    16751676    case TCM_SETITEMW:
    16761677//      FIXME (tab, "Unimplemented msg TCM_SETITEMW\n");
    16771678      return 0;
    1678      
     1679
    16791680    case TCM_DELETEITEM:
    16801681      return TAB_DeleteItem (hwnd, wParam, lParam);
    1681      
     1682
    16821683    case TCM_DELETEALLITEMS:
    16831684     return TAB_DeleteAllItems (hwnd, wParam, lParam);
    1684      
     1685
    16851686    case TCM_GETITEMRECT:
    16861687     return TAB_GetItemRect (hwnd, wParam, lParam);
    1687      
     1688
    16881689    case TCM_GETCURSEL:
    16891690      return TAB_GetCurSel (hwnd);
    1690      
     1691
    16911692    case TCM_HITTEST:
    16921693      return TAB_HitTest (hwnd, wParam, lParam);
    1693      
     1694
    16941695    case TCM_SETCURSEL:
    16951696      return TAB_SetCurSel (hwnd, wParam);
    1696      
     1697
    16971698    case TCM_INSERTITEMA:
    16981699      return TAB_InsertItem (hwnd, wParam, lParam);
    1699      
     1700
    17001701    case TCM_INSERTITEMW:
    17011702//      FIXME (tab, "Unimplemented msg TCM_INSERTITEM32W\n");
    17021703      return 0;
    1703      
     1704
    17041705    case TCM_SETITEMEXTRA:
    17051706//      FIXME (tab, "Unimplemented msg TCM_SETITEMEXTRA\n");
    17061707      return 0;
    1707      
     1708
    17081709    case TCM_ADJUSTRECT:
    17091710      return TAB_AdjustRect (hwnd, (BOOL)wParam, (LPRECT)lParam);
    1710      
     1711
    17111712    case TCM_SETITEMSIZE:
    17121713      return TAB_SetItemSize (hwnd, wParam, lParam);
    1713      
     1714
    17141715    case TCM_REMOVEIMAGE:
    17151716//      FIXME (tab, "Unimplemented msg TCM_REMOVEIMAGE\n");
    17161717      return 0;
    1717      
     1718
    17181719    case TCM_SETPADDING:
    17191720//      FIXME (tab, "Unimplemented msg TCM_SETPADDING\n");
    17201721      return 0;
    1721      
     1722
    17221723    case TCM_GETROWCOUNT:
    17231724//      FIXME (tab, "Unimplemented msg TCM_GETROWCOUNT\n");
     
    17351736//      FIXME (tab, "Unimplemented msg TCM_HIGHLIGHTITEM\n");
    17361737      return 0;
    1737      
     1738
    17381739    case TCM_GETTOOLTIPS:
    17391740      return TAB_GetToolTips (hwnd, wParam, lParam);
    1740      
     1741
    17411742    case TCM_SETTOOLTIPS:
    17421743      return TAB_SetToolTips (hwnd, wParam, lParam);
    1743      
     1744
    17441745    case TCM_GETCURFOCUS:
    17451746      return TAB_GetCurFocus (hwnd);
    1746      
     1747
    17471748    case TCM_SETCURFOCUS:
    17481749      return TAB_SetCurFocus (hwnd, wParam);
    1749      
     1750
    17501751    case TCM_SETMINTTABWIDTH:
    17511752//      FIXME (tab, "Unimplemented msg TCM_SETMINTTABWIDTH\n");
    17521753      return 0;
    1753      
     1754
    17541755    case TCM_DESELECTALL:
    17551756//      FIXME (tab, "Unimplemented msg TCM_DESELECTALL\n");
    17561757      return 0;
    1757      
     1758
    17581759    case TCM_GETEXTENDEDSTYLE:
    17591760//      FIXME (tab, "Unimplemented msg TCM_GETEXTENDEDSTYLE\n");
     
    17661767    case WM_GETFONT:
    17671768      return TAB_GetFont (hwnd, wParam, lParam);
    1768      
     1769
    17691770    case WM_SETFONT:
    17701771      return TAB_SetFont (hwnd, wParam, lParam);
    1771      
     1772
    17721773    case WM_CREATE:
    17731774      return TAB_Create (hwnd, wParam, lParam);
    1774      
     1775
    17751776    case WM_NCDESTROY:
    17761777      return TAB_Destroy (hwnd, wParam, lParam);
    1777      
     1778
    17781779    case WM_GETDLGCODE:
    17791780      return DLGC_WANTARROWS | DLGC_WANTCHARS;
    1780      
     1781
    17811782    case WM_LBUTTONDOWN:
    17821783      return TAB_LButtonDown (hwnd, wParam, lParam);
    1783      
     1784
    17841785    case WM_LBUTTONUP:
    17851786      return TAB_LButtonUp (hwnd, wParam, lParam);
    1786      
     1787
    17871788    case WM_RBUTTONDOWN:
    17881789      return TAB_RButtonDown (hwnd, wParam, lParam);
    1789      
     1790
    17901791    case WM_MOUSEMOVE:
    17911792      return TAB_MouseMove (hwnd, wParam, lParam);
    1792      
     1793
    17931794    case WM_ERASEBKGND:
    17941795      return TAB_EraseBackground (hwnd, (HDC)wParam);
     
    17991800    case WM_SIZE:
    18001801      return TAB_Size (hwnd, wParam, lParam);
    1801      
     1802
    18021803    case WM_SETREDRAW:
    18031804      return TAB_SetRedraw (hwnd, wParam);
     
    18051806    case WM_HSCROLL:
    18061807      return TAB_OnHScroll(hwnd, (int)LOWORD(wParam), (int)HIWORD(wParam), (HWND)lParam);
    1807      
     1808
    18081809    case WM_KILLFOCUS:
    18091810    case WM_SETFOCUS:
     
    18151816    default:
    18161817//      if (uMsg >= WM_USER)
    1817 //      ERR (tab, "unknown msg %04x wp=%08x lp=%08lx\n",
    1818 //           uMsg, wParam, lParam);
     1818//      ERR (tab, "unknown msg %04x wp=%08x lp=%08lx\n",
     1819//           uMsg, wParam, lParam);
    18191820      return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    18201821    }
     
    18391840  wndClass.hbrBackground = (HBRUSH)NULL;
    18401841  wndClass.lpszClassName = WC_TABCONTROLA;
    1841  
     1842
    18421843  RegisterClassA (&wndClass);
    18431844}
  • trunk/src/comctl32/toolbar.c

    r180 r236  
    1 /* $Id: toolbar.c,v 1.6 1999-06-24 16:37:45 cbratschi Exp $ */
     1/* $Id: toolbar.c,v 1.7 1999-06-28 15:46:27 cbratschi Exp $ */
    22/*
    33 * Toolbar control
     
    2929 */
    3030
     31/* CB: Odin32/WINE bugs
     32  - IMAGELIST_Draw draws a line too much at the bottom of the bitmap
     33*/
     34
    3135#include <string.h>
    3236
     
    15141518            lstrcpynA (lpTbInfo->pszText,
    15151519                         (LPSTR)infoPtr->strings[btnPtr->iString],
    1516                          lpTbInfo->cchText);
     1520                         MIN(lpTbInfo->cchText,lstrlenA((LPSTR)infoPtr->strings[btnPtr->iString])));
    15171521    }
    15181522
     
    20572061    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    20582062
    2059     if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0)) return FALSE;
     2063    if ((LOWORD(lParam) <= 0) || (HIWORD(lParam) <= 0)) return FALSE;
    20602064
    20612065    infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
     
    24742478
    24752479            nmttc.hdr.hwndFrom = hwnd;
    2476             nmttc.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     2480            nmttc.hdr.idFrom   = GetWindowLongA(hwnd,GWL_ID);
    24772481            nmttc.hdr.code = NM_TOOLTIPSCREATED;
    24782482            nmttc.hwndToolTips = infoPtr->hwndToolTip;
    24792483
    2480             SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
    2481                           (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
     2484            SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)nmttc.hdr.idFrom,(LPARAM)&nmttc);
    24822485        }
    24832486    }
     
    26912694    INT   nHit;
    26922695    HDC   hdc;
     2696    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    26932697
    26942698    if (infoPtr->hwndToolTip)
     
    27112715          oldBtnPtr->bHot = FALSE;
    27122716
    2713           InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE);
     2717          if (dwStyle & TBSTYLE_FLAT) InvalidateRect(hwnd,&oldBtnPtr->rect,TRUE);
    27142718        }
    27152719      }
     
    27232727          btnPtr->bHot = TRUE;
    27242728
    2725           hdc = GetDC (hwnd);
    2726           TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
    2727           ReleaseDC (hwnd, hdc);
     2729          if (dwStyle & TBSTYLE_FLAT)
     2730          {
     2731            hdc = GetDC (hwnd);
     2732            TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
     2733            ReleaseDC (hwnd, hdc);
     2734          }
    27282735
    27292736          infoPtr->nHotItem = nHit;
     
    28642871
    28652872    TOOLBAR_CalcToolbar(hwnd);
    2866     hdc = wParam==0 ? BeginPaint(hwnd,&ps) : (HDC)wParam;
     2873    hdc = wParam == 0 ? BeginPaint(hwnd,&ps) : (HDC)wParam;
    28672874    TOOLBAR_Refresh(hwnd,hdc);
    28682875    if (!wParam) EndPaint (hwnd, &ps);
  • trunk/src/comctl32/tooltips.c

    r219 r236  
    1 /* $Id: tooltips.c,v 1.7 1999-06-26 14:20:31 cbratschi Exp $ */
     1/* $Id: tooltips.c,v 1.8 1999-06-28 15:46:27 cbratschi Exp $ */
    22/*
    33 * Tool tip control
     
    2929#include "comctl32.h"
    3030
    31 
    3231#define ID_TIMERSHOW   1    /* show delay timer */
    3332#define ID_TIMERPOP    2    /* auto pop timer */
     
    4140
    4241#define TOOLTIPS_GetInfoPtr(hWindow) ((TOOLTIPS_INFO *)GetWindowLongA (hWindow, 0))
    43 
    4442
    4543LRESULT CALLBACK
     
    119117        } else if (ttnmdi.szText[0])
    120118        {
    121           lstrcpynAtoW (infoPtr->szTipText,ttnmdi.szText,80);
     119          lstrcpynAtoW(infoPtr->szTipText,ttnmdi.szText,MIN(INFOTIPSIZE-1,lstrlenA(ttnmdi.szText)));
    122120          if (ttnmdi.uFlags & TTF_DI_SETITEM)
    123121          {
     
    130128        {
    131129          /* no text available */
    132           infoPtr->szTipText[0] = L'\0';
     130          infoPtr->szTipText[0] = '\0';
    133131        } else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA)
    134132        {
    135           lstrcpynAtoW(infoPtr->szTipText,ttnmdi.lpszText,INFOTIPSIZE);
     133          lstrcpynAtoW(infoPtr->szTipText,ttnmdi.lpszText,MIN(INFOTIPSIZE-1,lstrlenA(ttnmdi.lpszText)));
    136134          if (ttnmdi.uFlags & TTF_DI_SETITEM)
    137135          {
     
    149147      {
    150148        /* the item is a usual (unicode) text */
    151       lstrcpynW (infoPtr->szTipText,toolPtr->lpszText,INFOTIPSIZE);
     149        lstrcpynW(infoPtr->szTipText,toolPtr->lpszText,MIN(INFOTIPSIZE-1,lstrlenW(toolPtr->lpszText)));
    152150      }
    153151    }
     
    155153    {
    156154      /* no text available */
    157       infoPtr->szTipText[0] = L'\0';
     155      infoPtr->szTipText[0] = '\0';
    158156    }
    159157
     
    206204
    207205//    TRACE (tooltips, "Show tooltip pre %d!\n", infoPtr->nTool);
    208 
    209206    TOOLTIPS_GetTipText(hwnd,infoPtr,infoPtr->nCurrentTool);
    210207
    211     if (infoPtr->szTipText[0] == L'\0')
     208    if (infoPtr->szTipText[0] == '\0')
    212209    {
    213210        infoPtr->nCurrentTool = -1;
     
    316313    TOOLTIPS_GetTipText(hwnd,infoPtr,infoPtr->nTrackTool);
    317314
    318     if (infoPtr->szTipText[0] == L'\0')
     315    if (infoPtr->szTipText[0] == '\0')
    319316    {
    320317      infoPtr->nTrackTool = -1;
     
    558555TOOLTIPS_Activate (HWND hwnd, WPARAM wParam, LPARAM lParam)
    559556{
    560     TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
     557    TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
    561558
    562559    infoPtr->bActive = (BOOL)wParam;
     
    572569
    573570
    574 static LRESULT
    575 TOOLTIPS_AddToolA(HWND hwnd,WPARAM wParam,LPARAM lParam)
    576 {
    577     TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
    578     LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
    579     TTTOOL_INFO *toolPtr;
    580 
    581     if (lpToolInfo == NULL) return FALSE;
    582     if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) return FALSE;
    583 
    584 //    TRACE (tooltips, "add tool (%x) %x %d%s!\n",
    585 //         hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
    586 //         (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
    587 
    588     if (infoPtr->uNumTools == 0)
    589     {
    590       infoPtr->tools = COMCTL32_Alloc(sizeof(TTTOOL_INFO));
    591       toolPtr = infoPtr->tools;
    592     } else
    593     {
    594       TTTOOL_INFO *oldTools = infoPtr->tools;
    595 
    596       //CB: check if already exists!
    597 
    598       infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO)*(infoPtr->uNumTools+1));
    599       memcpy (infoPtr->tools,oldTools,infoPtr->uNumTools*sizeof(TTTOOL_INFO));
    600       COMCTL32_Free(oldTools);
    601       toolPtr = &infoPtr->tools[infoPtr->uNumTools];
    602     }
    603 
    604     infoPtr->uNumTools++;
    605 
    606     /* copy tool data */
    607     toolPtr->uFlags = lpToolInfo->uFlags;
    608     toolPtr->hwnd   = lpToolInfo->hwnd;
    609     toolPtr->uId    = lpToolInfo->uId;
    610     toolPtr->rect   = lpToolInfo->rect;
    611     toolPtr->hinst  = lpToolInfo->hinst;
    612 
    613     if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0))
    614     {
    615 //    TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText);
    616       toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
    617     } else if (lpToolInfo->lpszText)
    618     {
    619       if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
    620       {
    621 //      TRACE (tooltips, "add CALLBACK!\n");
    622         toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    623       } else
    624       {
    625         INT len = lstrlenA (lpToolInfo->lpszText);
    626 //          TRACE (tooltips, "add text \"%s\"!\n", lpToolInfo->lpszText);
    627         toolPtr->lpszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR));
    628         lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
    629       }
    630     } else toolPtr->lpszText = NULL;
    631 
    632     if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
    633         toolPtr->lParam = lpToolInfo->lParam;
    634 
    635     /* install subclassing hook */
     571static VOID TOOLTIPS_Subclass(HWND hwnd,TTTOOL_INFO *toolPtr)
     572{
    636573    if (toolPtr->uFlags & TTF_SUBCLASS)
    637574    {
     
    669606//      TRACE (tooltips, "subclassing installed!\n");
    670607    }
    671 
    672     return TRUE;
    673 }
    674 
    675 
    676 static LRESULT
    677 TOOLTIPS_AddToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    678 {
    679     TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
    680     LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
     608}
     609
     610static VOID TOOLTIPS_Desubclass(TTTOOL_INFO *toolPtr)
     611{
     612    if (toolPtr->uFlags & TTF_SUBCLASS)
     613    {
     614      if (toolPtr->uFlags & TTF_IDISHWND)
     615      {
     616        LPTT_SUBCLASS_INFO lpttsi =
     617            (LPTT_SUBCLASS_INFO)GetPropA((HWND)toolPtr->uId,COMCTL32_aSubclass);
     618        if (lpttsi)
     619        {
     620          SetWindowLongA ((HWND)toolPtr->uId,GWL_WNDPROC,(LONG)lpttsi->wpOrigProc);
     621          RemovePropA ((HWND)toolPtr->uId,COMCTL32_aSubclass);
     622          COMCTL32_Free(&lpttsi);
     623        }
     624//          else
     625//              ERR (tooltips, "Invalid data handle!\n");
     626      } else
     627      {
     628        LPTT_SUBCLASS_INFO lpttsi =
     629            (LPTT_SUBCLASS_INFO)GetPropA(toolPtr->hwnd,COMCTL32_aSubclass);
     630        if (lpttsi)
     631        {
     632          if (lpttsi->uRefCount == 1)
     633          {
     634            SetWindowLongA((HWND)toolPtr->uId,GWL_WNDPROC,(LONG)lpttsi->wpOrigProc);
     635            RemovePropA((HWND)toolPtr->uId,COMCTL32_aSubclass);
     636            COMCTL32_Free(&lpttsi);
     637          } else lpttsi->uRefCount--;
     638        }
     639//          else
     640//              ERR (tooltips, "Invalid data handle!\n");
     641      }
     642    }
     643}
     644
     645static LRESULT
     646TOOLTIPS_AddToolA(HWND hwnd,WPARAM wParam,LPARAM lParam)
     647{
     648    TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
     649    LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
    681650    TTTOOL_INFO *toolPtr;
    682651
    683     if (lpToolInfo == NULL)
    684         return FALSE;
    685     if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    686         return FALSE;
     652    if (lpToolInfo == NULL) return FALSE;
     653    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) return FALSE;
    687654
    688655//    TRACE (tooltips, "add tool (%x) %x %d%s!\n",
     
    690657//         (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
    691658
    692     if (infoPtr->uNumTools == 0) {
    693         infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO));
    694         toolPtr = infoPtr->tools;
    695     }
    696     else {
    697         TTTOOL_INFO *oldTools = infoPtr->tools;
    698         infoPtr->tools =
    699             COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1));
    700         memcpy (infoPtr->tools, oldTools,
    701                 infoPtr->uNumTools * sizeof(TTTOOL_INFO));
    702         COMCTL32_Free (oldTools);
     659    if (infoPtr->uNumTools == 0)
     660    {
     661      infoPtr->tools = COMCTL32_Alloc(sizeof(TTTOOL_INFO));
     662      toolPtr = infoPtr->tools;
     663    } else
     664    {
     665      TTTOOL_INFO *oldTools = infoPtr->tools;
     666      INT x;
     667
     668      toolPtr = NULL;
     669
     670      //check if toolinfo already exists
     671      for (x = 0;x < infoPtr->uNumTools;x++)
     672      {
     673        if (lpToolInfo->hwnd == infoPtr->tools[x].hwnd && lpToolInfo->uId == infoPtr->tools[x].uId)
     674        {
     675          //return toolPtr
     676          toolPtr = &infoPtr->tools[x];
     677          //free allocated memory
     678          TOOLTIPS_Desubclass(toolPtr);
     679          if ((toolPtr->hinst) && (toolPtr->lpszText))
     680          {
     681            if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(toolPtr->lpszText);
     682          }
     683
     684          break;
     685        }
     686      }
     687
     688      if (toolPtr == NULL)
     689      {
     690        infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO)*(infoPtr->uNumTools+1));
     691        memcpy(infoPtr->tools,oldTools,infoPtr->uNumTools*sizeof(TTTOOL_INFO));
     692        COMCTL32_Free(oldTools);
    703693        toolPtr = &infoPtr->tools[infoPtr->uNumTools];
     694      }
     695    }
     696
     697    infoPtr->uNumTools++;
     698
     699    /* copy tool data */
     700    toolPtr->uFlags = lpToolInfo->uFlags;
     701    toolPtr->hwnd   = lpToolInfo->hwnd;
     702    toolPtr->uId    = lpToolInfo->uId;
     703    toolPtr->rect   = lpToolInfo->rect;
     704    toolPtr->hinst  = lpToolInfo->hinst;
     705
     706    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0))
     707    {
     708//    TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText);
     709      toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
     710    } else if (lpToolInfo->lpszText)
     711    {
     712      if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
     713      {
     714//      TRACE (tooltips, "add CALLBACK!\n");
     715        toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     716      } else
     717      {
     718        INT len = lstrlenA (lpToolInfo->lpszText);
     719//          TRACE (tooltips, "add text \"%s\"!\n", lpToolInfo->lpszText);
     720        toolPtr->lpszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR));
     721        lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
     722      }
     723    } else toolPtr->lpszText = NULL;
     724
     725    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
     726        toolPtr->lParam = lpToolInfo->lParam;
     727
     728    /* install subclassing hook */
     729    TOOLTIPS_Subclass(hwnd,toolPtr);
     730
     731    return TRUE;
     732}
     733
     734
     735static LRESULT
     736TOOLTIPS_AddToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
     737{
     738    TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
     739    LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
     740    TTTOOL_INFO *toolPtr;
     741
     742    if (lpToolInfo == NULL)
     743        return FALSE;
     744    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
     745        return FALSE;
     746
     747//    TRACE (tooltips, "add tool (%x) %x %d%s!\n",
     748//         hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
     749//         (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
     750
     751    if (infoPtr->uNumTools == 0)
     752    {
     753      infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO));
     754      toolPtr = infoPtr->tools;
     755    } else
     756    {
     757      TTTOOL_INFO *oldTools = infoPtr->tools;
     758      INT x;
     759
     760      toolPtr = NULL;
     761
     762      //check if toolinfo already exists
     763      for (x = 0;x < infoPtr->uNumTools;x++)
     764      {
     765        if (lpToolInfo->hwnd == infoPtr->tools[x].hwnd && lpToolInfo->uId == infoPtr->tools[x].uId)
     766        {
     767          //return toolPtr
     768          toolPtr = &infoPtr->tools[x];
     769          //free allocated memory
     770          TOOLTIPS_Desubclass(toolPtr);
     771          if ((toolPtr->hinst) && (toolPtr->lpszText))
     772          {
     773            if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(toolPtr->lpszText);
     774          }
     775
     776          break;
     777        }
     778      }
     779
     780      if (toolPtr == NULL)
     781      {
     782        infoPtr->tools = COMCTL32_Alloc(sizeof(TTTOOL_INFO)*(infoPtr->uNumTools+1));
     783        memcpy (infoPtr->tools,oldTools,infoPtr->uNumTools*sizeof(TTTOOL_INFO));
     784        COMCTL32_Free(oldTools);
     785        toolPtr = &infoPtr->tools[infoPtr->uNumTools];
     786      }
    704787    }
    705788
     
    735818
    736819    /* install subclassing hook */
    737     if (toolPtr->uFlags & TTF_SUBCLASS) {
    738         if (toolPtr->uFlags & TTF_IDISHWND) {
    739             LPTT_SUBCLASS_INFO lpttsi =
    740                 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    741             if (lpttsi == NULL) {
    742                 lpttsi =
    743                     (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
    744                 lpttsi->wpOrigProc =
    745                     (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId,
    746                     GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
    747                 lpttsi->hwndToolTip = hwnd;
    748                 lpttsi->uRefCount++;
    749                 SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass,
    750                             (HANDLE)lpttsi);
    751             }
    752 //          else
    753 //              WARN (tooltips, "A window tool must only be listed once!\n");
    754         }
    755         else {
    756             LPTT_SUBCLASS_INFO lpttsi =
    757                 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
    758             if (lpttsi == NULL) {
    759                 lpttsi =
    760                     (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
    761                 lpttsi->wpOrigProc =
    762                     (WNDPROC)SetWindowLongA (toolPtr->hwnd,
    763                     GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
    764                 lpttsi->hwndToolTip = hwnd;
    765                 lpttsi->uRefCount++;
    766                 SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi);
    767             }
    768             else
    769                 lpttsi->uRefCount++;
    770         }
    771 //      TRACE (tooltips, "subclassing installed!\n");
    772     }
     820    TOOLTIPS_Subclass(hwnd,toolPtr);
    773821
    774822    return TRUE;
     
    804852
    805853    /* remove subclassing */
    806     if (toolPtr->uFlags & TTF_SUBCLASS) {
    807         if (toolPtr->uFlags & TTF_IDISHWND) {
    808             LPTT_SUBCLASS_INFO lpttsi =
    809                 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    810             if (lpttsi) {
    811                 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
    812                                   (LONG)lpttsi->wpOrigProc);
    813                 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    814                 COMCTL32_Free (&lpttsi);
    815             }
    816 //          else
    817 //              ERR (tooltips, "Invalid data handle!\n");
    818         }
    819         else {
    820             LPTT_SUBCLASS_INFO lpttsi =
    821                 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
    822             if (lpttsi) {
    823                 if (lpttsi->uRefCount == 1) {
    824                     SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
    825                                       (LONG)lpttsi->wpOrigProc);
    826                     RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    827                     COMCTL32_Free (&lpttsi);
    828                 }
    829                 else
    830                     lpttsi->uRefCount--;
    831             }
    832 //          else
    833 //              ERR (tooltips, "Invalid data handle!\n");
    834         }
    835     }
     854    TOOLTIPS_Desubclass(toolPtr);
    836855
    837856    /* delete tool from tool list */
     
    890909
    891910    /* remove subclassing */
    892     if (toolPtr->uFlags & TTF_SUBCLASS) {
    893         if (toolPtr->uFlags & TTF_IDISHWND) {
    894             LPTT_SUBCLASS_INFO lpttsi =
    895                 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    896             if (lpttsi) {
    897                 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
    898                                   (LONG)lpttsi->wpOrigProc);
    899                 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    900                 COMCTL32_Free (&lpttsi);
    901             }
    902 //          else
    903 //              ERR (tooltips, "Invalid data handle!\n");
    904         }
    905         else {
    906             LPTT_SUBCLASS_INFO lpttsi =
    907                 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
    908             if (lpttsi) {
    909                 if (lpttsi->uRefCount == 1) {
    910                     SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
    911                                       (LONG)lpttsi->wpOrigProc);
    912                     RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    913                     COMCTL32_Free (&lpttsi);
    914                 }
    915                 else
    916                     lpttsi->uRefCount--;
    917             }
    918 //          else
    919 //              ERR (tooltips, "Invalid data handle!\n");
    920         }
    921     }
     911    TOOLTIPS_Desubclass(toolPtr);
    922912
    923913    /* delete tool from tool list */
     
    14431433//          TRACE (tooltips, "WM_MOUSEMOVE (%04x %ld %ld)\n",
    14441434//                 hwnd, pt.x, pt.y);
    1445 infoPtr->bActive = TRUE;//CB: somewhere reset, find it!!!
     1435
    14461436            if (infoPtr->bActive && (infoPtr->nTool != infoPtr->nOldTool))
    14471437            {
     
    18551845
    18561846    /* initialize info structure */
     1847    infoPtr->szTipText[0] = '\0';
    18571848    infoPtr->bActive = TRUE;
    18581849    infoPtr->bTrackActive = FALSE;
    18591850    infoPtr->clrBk   = GetSysColor(COLOR_INFOBK);
    18601851    infoPtr->clrText = GetSysColor(COLOR_INFOTEXT);
     1852    infoPtr->xTrackPos = 0;
     1853    infoPtr->yTrackPos = 0;
    18611854
    18621855    nclm.cbSize = sizeof(NONCLIENTMETRICSA);
     
    19101903
    19111904        /* remove subclassing */
    1912         if (toolPtr->uFlags & TTF_SUBCLASS)
    1913         {
    1914           LPTT_SUBCLASS_INFO lpttsi;
    1915 
    1916           if (toolPtr->uFlags & TTF_IDISHWND)
    1917               lpttsi = (LPTT_SUBCLASS_INFO)GetPropA((HWND)toolPtr->uId,COMCTL32_aSubclass);
    1918           else
    1919               lpttsi = (LPTT_SUBCLASS_INFO)GetPropA(toolPtr->hwnd,COMCTL32_aSubclass);
    1920 
    1921           if (lpttsi)
    1922           {
    1923             SetWindowLongA ((HWND)toolPtr->uId,GWL_WNDPROC,(LONG)lpttsi->wpOrigProc);
    1924             RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    1925             COMCTL32_Free (&lpttsi);
    1926           }
    1927         }
     1905        TOOLTIPS_Desubclass(toolPtr);
     1906
    19281907      }
    19291908      COMCTL32_Free (infoPtr->tools);
     
    20792058    if(wParam < length)
    20802059    {
    2081         lstrcpynWtoA((LPSTR)lParam, infoPtr->szTipText,(UINT)wParam);
     2060        lstrcpynWtoA((LPSTR)lParam,infoPtr->szTipText,MIN((UINT)wParam,lstrlenW(infoPtr->szTipText)));
    20822061        return wParam;
    20832062    }
    2084     lstrcpyWtoA((LPSTR)lParam, infoPtr->szTipText);
     2063    lstrcpyWtoA((LPSTR)lParam,infoPtr->szTipText);
    20852064    return length;
    20862065
     
    20932072
    20942073//    TRACE (tooltips, "timer %d (%x) expired!\n", wParam, hwnd);
    2095 
    20962074    switch (wParam)
    20972075    {
    20982076      case ID_TIMERSHOW:
    2099           KillTimer (hwnd,ID_TIMERSHOW);
     2077          KillTimer(hwnd,ID_TIMERSHOW);
    21002078          if (TOOLTIPS_CheckTool(hwnd,TRUE) == infoPtr->nTool)
    21012079              TOOLTIPS_Show(hwnd,infoPtr);
     
    21162094          break;
    21172095    }
     2096
    21182097    return 0;
    21192098}
  • trunk/src/comctl32/trackbar.c

    r219 r236  
    1 /* $Id: trackbar.c,v 1.8 1999-06-26 14:20:32 cbratschi Exp $ */
     1/* $Id: trackbar.c,v 1.9 1999-06-28 15:46:28 cbratschi Exp $ */
    22/*
    33 * Trackbar control
     
    13841384  j = hi;
    13851385  x = list[(lo+hi)/2];
    1386   while (i <= j)
     1386  do
    13871387  {
    13881388    while (list[i] < x) i++;
     
    13961396      j--;
    13971397    }
    1398   }
     1398  } while (i <= j);
    13991399  if (lo < j) TRACKBAR_QuickSort(list,lo,j);
    14001400  if (i < hi) TRACKBAR_QuickSort(list,i,hi);
  • trunk/src/comctl32/treeview.c

    r164 r236  
    1 /* $Id: treeview.c,v 1.5 1999-06-23 19:45:02 achimha Exp $ */
     1/* $Id: treeview.c,v 1.6 1999-06-28 15:46:28 cbratschi Exp $ */
    22/* Treeview control
    33 *
     
    894894  if (tvItem->mask & TVIF_TEXT) {
    895895                if (tvItem->pszText!=LPSTR_TEXTCALLBACKA) {
    896         len=lstrlenA (tvItem->pszText);
    897         if (len>wineItem->cchTextMax)
    898                         wineItem->pszText= COMCTL32_ReAlloc (wineItem->pszText, len+1);
     896        len = lstrlenA (tvItem->pszText);
     897        if (len > wineItem->cchTextMax)
     898                        wineItem->pszText = COMCTL32_ReAlloc (wineItem->pszText, len+1);
    899899        lstrcpynA (wineItem->pszText, tvItem->pszText,len);
    900900                } else {
     
    903903                                wineItem->cchTextMax=0;
    904904                        }
    905                 wineItem->pszText=LPSTR_TEXTCALLBACKA;
     905                wineItem->pszText = LPSTR_TEXTCALLBACKA;
    906906                }
    907907   }
     
    11661166        }
    11671167        else if (wineItem->pszText) {
    1168             lstrcpynA (tvItem->pszText, wineItem->pszText, tvItem->cchTextMax);
     1168            lstrcpynA (tvItem->pszText, wineItem->pszText, MIN(tvItem->cchTextMax,lstrlenA(wineItem->pszText)));
    11691169        }
    11701170   }
Note: See TracChangeset for help on using the changeset viewer.