Changeset 110 for trunk/src


Ignore:
Timestamp:
Jun 16, 1999, 10:25:45 PM (26 years ago)
Author:
cbratschi
Message:

comctl32 wine conversion bugs fixed
trackbar: TRACKBAR_Draw prototype

Location:
trunk/src
Files:
8 edited

Legend:

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

    r109 r110  
    1 /* $Id: progress.c,v 1.4 1999-06-16 15:29:26 cbratschi Exp $ */
     1/* $Id: progress.c,v 1.5 1999-06-16 20:25:43 cbratschi Exp $ */
    22/*
    33 * Progress control
     
    88 * Copyright 1999 Christoph Bratschi
    99 *
     10 * Status: complete
    1011 */
    1112
     
    374375      temp = infoPtr->CurVal;
    375376      if(temp != wParam){
    376         infoPtr->CurVal = (UINT16)wParam;
     377        infoPtr->CurVal = (UINT16)wParam; //CB: 0..65535 allowed
    377378        PROGRESS_CoercePos(hwnd);
    378379        PROGRESS_Update (hwnd,temp);
     
    398399        UNKNOWN_PARAM(PBM_SETSTEP, wParam, lParam);
    399400      temp = infoPtr->Step;
    400       infoPtr->Step = (INT)wParam;
     401      infoPtr->Step = (INT)wParam; //CB: negative steps allowed
    401402      return temp;
    402403
  • trunk/src/comctl32/status.c

    r94 r110  
    1 /* $Id: status.c,v 1.3 1999-06-10 16:22:01 achimha Exp $ */
     1/* $Id: status.c,v 1.4 1999-06-16 20:25:43 cbratschi Exp $ */
    22/*
    33 * Interface code to StatusWindow widget/control
     
    66 * Copyright 1998, 1999 Eric Kohl
    77 * Copyright 1999 Achim Hasenmueller
     8 * Copyright 1999 Christoph Bratschi
    89 */
    910
     
    5657    SelectObject (hdc, GetSysColorPen (COLOR_3DSHADOW));
    5758    for (i = 1; i < 11; i += 4) {
    58         MoveToEx (hdc, pt.x - i, pt.y, NULL);
    59         LineTo (hdc, pt.x, pt.y - i);
    60 
    61         MoveToEx (hdc, pt.x - i-1, pt.y, NULL);
    62         LineTo (hdc, pt.x, pt.y - i-1);
     59        MoveToEx (hdc, pt.x - i, pt.y, NULL);
     60        LineTo (hdc, pt.x, pt.y - i);
     61
     62        MoveToEx (hdc, pt.x - i-1, pt.y, NULL);
     63        LineTo (hdc, pt.x, pt.y - i-1);
    6364    }
    6465
    6566    SelectObject (hdc, GetSysColorPen (COLOR_3DHIGHLIGHT));
    6667    for (i = 3; i < 13; i += 4) {
    67         MoveToEx (hdc, pt.x - i, pt.y, NULL);
    68         LineTo (hdc, pt.x, pt.y - i);
     68        MoveToEx (hdc, pt.x - i, pt.y, NULL);
     69        LineTo (hdc, pt.x, pt.y - i);
    6970    }
    7071
     
    7374
    7475
    75 static void 
     76static void
    7677STATUSBAR_DrawPart (HDC hdc, STATUSWINDOWPART *part)
    7778{
     
    8889    /* draw the icon */
    8990    if (part->hIcon) {
    90         INT cy = r.bottom - r.top;
    91 
    92         r.left += 2;
    93         DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL);
    94         r.left += cy;
     91        INT cy = r.bottom - r.top;
     92
     93        r.left += 2;
     94        DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL);
     95        r.left += cy;
    9596    }
    9697
     
    101102      UINT align = DT_LEFT;
    102103      if (*p == L'\t') {
    103         p++;
    104         align = DT_CENTER;
    105 
    106         if (*p == L'\t') {
    107           p++;
    108           align = DT_RIGHT;
    109         }
     104        p++;
     105        align = DT_CENTER;
     106
     107        if (*p == L'\t') {
     108          p++;
     109          align = DT_RIGHT;
     110        }
    110111      }
    111112      r.left += 3;
    112113      DrawTextW (hdc, p, lstrlenW (p), &r, align|DT_VCENTER|DT_SINGLELINE);
    113114      if (oldbkmode != TRANSPARENT)
    114         SetBkMode(hdc, oldbkmode);
     115        SetBkMode(hdc, oldbkmode);
    115116    }
    116117}
     
    128129
    129130    if (self->clrBk != CLR_DEFAULT)
    130         hbrBk = CreateSolidBrush (self->clrBk);
     131        hbrBk = CreateSolidBrush (self->clrBk);
    131132    else
    132         hbrBk = GetSysColorBrush (COLOR_3DFACE);
     133        hbrBk = GetSysColorBrush (COLOR_3DFACE);
    133134    FillRect(hdc, &part->bound, hbrBk);
    134135
     
    136137
    137138    if (part->style == SBT_OWNERDRAW) {
    138         DRAWITEMSTRUCT dis;
    139 
    140         dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
    141         dis.itemID = -1;
    142         dis.hwndItem = hwnd;
    143         dis.hDC = hdc;
    144         dis.rcItem = part->bound;
    145         dis.itemData = (INT)part->text;
    146         SendMessageA (GetParent (hwnd), WM_DRAWITEM,
    147                 (WPARAM)dis.CtlID, (LPARAM)&dis);
     139        DRAWITEMSTRUCT dis;
     140
     141        dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
     142        dis.itemID = -1;
     143        dis.hwndItem = hwnd;
     144        dis.hDC = hdc;
     145        dis.rcItem = part->bound;
     146        dis.itemData = (INT)part->text;
     147        SendMessageA (GetParent (hwnd), WM_DRAWITEM,
     148                (WPARAM)dis.CtlID, (LPARAM)&dis);
    148149    }
    149150    else
    150         STATUSBAR_DrawPart (hdc, part);
     151        STATUSBAR_DrawPart (hdc, part);
    151152
    152153    SelectObject (hdc, hOldFont);
    153154
    154155    if (self->clrBk != CLR_DEFAULT)
    155         DeleteObject (hbrBk);
     156        DeleteObject (hbrBk);
    156157
    157158    if (GetWindowLongA (hwnd, GWL_STYLE) & SBARS_SIZEGRIP) {
    158         RECT rect;
    159 
    160         GetClientRect (hwnd, &rect);
    161         STATUSBAR_DrawSizeGrip (hdc, &rect);
     159        RECT rect;
     160
     161        GetClientRect (hwnd, &rect);
     162        STATUSBAR_DrawSizeGrip (hdc, &rect);
    162163    }
    163164}
     
    179180
    180181    if (infoPtr->clrBk != CLR_DEFAULT)
    181         hbrBk = CreateSolidBrush (infoPtr->clrBk);
     182        hbrBk = CreateSolidBrush (infoPtr->clrBk);
    182183    else
    183         hbrBk = GetSysColorBrush (COLOR_3DFACE);
     184        hbrBk = GetSysColorBrush (COLOR_3DFACE);
    184185    FillRect(hdc, &rect, hbrBk);
    185186
     
    187188
    188189    if (infoPtr->simple) {
    189         STATUSBAR_DrawPart (hdc, &infoPtr->part0);
     190        STATUSBAR_DrawPart (hdc, &infoPtr->part0);
    190191    }
    191192    else {
    192         for (i = 0; i < infoPtr->numParts; i++) {
    193             if (infoPtr->parts[i].style == SBT_OWNERDRAW) {
    194                 DRAWITEMSTRUCT dis;
    195 
    196                 dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
    197                 dis.itemID = -1;
    198                 dis.hwndItem = hwnd;
    199                 dis.hDC = hdc;
    200                 dis.rcItem = infoPtr->parts[i].bound;
    201                 dis.itemData = (INT)infoPtr->parts[i].text;
    202                 SendMessageA (GetParent (hwnd), WM_DRAWITEM,
    203                         (WPARAM)dis.CtlID, (LPARAM)&dis);
    204             }
    205             else
    206                 STATUSBAR_DrawPart (hdc, &infoPtr->parts[i]);
    207         }
     193        for (i = 0; i < infoPtr->numParts; i++) {
     194            if (infoPtr->parts[i].style == SBT_OWNERDRAW) {
     195                DRAWITEMSTRUCT dis;
     196
     197                dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
     198                dis.itemID = -1;
     199                dis.hwndItem = hwnd;
     200                dis.hDC = hdc;
     201                dis.rcItem = infoPtr->parts[i].bound;
     202                dis.itemData = (INT)infoPtr->parts[i].text;
     203                SendMessageA (GetParent (hwnd), WM_DRAWITEM,
     204                        (WPARAM)dis.CtlID, (LPARAM)&dis);
     205            }
     206            else
     207                STATUSBAR_DrawPart (hdc, &infoPtr->parts[i]);
     208        }
    208209    }
    209210
     
    211212
    212213    if (infoPtr->clrBk != CLR_DEFAULT)
    213         DeleteObject (hbrBk);
     214        DeleteObject (hbrBk);
    214215
    215216    if (GetWindowLongA(hwnd, GWL_STYLE) & SBARS_SIZEGRIP)
    216         STATUSBAR_DrawSizeGrip (hdc, &rect);
     217        STATUSBAR_DrawSizeGrip (hdc, &rect);
    217218
    218219    return TRUE;
     
    226227    STATUSWINDOWPART *part;
    227228    RECT rect, *r;
    228     int i;
     229    int i;
    229230
    230231    /* get our window size */
     
    238239    /* set bounds for non-simple rectangles */
    239240    for (i = 0; i < self->numParts; i++) {
    240         part = &self->parts[i];
    241         r = &self->parts[i].bound;
    242         r->top = rect.top;
    243         r->bottom = rect.bottom;
    244         if (i == 0)
    245             r->left = 0;
    246         else
    247             r->left = self->parts[i-1].bound.right + HORZ_GAP;
    248         if (part->x == -1)
    249             r->right = rect.right;
    250         else
    251             r->right = part->x;
    252 
    253         if (self->hwndToolTip) {
    254             TTTOOLINFOA ti;
    255 
    256             ti.cbSize = sizeof(TTTOOLINFOA);
    257             ti.hwnd = hwnd;
    258             ti.uId = i;
    259             ti.rect = *r;
    260             SendMessageA (self->hwndToolTip, TTM_NEWTOOLRECTA,
    261                             0, (LPARAM)&ti);
    262         }
     241        part = &self->parts[i];
     242        r = &self->parts[i].bound;
     243        r->top = rect.top;
     244        r->bottom = rect.bottom;
     245        if (i == 0)
     246            r->left = 0;
     247        else
     248            r->left = self->parts[i-1].bound.right + HORZ_GAP;
     249        if (part->x == -1)
     250            r->right = rect.right;
     251        else
     252            r->right = part->x;
     253
     254        if (self->hwndToolTip) {
     255            TTTOOLINFOA ti;
     256
     257            ti.cbSize = sizeof(TTTOOLINFOA);
     258            ti.hwnd = hwnd;
     259            ti.uId = i;
     260            ti.rect = *r;
     261            SendMessageA (self->hwndToolTip, TTM_NEWTOOLRECTA,
     262                            0, (LPARAM)&ti);
     263        }
    263264    }
    264265}
     
    267268static VOID
    268269STATUSBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
    269                       WPARAM wParam, LPARAM lParam)
     270                      WPARAM wParam, LPARAM lParam)
    270271{
    271272    MSG msg;
     
    304305    nPart = (INT)wParam & 0x00ff;
    305306    if ((nPart < -1) || (nPart >= self->numParts))
    306         return 0;
     307        return 0;
    307308
    308309    if (nPart == -1)
     
    324325    parts = (LPINT) lParam;
    325326    if (parts) {
    326         return (infoPtr->numParts);
    327         for (i = 0; i < num_parts; i++) {
    328             parts[i] = infoPtr->parts[i].x;
    329         }
     327        return (infoPtr->numParts);
     328        for (i = 0; i < num_parts; i++) {
     329            parts[i] = infoPtr->parts[i].x;
     330        }
    330331    }
    331332    return (infoPtr->numParts);
     
    337338{
    338339    STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd);
    339     int part_num;
     340    int part_num;
    340341    LPRECT  rect;
    341342
     
    343344    rect = (LPRECT) lParam;
    344345    if (infoPtr->simple)
    345         *rect = infoPtr->part0.bound;
     346        *rect = infoPtr->part0.bound;
    346347    else
    347         *rect = infoPtr->parts[part_num].bound;
     348        *rect = infoPtr->parts[part_num].bound;
    348349    return TRUE;
    349350}
     
    360361    nPart = ((INT) wParam) & 0x00ff;
    361362    if (self->simple)
    362         part = &self->part0;
     363        part = &self->part0;
    363364    else
    364         part = &self->parts[nPart];
     365        part = &self->parts[nPart];
    365366
    366367    if (part->style == SBT_OWNERDRAW)
    367         result = (LRESULT)part->text;
     368        result = (LRESULT)part->text;
    368369    else {
    369         result = part->text ? lstrlenW (part->text) : 0;
    370         result |= (part->style << 16);
    371         if (lParam && LOWORD(result))
    372             lstrcpyWtoA((LPSTR)lParam, part->text);
     370        result = part->text ? lstrlenW (part->text) : 0;
     371        result |= (part->style << 16);
     372        if (lParam && LOWORD(result))
     373            lstrcpyWtoA((LPSTR)lParam, part->text);
    373374    }
    374375    return result;
     
    386387    nPart = ((INT)wParam) & 0x00ff;
    387388    if (infoPtr->simple)
    388         part = &infoPtr->part0;
     389        part = &infoPtr->part0;
    389390    else
    390         part = &infoPtr->parts[nPart];
     391        part = &infoPtr->parts[nPart];
    391392
    392393    if (part->style == SBT_OWNERDRAW)
    393         result = (LRESULT)part->text;
     394        result = (LRESULT)part->text;
    394395    else {
    395         result = part->text ? lstrlenW (part->text) : 0;
    396         result |= (part->style << 16);
    397         if (lParam)
    398             lstrcpyW ((LPWSTR)lParam, part->text);
     396        result = part->text ? lstrlenW (part->text) : 0;
     397        result |= (part->style << 16);
     398        if (lParam)
     399            lstrcpyW ((LPWSTR)lParam, part->text);
    399400    }
    400401    return result;
     
    413414
    414415    if (infoPtr->simple)
    415         part = &infoPtr->part0;
     416        part = &infoPtr->part0;
    416417    else
    417         part = &infoPtr->parts[part_num];
     418        part = &infoPtr->parts[part_num];
    418419
    419420    if (part->text)
    420         result = lstrlenW(part->text);
     421        result = lstrlenW(part->text);
    421422    else
    422         result = 0;
     423        result = 0;
    423424
    424425    result |= (part->style << 16);
     
    433434
    434435    if (infoPtr->hwndToolTip) {
    435         TTTOOLINFOA ti;
    436         ti.cbSize = sizeof(TTTOOLINFOA);
    437         ti.hwnd = hwnd;
    438         ti.uId = LOWORD(wParam);
    439         SendMessageA (infoPtr->hwndToolTip, TTM_GETTEXTA, 0, (LPARAM)&ti);
    440 
    441         if (ti.lpszText)
    442             lstrcpynA ((LPSTR)lParam, ti.lpszText, HIWORD(wParam));
     436        TTTOOLINFOA ti;
     437        ti.cbSize = sizeof(TTTOOLINFOA);
     438        ti.hwnd = hwnd;
     439        ti.uId = LOWORD(wParam);
     440        SendMessageA (infoPtr->hwndToolTip, TTM_GETTEXTA, 0, (LPARAM)&ti);
     441
     442        if (ti.lpszText)
     443            lstrcpynA ((LPSTR)lParam, ti.lpszText, HIWORD(wParam));
    443444    }
    444445
     
    453454
    454455    if (infoPtr->hwndToolTip) {
    455         TTTOOLINFOW ti;
    456         ti.cbSize = sizeof(TTTOOLINFOW);
    457         ti.hwnd = hwnd;
    458         ti.uId = LOWORD(wParam);
    459         SendMessageW (infoPtr->hwndToolTip, TTM_GETTEXTW, 0, (LPARAM)&ti);
    460 
    461         if (ti.lpszText)
    462             lstrcpynW ((LPWSTR)lParam, ti.lpszText, HIWORD(wParam));
     456        TTTOOLINFOW ti;
     457        ti.cbSize = sizeof(TTTOOLINFOW);
     458        ti.hwnd = hwnd;
     459        ti.uId = LOWORD(wParam);
     460        SendMessageW (infoPtr->hwndToolTip, TTM_GETTEXTW, 0, (LPARAM)&ti);
     461
     462        if (ti.lpszText)
     463            lstrcpynW ((LPWSTR)lParam, ti.lpszText, HIWORD(wParam));
    463464    }
    464465
     
    505506    STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
    506507    INT nPart = (INT)wParam & 0x00ff;
    507     HDC hdc; 
     508    HDC hdc;
    508509
    509510    if ((nPart < -1) || (nPart >= self->numParts))
    510         return FALSE;
     511        return FALSE;
    511512
    512513    hdc = GetDC (hwnd);
    513514    if (nPart == -1) {
    514         self->part0.hIcon = (HICON)lParam;
    515         if (self->simple)
    516             STATUSBAR_RefreshPart (hwnd, &self->part0, hdc);
     515        self->part0.hIcon = (HICON)lParam;
     516        if (self->simple)
     517            STATUSBAR_RefreshPart (hwnd, &self->part0, hdc);
    517518    }
    518519    else {
    519         self->parts[nPart].hIcon = (HICON)lParam;
    520         if (!(self->simple))
    521             STATUSBAR_RefreshPart (hwnd, &self->parts[nPart], hdc);
     520        self->parts[nPart].hIcon = (HICON)lParam;
     521        if (!(self->simple))
     522            STATUSBAR_RefreshPart (hwnd, &self->parts[nPart], hdc);
    522523    }
    523524    ReleaseDC (hwnd, hdc);
     
    533534
    534535    if (IsWindowVisible (hwnd)) {
    535         HWND parent = GetParent (hwnd);
    536         INT  width, x, y;
    537         RECT parent_rect;
    538 
    539         GetClientRect (parent, &parent_rect);
    540         self->height = (INT)wParam + VERT_BORDER;
    541         width = parent_rect.right - parent_rect.left;
    542         x = parent_rect.left;
    543         y = parent_rect.bottom - self->height;
    544         MoveWindow (hwnd, parent_rect.left,
    545                       parent_rect.bottom - self->height,
    546                       width, self->height, TRUE);
    547         STATUSBAR_SetPartBounds (hwnd);
     536        HWND parent = GetParent (hwnd);
     537        INT  width, x, y;
     538        RECT parent_rect;
     539
     540        GetClientRect (parent, &parent_rect);
     541        self->height = (INT)wParam + VERT_BORDER;
     542        width = parent_rect.right - parent_rect.left;
     543        x = parent_rect.left;
     544        y = parent_rect.bottom - self->height;
     545        MoveWindow (hwnd, parent_rect.left,
     546                      parent_rect.bottom - self->height,
     547                      width, self->height, TRUE);
     548        STATUSBAR_SetPartBounds (hwnd);
    548549    }
    549550
     
    557558    STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
    558559    STATUSWINDOWPART *tmp;
    559     HDC hdc;
     560    HDC hdc;
    560561    LPINT parts;
    561     int i;
    562     int oldNumParts;
     562    int i;
     563    int oldNumParts;
    563564
    564565    if (self->simple)
    565         self->simple = FALSE;
     566        self->simple = FALSE;
    566567
    567568    oldNumParts = self->numParts;
     
    569570    parts = (LPINT) lParam;
    570571    if (oldNumParts > self->numParts) {
    571         for (i = self->numParts ; i < oldNumParts; i++) {
    572             if (self->parts[i].text && (self->parts[i].style != SBT_OWNERDRAW))
    573                 COMCTL32_Free (self->parts[i].text);
    574         }
     572        for (i = self->numParts ; i < oldNumParts; i++) {
     573            if (self->parts[i].text && (self->parts[i].style != SBT_OWNERDRAW))
     574                COMCTL32_Free (self->parts[i].text);
     575        }
    575576    }
    576577    else if (oldNumParts < self->numParts) {
    577         tmp = COMCTL32_Alloc (sizeof(STATUSWINDOWPART) * self->numParts);
    578         for (i = 0; i < oldNumParts; i++) {
    579             tmp[i] = self->parts[i];
    580         }
    581         if (self->parts)
    582             COMCTL32_Free (self->parts);
    583         self->parts = tmp;
    584     }
    585    
     578        tmp = COMCTL32_Alloc (sizeof(STATUSWINDOWPART) * self->numParts);
     579        for (i = 0; i < oldNumParts; i++) {
     580            tmp[i] = self->parts[i];
     581        }
     582        if (self->parts)
     583            COMCTL32_Free (self->parts);
     584        self->parts = tmp;
     585    }
     586
    586587    for (i = 0; i < self->numParts; i++) {
    587         self->parts[i].x = parts[i];
     588        self->parts[i].x = parts[i];
    588589    }
    589590
    590591    if (self->hwndToolTip) {
    591         INT nTipCount =
    592             SendMessageA (self->hwndToolTip, TTM_GETTOOLCOUNT, 0, 0);
    593 
    594         if (nTipCount < self->numParts) {
    595             /* add tools */
    596             TTTOOLINFOA ti;
    597             INT i;
    598 
    599             ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    600             ti.cbSize = sizeof(TTTOOLINFOA);
    601             ti.hwnd = hwnd;
    602             for (i = nTipCount; i < self->numParts; i++) {
    603 //              TRACE (statusbar, "add tool %d\n", i);
    604                 ti.uId = i;
    605                 SendMessageA (self->hwndToolTip, TTM_ADDTOOLA,
    606                                 0, (LPARAM)&ti);
    607             }
    608         }
    609         else if (nTipCount > self->numParts) {
    610             /* delete tools */
    611             INT i;
    612 
    613             for (i = nTipCount - 1; i >= self->numParts; i--) {
    614 
    615 //              FIXME (statusbar, "delete tool %d\n", i);
    616 
    617             }
    618         }
     592        INT nTipCount =
     593            SendMessageA (self->hwndToolTip, TTM_GETTOOLCOUNT, 0, 0);
     594
     595        if (nTipCount < self->numParts) {
     596            /* add tools */
     597            TTTOOLINFOA ti;
     598            INT i;
     599
     600            ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     601            ti.cbSize = sizeof(TTTOOLINFOA);
     602            ti.hwnd = hwnd;
     603            for (i = nTipCount; i < self->numParts; i++) {
     604//              TRACE (statusbar, "add tool %d\n", i);
     605                ti.uId = i;
     606                SendMessageA (self->hwndToolTip, TTM_ADDTOOLA,
     607                                0, (LPARAM)&ti);
     608            }
     609        }
     610        else if (nTipCount > self->numParts) {
     611            /* delete tools */
     612            INT i;
     613
     614            for (i = nTipCount - 1; i >= self->numParts; i--) {
     615
     616//              FIXME (statusbar, "delete tool %d\n", i);
     617
     618            }
     619        }
    619620    }
    620621
     
    634635    STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
    635636    STATUSWINDOWPART *part;
    636     int part_num;
    637     int style;
     637    int part_num;
     638    int style;
    638639    LPSTR text;
    639     int len;
     640    int len;
    640641    HDC hdc;
    641642
     
    645646
    646647    if ((self->simple) || (self->parts==NULL) || (part_num==255))
    647         part = &self->part0;
     648        part = &self->part0;
    648649    else
    649         part = &self->parts[part_num];
     650        part = &self->parts[part_num];
    650651    if (!part) return FALSE;
    651652    part->style = style;
    652653    if (style == SBT_OWNERDRAW) {
    653         part->text = (LPWSTR)text;
     654        part->text = (LPWSTR)text;
    654655    }
    655656    else {
    656         /* duplicate string */
    657         if (part->text)
    658             COMCTL32_Free (part->text);
    659         part->text = 0;
    660         if (text && (len = lstrlenA(text))) {
    661             part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    662             lstrcpyAtoW (part->text, text);
    663         }
     657        /* duplicate string */
     658        if (part->text)
     659            COMCTL32_Free (part->text);
     660        part->text = 0;
     661        if (text && (len = lstrlenA(text))) {
     662            part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     663            lstrcpyAtoW (part->text, text);
     664        }
    664665    }
    665666
     
    686687
    687688    if ((self->simple) || (self->parts==NULL) || (part_num==255))
    688         part = &self->part0;
     689        part = &self->part0;
    689690    else
    690         part = &self->parts[part_num];
     691        part = &self->parts[part_num];
    691692    if (!part) return FALSE;
    692693    part->style = style;
    693694    if (style == SBT_OWNERDRAW) {
    694         part->text = text;
     695        part->text = text;
    695696    }
    696697    else {
    697         /* duplicate string */
    698         if (part->text)
    699             COMCTL32_Free (part->text);
    700         part->text = 0;
    701         if (text && (len = lstrlenW(text))) {
    702             part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    703             lstrcpyW(part->text, text);
    704         }
     698        /* duplicate string */
     699        if (part->text)
     700            COMCTL32_Free (part->text);
     701        part->text = 0;
     702        if (text && (len = lstrlenW(text))) {
     703            part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     704            lstrcpyW(part->text, text);
     705        }
    705706    }
    706707
     
    720721//    TRACE (statusbar, "part %d: \"%s\"\n", (INT)wParam, (LPSTR)lParam);
    721722    if (infoPtr->hwndToolTip) {
    722         TTTOOLINFOA ti;
    723         ti.cbSize = sizeof(TTTOOLINFOA);
    724         ti.hwnd = hwnd;
    725         ti.uId = (INT)wParam;
    726         ti.hinst = 0;
    727         ti.lpszText = (LPSTR)lParam;
    728         SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA,
    729                         0, (LPARAM)&ti);
     723        TTTOOLINFOA ti;
     724        ti.cbSize = sizeof(TTTOOLINFOA);
     725        ti.hwnd = hwnd;
     726        ti.uId = (INT)wParam;
     727        ti.hinst = 0;
     728        ti.lpszText = (LPSTR)lParam;
     729        SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA,
     730                        0, (LPARAM)&ti);
    730731    }
    731732
     
    741742//    TRACE (statusbar, "part %d: \"%s\"\n", (INT)wParam, (LPSTR)lParam);
    742743    if (infoPtr->hwndToolTip) {
    743         TTTOOLINFOW ti;
    744         ti.cbSize = sizeof(TTTOOLINFOW);
    745         ti.hwnd = hwnd;
    746         ti.uId = (INT)wParam;
    747         ti.hinst = 0;
    748         ti.lpszText = (LPWSTR)lParam;
    749         SendMessageW (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTW,
    750                         0, (LPARAM)&ti);
     744        TTTOOLINFOW ti;
     745        ti.cbSize = sizeof(TTTOOLINFOW);
     746        ti.hwnd = hwnd;
     747        ti.uId = (INT)wParam;
     748        ti.hinst = 0;
     749        ti.lpszText = (LPWSTR)lParam;
     750        SendMessageW (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTW,
     751                        0, (LPARAM)&ti);
    751752    }
    752753
     
    796797    LPCREATESTRUCTA lpCreate = (LPCREATESTRUCTA)lParam;
    797798    NONCLIENTMETRICSA nclm;
    798     RECT        rect;
    799     int         width, len;
    800     HDC hdc;
     799    RECT        rect;
     800    int         width, len;
     801    HDC hdc;
    801802    STATUSWINDOWINFO *self;
    802803
     
    831832
    832833    if (IsWindowUnicode (hwnd)) {
    833         self->bUnicode = TRUE;
    834         if ((len = lstrlenW ((LPCWSTR)lpCreate->lpszName))) {
    835             self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    836             lstrcpyW (self->parts[0].text, (LPCWSTR)lpCreate->lpszName);
    837         }
     834        self->bUnicode = TRUE;
     835        if ((len = lstrlenW ((LPCWSTR)lpCreate->lpszName))) {
     836            self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     837            lstrcpyW (self->parts[0].text, (LPCWSTR)lpCreate->lpszName);
     838        }
    838839    }
    839840    else {
    840         if ((len = lstrlenA ((LPCSTR)lpCreate->lpszName))) {
    841             self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    842             lstrcpyAtoW (self->parts[0].text, (LPCSTR)lpCreate->lpszName);
    843         }
     841        if ((len = lstrlenA ((LPCSTR)lpCreate->lpszName))) {
     842            self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     843            lstrcpyAtoW (self->parts[0].text, (LPCSTR)lpCreate->lpszName);
     844        }
    844845    }
    845846
    846847    if ((hdc = GetDC (0))) {
    847         TEXTMETRICA tm;
    848         HFONT hOldFont;
    849 
    850         hOldFont = SelectObject (hdc,self->hDefaultFont);
    851         GetTextMetricsA(hdc, &tm);
    852         self->textHeight = tm.tmHeight;
    853         SelectObject (hdc, hOldFont);
    854         ReleaseDC(0, hdc);
     848        TEXTMETRICA tm;
     849        HFONT hOldFont;
     850
     851        hOldFont = SelectObject (hdc,self->hDefaultFont);
     852        GetTextMetricsA(hdc, &tm);
     853        self->textHeight = tm.tmHeight;
     854        SelectObject (hdc, hOldFont);
     855        ReleaseDC(0, hdc);
    855856    }
    856857
    857858    if (GetWindowLongA (hwnd, GWL_STYLE) & SBT_TOOLTIPS) {
    858         self->hwndToolTip =
    859             CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    860                                CW_USEDEFAULT, CW_USEDEFAULT,
    861                                CW_USEDEFAULT, CW_USEDEFAULT,
    862                              hwnd, 0,
    863                              GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
    864 
    865         if (self->hwndToolTip) {
    866             NMTOOLTIPSCREATED nmttc;
    867 
    868             nmttc.hdr.hwndFrom = hwnd;
    869             nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
    870             nmttc.hdr.code = NM_TOOLTIPSCREATED;
    871             nmttc.hwndToolTips = self->hwndToolTip;
    872 
    873             SendMessageA (GetParent (hwnd), WM_NOTIFY,
    874                             (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
    875         }
     859        self->hwndToolTip =
     860            CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
     861                               CW_USEDEFAULT, CW_USEDEFAULT,
     862                               CW_USEDEFAULT, CW_USEDEFAULT,
     863                             hwnd, 0,
     864                             GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
     865
     866        if (self->hwndToolTip) {
     867            NMTOOLTIPSCREATED nmttc;
     868
     869            nmttc.hdr.hwndFrom = hwnd;
     870            nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
     871            nmttc.hdr.code = NM_TOOLTIPSCREATED;
     872            nmttc.hwndToolTips = self->hwndToolTip;
     873
     874            SendMessageA (GetParent (hwnd), WM_NOTIFY,
     875                            (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
     876        }
    876877    }
    877878
     
    880881    self->height = self->textHeight + 4 + VERT_BORDER;
    881882    MoveWindow (hwnd, lpCreate->x, lpCreate->y-1,
    882                   width, self->height, FALSE);
     883                  width, self->height, FALSE);
    883884    STATUSBAR_SetPartBounds (hwnd);
    884885
     
    891892{
    892893    STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd);
    893     int i;
     894    int i;
    894895
    895896    for (i = 0; i < self->numParts; i++) {
    896         if (self->parts[i].text && (self->parts[i].style != SBT_OWNERDRAW))
    897             COMCTL32_Free (self->parts[i].text);
     897        if (self->parts[i].text && (self->parts[i].style != SBT_OWNERDRAW))
     898            COMCTL32_Free (self->parts[i].text);
    898899    }
    899900    if (self->part0.text && (self->part0.style != SBT_OWNERDRAW))
    900         COMCTL32_Free (self->part0.text);
     901        COMCTL32_Free (self->part0.text);
    901902    COMCTL32_Free (self->parts);
    902903
    903904    /* delete default font */
    904905    if (self->hDefaultFont)
    905         DeleteObject (self->hDefaultFont);
     906        DeleteObject (self->hDefaultFont);
    906907
    907908    /* delete tool tip control */
    908909    if (self->hwndToolTip)
    909         DestroyWindow (self->hwndToolTip);
     910        DestroyWindow (self->hwndToolTip);
    910911
    911912    COMCTL32_Free (self);
     
    933934    len = lstrlenW (infoPtr->parts[0].text);
    934935    if (wParam > len) {
    935         if (infoPtr->bUnicode)
    936             lstrcpyW ((LPWSTR)lParam, infoPtr->parts[0].text);
    937         else
    938             lstrcpyWtoA ((LPSTR)lParam, infoPtr->parts[0].text);
    939         return len;
     936        if (infoPtr->bUnicode)
     937            lstrcpyW ((LPWSTR)lParam, infoPtr->parts[0].text);
     938        else
     939            lstrcpyWtoA ((LPSTR)lParam, infoPtr->parts[0].text);
     940        return len;
    940941    }
    941942
     
    950951
    951952    if (infoPtr->hwndToolTip)
    952         STATUSBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
    953                               WM_MOUSEMOVE, wParam, lParam);
     953        STATUSBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
     954                              WM_MOUSEMOVE, wParam, lParam);
    954955    return 0;
    955956}
     
    960961{
    961962    if (GetWindowLongA (hwnd, GWL_STYLE) & SBARS_SIZEGRIP) {
    962         RECT  rect;
    963         POINT pt;
    964 
    965         GetClientRect (hwnd, &rect);
    966 
    967         pt.x = (INT)LOWORD(lParam);
    968         pt.y = (INT)HIWORD(lParam);
    969         ScreenToClient (hwnd, &pt);
    970 
    971         rect.left = rect.right - 13;
    972         rect.top += 2;
    973 
    974         if (PtInRect (&rect, pt))
    975             return HTBOTTOMRIGHT;
     963        RECT  rect;
     964        POINT pt;
     965
     966        GetClientRect (hwnd, &rect);
     967
     968        pt.x = (INT)LOWORD(lParam);
     969        pt.y = (INT)HIWORD(lParam);
     970        ScreenToClient (hwnd, &pt);
     971
     972        rect.left = rect.right - 13;
     973        rect.top += 2;
     974
     975        if (PtInRect (&rect, pt))
     976            return HTBOTTOMRIGHT;
    976977    }
    977978
     
    10051006    STATUSBAR_Refresh (hwnd, hdc);
    10061007    if (!wParam)
    1007         EndPaint (hwnd, &ps);
     1008        EndPaint (hwnd, &ps);
    10081009
    10091010    return 0;
     
    10181019    infoPtr->hFont = (HFONT)wParam;
    10191020    if (LOWORD(lParam) == TRUE) {
    1020         HDC hdc = GetDC (hwnd);
     1021        HDC hdc = GetDC (hwnd);
    10211022        STATUSBAR_Refresh (hwnd, hdc);
    10221023        ReleaseDC (hwnd, hdc);
     
    10361037
    10371038    if (infoPtr->numParts == 0)
    1038         return FALSE;
     1039        return FALSE;
    10391040
    10401041    part = &infoPtr->parts[0];
     
    10441045    part->text = 0;
    10451046    if (infoPtr->bUnicode) {
    1046         if (lParam && (len = lstrlenW((LPCWSTR)lParam))) {
    1047             part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    1048             lstrcpyW (part->text, (LPCWSTR)lParam);
    1049         }
     1047        if (lParam && (len = lstrlenW((LPCWSTR)lParam))) {
     1048            part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1049            lstrcpyW (part->text, (LPCWSTR)lParam);
     1050        }
    10501051    }
    10511052    else {
    1052         if (lParam && (len = lstrlenA((LPCSTR)lParam))) {
    1053             part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    1054             lstrcpyAtoW (part->text, (LPCSTR)lParam);
    1055         }
     1053        if (lParam && (len = lstrlenA((LPCSTR)lParam))) {
     1054            part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1055            lstrcpyAtoW (part->text, (LPCSTR)lParam);
     1056        }
    10561057    }
    10571058
     
    10801081
    10811082    if (flags == SIZE_RESTORED) {
    1082         /* width and height don't apply */
    1083         parent = GetParent (hwnd);
    1084         GetClientRect (parent, &parent_rect);
    1085         width = parent_rect.right - parent_rect.left;
    1086         x = parent_rect.left;
    1087         y = parent_rect.bottom - infoPtr->height;
    1088         MoveWindow (hwnd, parent_rect.left,
    1089                       parent_rect.bottom - infoPtr->height,
    1090                       width, infoPtr->height, TRUE);
    1091         STATUSBAR_SetPartBounds (hwnd);
     1083        /* width and height don't apply */
     1084        parent = GetParent (hwnd);
     1085        GetClientRect (parent, &parent_rect);
     1086        width = parent_rect.right - parent_rect.left;
     1087        x = parent_rect.left;
     1088        y = parent_rect.bottom - infoPtr->height;
     1089        MoveWindow (hwnd, parent_rect.left,
     1090                      parent_rect.bottom - infoPtr->height,
     1091                      width, infoPtr->height, TRUE);
     1092        STATUSBAR_SetPartBounds (hwnd);
    10921093    }
    10931094    return 0;
     
    11131114{
    11141115    switch (msg) {
    1115         case SB_GETBORDERS:
    1116             return STATUSBAR_GetBorders (lParam);
    1117 
    1118         case SB_GETICON:
    1119             return STATUSBAR_GetIcon (hwnd, wParam);
    1120 
    1121         case SB_GETPARTS:
    1122             return STATUSBAR_GetParts (hwnd, wParam, lParam);
    1123 
    1124         case SB_GETRECT:
    1125             return STATUSBAR_GetRect (hwnd, wParam, lParam);
    1126 
    1127         case SB_GETTEXTA:
    1128             return STATUSBAR_GetTextA (hwnd, wParam, lParam);
    1129 
    1130         case SB_GETTEXTW:
    1131             return STATUSBAR_GetTextW (hwnd, wParam, lParam);
    1132 
    1133         case SB_GETTEXTLENGTHA:
    1134         case SB_GETTEXTLENGTHW:
    1135             return STATUSBAR_GetTextLength (hwnd, wParam);
    1136 
    1137         case SB_GETTIPTEXTA:
    1138             return STATUSBAR_GetTipTextA (hwnd, wParam, lParam);
    1139 
    1140         case SB_GETTIPTEXTW:
    1141             return STATUSBAR_GetTipTextW (hwnd, wParam, lParam);
    1142 
    1143         case SB_GETUNICODEFORMAT:
    1144             return STATUSBAR_GetUnicodeFormat (hwnd);
    1145 
    1146         case SB_ISSIMPLE:
    1147             return STATUSBAR_IsSimple (hwnd);
    1148 
    1149         case SB_SETBKCOLOR:
    1150             return STATUSBAR_SetBkColor (hwnd, wParam, lParam);
    1151 
    1152         case SB_SETICON:
    1153             return STATUSBAR_SetIcon (hwnd, wParam, lParam);
    1154 
    1155         case SB_SETMINHEIGHT:
    1156             return STATUSBAR_SetMinHeight (hwnd, wParam, lParam);
    1157 
    1158         case SB_SETPARTS:       
    1159             return STATUSBAR_SetParts (hwnd, wParam, lParam);
    1160 
    1161         case SB_SETTEXTA:
    1162             return STATUSBAR_SetTextA (hwnd, wParam, lParam);
    1163 
    1164         case SB_SETTEXTW:
    1165             return STATUSBAR_SetTextW (hwnd, wParam, lParam);
    1166 
    1167         case SB_SETTIPTEXTA:
    1168             return STATUSBAR_SetTipTextA (hwnd, wParam, lParam);
    1169 
    1170         case SB_SETTIPTEXTW:
    1171             return STATUSBAR_SetTipTextW (hwnd, wParam, lParam);
    1172 
    1173         case SB_SETUNICODEFORMAT:
    1174             return STATUSBAR_SetUnicodeFormat (hwnd, wParam);
    1175 
    1176         case SB_SIMPLE:
    1177             return STATUSBAR_Simple (hwnd, wParam, lParam);
    1178 
    1179 
    1180         case WM_CREATE:
    1181             return STATUSBAR_WMCreate (hwnd, wParam, lParam);
    1182 
    1183         case WM_DESTROY:
    1184             return STATUSBAR_WMDestroy (hwnd);
    1185 
    1186         case WM_GETFONT:
     1116        case SB_GETBORDERS:
     1117            return STATUSBAR_GetBorders (lParam);
     1118
     1119        case SB_GETICON:
     1120            return STATUSBAR_GetIcon (hwnd, wParam);
     1121
     1122        case SB_GETPARTS:
     1123            return STATUSBAR_GetParts (hwnd, wParam, lParam);
     1124
     1125        case SB_GETRECT:
     1126            return STATUSBAR_GetRect (hwnd, wParam, lParam);
     1127
     1128        case SB_GETTEXTA:
     1129            return STATUSBAR_GetTextA (hwnd, wParam, lParam);
     1130
     1131        case SB_GETTEXTW:
     1132            return STATUSBAR_GetTextW (hwnd, wParam, lParam);
     1133
     1134        case SB_GETTEXTLENGTHA:
     1135        case SB_GETTEXTLENGTHW:
     1136            return STATUSBAR_GetTextLength (hwnd, wParam);
     1137
     1138        case SB_GETTIPTEXTA:
     1139            return STATUSBAR_GetTipTextA (hwnd, wParam, lParam);
     1140
     1141        case SB_GETTIPTEXTW:
     1142            return STATUSBAR_GetTipTextW (hwnd, wParam, lParam);
     1143
     1144        case SB_GETUNICODEFORMAT:
     1145            return STATUSBAR_GetUnicodeFormat (hwnd);
     1146
     1147        case SB_ISSIMPLE:
     1148            return STATUSBAR_IsSimple (hwnd);
     1149
     1150        case SB_SETBKCOLOR:
     1151            return STATUSBAR_SetBkColor (hwnd, wParam, lParam);
     1152
     1153        case SB_SETICON:
     1154            return STATUSBAR_SetIcon (hwnd, wParam, lParam);
     1155
     1156        case SB_SETMINHEIGHT:
     1157            return STATUSBAR_SetMinHeight (hwnd, wParam, lParam);
     1158
     1159        case SB_SETPARTS:
     1160            return STATUSBAR_SetParts (hwnd, wParam, lParam);
     1161
     1162        case SB_SETTEXTA:
     1163            return STATUSBAR_SetTextA (hwnd, wParam, lParam);
     1164
     1165        case SB_SETTEXTW:
     1166            return STATUSBAR_SetTextW (hwnd, wParam, lParam);
     1167
     1168        case SB_SETTIPTEXTA:
     1169            return STATUSBAR_SetTipTextA (hwnd, wParam, lParam);
     1170
     1171        case SB_SETTIPTEXTW:
     1172            return STATUSBAR_SetTipTextW (hwnd, wParam, lParam);
     1173
     1174        case SB_SETUNICODEFORMAT:
     1175            return STATUSBAR_SetUnicodeFormat (hwnd, wParam);
     1176
     1177        case SB_SIMPLE:
     1178            return STATUSBAR_Simple (hwnd, wParam, lParam);
     1179
     1180
     1181        case WM_CREATE:
     1182            return STATUSBAR_WMCreate (hwnd, wParam, lParam);
     1183
     1184        case WM_DESTROY:
     1185            return STATUSBAR_WMDestroy (hwnd);
     1186
     1187        case WM_GETFONT:
    11871188            return STATUSBAR_WMGetFont (hwnd);
    11881189
    1189         case WM_GETTEXT:
     1190        case WM_GETTEXT:
    11901191            return STATUSBAR_WMGetText (hwnd, wParam, lParam);
    11911192
    1192         case WM_GETTEXTLENGTH:
    1193             return STATUSBAR_GetTextLength (hwnd, 0);
    1194 
    1195         case WM_LBUTTONDBLCLK:
     1193        case WM_GETTEXTLENGTH:
     1194            return STATUSBAR_GetTextLength (hwnd, 0);
     1195
     1196        case WM_LBUTTONDBLCLK:
    11961197            return STATUSBAR_SendNotify (hwnd, NM_DBLCLK);
    11971198
    1198         case WM_LBUTTONUP:
    1199             return STATUSBAR_SendNotify (hwnd, NM_CLICK);
    1200 
    1201         case WM_MOUSEMOVE:
     1199        case WM_LBUTTONUP:
     1200            return STATUSBAR_SendNotify (hwnd, NM_CLICK);
     1201
     1202        case WM_MOUSEMOVE:
    12021203            return STATUSBAR_WMMouseMove (hwnd, wParam, lParam);
    12031204
    1204         case WM_NCHITTEST:
     1205        case WM_NCHITTEST:
    12051206            return STATUSBAR_WMNCHitTest (hwnd, wParam, lParam);
    12061207
    1207         case WM_NCLBUTTONDOWN:
    1208             return STATUSBAR_WMNCLButtonDown (hwnd, wParam, lParam);
    1209 
    1210         case WM_NCLBUTTONUP:
    1211             return STATUSBAR_WMNCLButtonUp (hwnd, wParam, lParam);
    1212 
    1213         case WM_PAINT:
    1214             return STATUSBAR_WMPaint (hwnd, wParam);
    1215 
    1216         case WM_RBUTTONDBLCLK:
    1217             return STATUSBAR_SendNotify (hwnd, NM_RDBLCLK);
    1218 
    1219         case WM_RBUTTONUP:
    1220             return STATUSBAR_SendNotify (hwnd, NM_RCLICK);
    1221 
    1222         case WM_SETFONT:
    1223             return STATUSBAR_WMSetFont (hwnd, wParam, lParam);
    1224 
    1225         case WM_SETTEXT:
    1226             return STATUSBAR_WMSetText (hwnd, wParam, lParam);
    1227 
    1228         case WM_SIZE:
    1229             return STATUSBAR_WMSize (hwnd, wParam, lParam);
    1230 
    1231         default:
    1232             if (msg >= WM_USER)
    1233 //              ERR (statusbar, "unknown msg %04x wp=%04x lp=%08lx\n",
    1234 //                   msg, wParam, lParam);
    1235             return DefWindowProcA (hwnd, msg, wParam, lParam);
     1208        case WM_NCLBUTTONDOWN:
     1209            return STATUSBAR_WMNCLButtonDown (hwnd, wParam, lParam);
     1210
     1211        case WM_NCLBUTTONUP:
     1212            return STATUSBAR_WMNCLButtonUp (hwnd, wParam, lParam);
     1213
     1214        case WM_PAINT:
     1215            return STATUSBAR_WMPaint (hwnd, wParam);
     1216
     1217        case WM_RBUTTONDBLCLK:
     1218            return STATUSBAR_SendNotify (hwnd, NM_RDBLCLK);
     1219
     1220        case WM_RBUTTONUP:
     1221            return STATUSBAR_SendNotify (hwnd, NM_RCLICK);
     1222
     1223        case WM_SETFONT:
     1224            return STATUSBAR_WMSetFont (hwnd, wParam, lParam);
     1225
     1226        case WM_SETTEXT:
     1227            return STATUSBAR_WMSetText (hwnd, wParam, lParam);
     1228
     1229        case WM_SIZE:
     1230            return STATUSBAR_WMSize (hwnd, wParam, lParam);
     1231
     1232        default:
     1233//            if (msg >= WM_USER)
     1234//              ERR (statusbar, "unknown msg %04x wp=%04x lp=%08lx\n",
     1235//                   msg, wParam, lParam);
     1236            return DefWindowProcA (hwnd, msg, wParam, lParam);
    12361237    }
    12371238    return 0;
     
    12601261    wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
    12611262    wndClass.lpszClassName = STATUSCLASSNAMEA;
    1262  
     1263
    12631264    RegisterClassA (&wndClass);
    12641265}
     
    12751276{
    12761277    if (GlobalFindAtomA (STATUSCLASSNAMEA))
    1277         UnregisterClassA (STATUSCLASSNAMEA, (HINSTANCE)NULL);
    1278 }
    1279 
     1278        UnregisterClassA (STATUSCLASSNAMEA, (HINSTANCE)NULL);
     1279}
     1280
  • trunk/src/comctl32/toolbar.c

    r94 r110  
    1 /* $Id: toolbar.c,v 1.4 1999-06-10 16:22:02 achimha Exp $ */
     1/* $Id: toolbar.c,v 1.5 1999-06-16 20:25:43 cbratschi Exp $ */
    22/*
    33 * Toolbar control
     
    55 * Copyright 1998,1999 Eric Kohl
    66 * Copyright 1999 Achim Hasenmueller
     7 * Copyright 1999 Christoph Bratschi
    78 *
    89 * TODO:
     
    6566static void
    6667TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
    67                     HDC hdc, INT nState)
     68                    HDC hdc, INT nState)
    6869{
    6970    RECT   rcText = btnPtr->rect;
     
    7475    /* draw text */
    7576    if ((btnPtr->iString > -1) && (btnPtr->iString < infoPtr->nNumStrings)) {
    76         InflateRect (&rcText, -3, -3);
    77         rcText.top += infoPtr->nBitmapHeight;
    78         if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
    79             OffsetRect (&rcText, 1, 1);
    80 
    81         hOldFont = SelectObject (hdc, infoPtr->hFont);
    82         nOldBkMode = SetBkMode (hdc, TRANSPARENT);
    83         if (!(nState & TBSTATE_ENABLED)) {
    84             clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
    85             OffsetRect (&rcText, 1, 1);
    86             DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
    87                         &rcText, infoPtr->dwDTFlags);
    88             SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
    89             OffsetRect (&rcText, -1, -1);
    90             DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
    91                         &rcText, infoPtr->dwDTFlags);
    92         }
    93         else if (nState & TBSTATE_INDETERMINATE) {
    94             clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
    95             DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
    96                         &rcText, infoPtr->dwDTFlags);
    97         }
    98         else {
    99             clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
    100             DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
    101                         &rcText, infoPtr->dwDTFlags);
    102         }
    103 
    104         SetTextColor (hdc, clrOld);
    105         SelectObject (hdc, hOldFont);
    106         if (nOldBkMode != TRANSPARENT)
    107             SetBkMode (hdc, nOldBkMode);
     77        InflateRect (&rcText, -3, -3);
     78        rcText.top += infoPtr->nBitmapHeight;
     79        if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
     80            OffsetRect (&rcText, 1, 1);
     81
     82        hOldFont = SelectObject (hdc, infoPtr->hFont);
     83        nOldBkMode = SetBkMode (hdc, TRANSPARENT);
     84        if (!(nState & TBSTATE_ENABLED)) {
     85            clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
     86            OffsetRect (&rcText, 1, 1);
     87            DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
     88                        &rcText, infoPtr->dwDTFlags);
     89            SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
     90            OffsetRect (&rcText, -1, -1);
     91            DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
     92                        &rcText, infoPtr->dwDTFlags);
     93        }
     94        else if (nState & TBSTATE_INDETERMINATE) {
     95            clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
     96            DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
     97                        &rcText, infoPtr->dwDTFlags);
     98        }
     99        else {
     100            clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
     101            DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
     102                        &rcText, infoPtr->dwDTFlags);
     103        }
     104
     105        SetTextColor (hdc, clrOld);
     106        SelectObject (hdc, hOldFont);
     107        if (nOldBkMode != TRANSPARENT)
     108            SetBkMode (hdc, nOldBkMode);
    108109    }
    109110}
     
    123124static void
    124125TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
    125                     HDC hdc, INT x, INT y)
     126                    HDC hdc, INT x, INT y)
    126127{
    127128    /* FIXME: this function is a hack since it uses image list
    128               internals directly */
     129              internals directly */
    129130
    130131    HDC hdcImageList = CreateCompatibleDC (0);
     
    142143    SetTextColor (hdcImageList, RGB(0, 0, 0));
    143144    BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
    144               hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
     145              hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
    145146
    146147#if 0
     
    149150    SetBkColor (hdcImageList, RGB(0, 0, 0));
    150151    BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
    151               hdcImageList, himl->cx * btnPtr->iBitmap, 0, MERGEPAINT);
     152              hdcImageList, himl->cx * btnPtr->iBitmap, 0, MERGEPAINT);
    152153#endif
    153154
     
    155156    SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
    156157    BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
    157               hdcMask, 0, 0, 0xB8074A);
     158              hdcMask, 0, 0, 0xB8074A);
    158159
    159160    SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
    160161    BitBlt (hdc, x, y, himl->cx, himl->cy,
    161               hdcMask, 0, 0, 0xB8074A);
     162              hdcMask, 0, 0, 0xB8074A);
    162163
    163164    DeleteObject (hbmMask);
     
    175176
    176177    if (btnPtr->fsState & TBSTATE_HIDDEN)
    177         return;
     178        return;
    178179
    179180    rc = btnPtr->rect;
    180181    if (btnPtr->fsStyle & TBSTYLE_SEP) {
    181         if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->idCommand == 0))
    182             TOOLBAR_DrawFlatSeparator (&btnPtr->rect, hdc);
    183         return;
     182        if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->idCommand == 0))
     183            TOOLBAR_DrawFlatSeparator (&btnPtr->rect, hdc);
     184        return;
    184185    }
    185186
    186187    /* disabled */
    187188    if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
    188         DrawEdge (hdc, &rc, EDGE_RAISED,
    189                     BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    190 
    191         if (dwStyle & TBSTYLE_FLAT) {
    192 /*          if (infoPtr->himlDis) */
    193                 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
    194                                 rc.left+1, rc.top+1, ILD_NORMAL);
    195 /*          else */
    196 /*              TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); */
    197         }
    198         else
    199             TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
    200 
    201         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
    202         return;
     189        DrawEdge (hdc, &rc, EDGE_RAISED,
     190                    BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     191
     192        if (dwStyle & TBSTYLE_FLAT) {
     193/*          if (infoPtr->himlDis) */
     194                ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
     195                                rc.left+1, rc.top+1, ILD_NORMAL);
     196/*          else */
     197/*              TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); */
     198        }
     199        else
     200            TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
     201
     202        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
     203        return;
    203204    }
    204205
    205206    /* pressed TBSTYLE_BUTTON */
    206207    if (btnPtr->fsState & TBSTATE_PRESSED) {
    207         DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
    208         ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
    209                         rc.left+2, rc.top+2, ILD_NORMAL);
    210         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
    211         return;
     208        DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
     209        ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
     210                        rc.left+2, rc.top+2, ILD_NORMAL);
     211        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
     212        return;
    212213    }
    213214
    214215    /* checked TBSTYLE_CHECK*/
    215216    if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
    216         (btnPtr->fsState & TBSTATE_CHECKED)) {
    217         if (dwStyle & TBSTYLE_FLAT)
    218             DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
    219                         BF_RECT | BF_MIDDLE | BF_ADJUST);
    220         else
    221             DrawEdge (hdc, &rc, EDGE_SUNKEN,
    222                         BF_RECT | BF_MIDDLE | BF_ADJUST);
    223 
    224         TOOLBAR_DrawPattern (hdc, &rc);
    225         if (dwStyle & TBSTYLE_FLAT)
    226         {
    227             if (infoPtr->himlDef != NULL)
    228             ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    229                             rc.left+2, rc.top+2, ILD_NORMAL);
    230         else
    231             ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
    232                             rc.left+2, rc.top+2, ILD_NORMAL);
    233         }
    234         else
    235             ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
    236                             rc.left+2, rc.top+2, ILD_NORMAL);
    237         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
    238         return;
    239     }
    240 
    241     /* indeterminate */ 
     217        (btnPtr->fsState & TBSTATE_CHECKED)) {
     218        if (dwStyle & TBSTYLE_FLAT)
     219            DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
     220                        BF_RECT | BF_MIDDLE | BF_ADJUST);
     221        else
     222            DrawEdge (hdc, &rc, EDGE_SUNKEN,
     223                        BF_RECT | BF_MIDDLE | BF_ADJUST);
     224
     225        TOOLBAR_DrawPattern (hdc, &rc);
     226        if (dwStyle & TBSTYLE_FLAT)
     227        {
     228            if (infoPtr->himlDef != NULL)
     229            ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
     230                            rc.left+2, rc.top+2, ILD_NORMAL);
     231        else
     232            ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
     233                            rc.left+2, rc.top+2, ILD_NORMAL);
     234        }
     235        else
     236            ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
     237                            rc.left+2, rc.top+2, ILD_NORMAL);
     238        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
     239        return;
     240    }
     241
     242    /* indeterminate */
    242243    if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
    243         DrawEdge (hdc, &rc, EDGE_RAISED,
    244                     BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    245 
    246         TOOLBAR_DrawPattern (hdc, &rc);
    247         TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
    248         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
    249         return;
     244        DrawEdge (hdc, &rc, EDGE_RAISED,
     245                    BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     246
     247        TOOLBAR_DrawPattern (hdc, &rc);
     248        TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
     249        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
     250        return;
    250251    }
    251252
    252253    if (dwStyle & TBSTYLE_FLAT)
    253254    {
    254         if(btnPtr->bHot)
    255             DrawEdge (hdc, &rc, BDR_RAISEDINNER,
    256                        BF_RECT | BF_MIDDLE | BF_SOFT);
    257 
    258         if(infoPtr->himlDef != NULL)
    259             ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    260                             rc.left +2, rc.top +2, ILD_NORMAL);
    261         else
    262             ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
    263                             rc.left +2, rc.top +2, ILD_NORMAL);
     255        if(btnPtr->bHot)
     256            DrawEdge (hdc, &rc, BDR_RAISEDINNER,
     257                       BF_RECT | BF_MIDDLE | BF_SOFT);
     258
     259        if(infoPtr->himlDef != NULL)
     260            ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
     261                            rc.left +2, rc.top +2, ILD_NORMAL);
     262        else
     263            ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
     264                            rc.left +2, rc.top +2, ILD_NORMAL);
    264265    }
    265266    else{
    266267    /* normal state */
    267268    DrawEdge (hdc, &rc, EDGE_RAISED,
    268                 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    269 
    270         ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
    271                         rc.left+1, rc.top+1, ILD_NORMAL);
     269                BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     270
     271        ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
     272                        rc.left+1, rc.top+1, ILD_NORMAL);
    272273    }
    273274
     
    286287    btnPtr = infoPtr->buttons;
    287288    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
    288         TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
     289        TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
    289290}
    290291
     
    307308    btnPtr = infoPtr->buttons;
    308309    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
    309         if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
    310             (btnPtr->iString > -1) &&
    311             (btnPtr->iString < infoPtr->nNumStrings)) {
    312             LPWSTR lpText = infoPtr->strings[btnPtr->iString];
    313             GetTextExtentPoint32W (hdc, lpText, lstrlenW (lpText), &sz);
    314             if (sz.cx > lpSize->cx)
    315                 lpSize->cx = sz.cx;
    316             if (sz.cy > lpSize->cy)
    317                 lpSize->cy = sz.cy;
    318         }
     310        if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
     311            (btnPtr->iString > -1) &&
     312            (btnPtr->iString < infoPtr->nNumStrings)) {
     313            LPWSTR lpText = infoPtr->strings[btnPtr->iString];
     314            GetTextExtentPoint32W (hdc, lpText, lstrlenW (lpText), &sz);
     315            if (sz.cx > lpSize->cx)
     316                lpSize->cx = sz.cx;
     317            if (sz.cy > lpSize->cy)
     318                lpSize->cy = sz.cy;
     319        }
    319320    }
    320321
     
    326327
    327328/***********************************************************************
    328 *               TOOLBAR_WrapToolbar
     329*               TOOLBAR_WrapToolbar
    329330*
    330 * This function walks through the buttons and seperators in the 
    331 * toolbar, and sets the TBSTATE_WRAP flag only on those items where 
    332 * wrapping should occur based on the width of the toolbar window. 
    333 * It does *not* calculate button placement itself.  That task 
    334 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage 
    335 * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE 
     331* This function walks through the buttons and seperators in the
     332* toolbar, and sets the TBSTATE_WRAP flag only on those items where
     333* wrapping should occur based on the width of the toolbar window.
     334* It does *not* calculate button placement itself.  That task
     335* takes place in TOOLBAR_CalcToolbar. If the program wants to manage
     336* the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE
    336337* flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
    337 */ 
     338*/
    338339
    339340static void
     
    347348    BOOL bWrap, bButtonWrap;
    348349
    349     /*  When the toolbar window style is not TBSTYLE_WRAPABLE,  */
    350     /*  no layout is necessary. Applications may use this style */
    351     /*  to perform their own layout on the toolbar.             */
     350    /*  When the toolbar window style is not TBSTYLE_WRAPABLE,  */
     351    /*  no layout is necessary. Applications may use this style */
     352    /*  to perform their own layout on the toolbar.             */
    352353    if( !(dwStyle & TBSTYLE_WRAPABLE) )
    353         return;
     354        return;
    354355
    355356    btnPtr = infoPtr->buttons;
     
    362363    for (i = 0; i < infoPtr->nNumButtons; i++ )
    363364    {
    364         bWrap = FALSE;
    365         btnPtr[i].fsState &= ~TBSTATE_WRAP;
    366        
    367         if (btnPtr[i].fsState & TBSTATE_HIDDEN)
    368             continue;
    369 
    370         /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
    371         /* it is the actual width of the separator. This is used for */
    372         /* custom controls in toolbars.                              */
    373         if (btnPtr[i].fsStyle & TBSTYLE_SEP)
    374             cx = (btnPtr[i].iBitmap > 0) ? 
    375                         btnPtr[i].iBitmap : SEPARATOR_WIDTH;
    376         else
    377             cx = infoPtr->nButtonWidth;
    378 
    379         /* Two or more adjacent separators form a separator group.   */
    380         /* The first separator in a group should be wrapped to the   */
    381         /* next row if the previous wrapping is on a button.         */
    382         if( bButtonWrap &&
    383                 (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
    384                 (i + 1 < infoPtr->nNumButtons ) &&
    385                 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
    386         {
    387             btnPtr[i].fsState |= TBSTATE_WRAP;
    388             x = infoPtr->nIndent;
    389             i++;
    390             bButtonWrap = FALSE;
    391             continue;
    392         }
    393 
    394         /* The layout makes sure the bitmap is visible, but not the button. */
    395         if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
    396                  > infoPtr->nWidth )
    397         {
    398             BOOL bFound = FALSE;
    399 
    400             /*  If the current button is a separator and not hidden,  */
    401             /*  go to the next until it reaches a non separator.      */
    402             /*  Wrap the last separator if it is before a button.     */
    403             while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
    404                         (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
    405                         i < infoPtr->nNumButtons )
    406             {
    407                 i++;
    408                 bFound = TRUE;
    409             }
    410    
    411             if( bFound && i < infoPtr->nNumButtons )
    412             {
    413                 i--;
    414                 btnPtr[i].fsState |= TBSTATE_WRAP;
    415                 x = infoPtr->nIndent;
    416                 bButtonWrap = FALSE;
    417                 continue;
    418             }
    419             else if ( i >= infoPtr->nNumButtons)
    420                 break;
    421 
    422             /*  If the current button is not a separator, find the last  */
    423             /*  separator and wrap it.                                  */
    424             for ( j = i - 1; j >= 0  &&  !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
    425             {
    426                 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
    427                         !(btnPtr[j].fsState & TBSTATE_HIDDEN))
    428                 {
    429                     bFound = TRUE;
    430                     i = j;
    431                     x = infoPtr->nIndent;
    432                     btnPtr[j].fsState |= TBSTATE_WRAP;
    433                     bButtonWrap = FALSE;
    434                     break;
    435                 }
    436             }
    437 
    438             /*  If no separator available for wrapping, wrap one of     */
    439             /*  non-hidden previous button.                             */
    440             if (!bFound)
    441             {
    442                 for ( j = i - 1;
    443                         j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
    444                 {
    445                     if (btnPtr[j].fsState & TBSTATE_HIDDEN)
    446                         continue;
    447 
    448                     bFound = TRUE;
    449                     i = j;
    450                     x = infoPtr->nIndent;
    451                     btnPtr[j].fsState |= TBSTATE_WRAP;
    452                     bButtonWrap = TRUE;
    453                     break;
    454                 }
    455             }
    456 
    457             /* If all above failed, wrap the current button. */
    458             if (!bFound) 
    459             {
    460                 btnPtr[i].fsState |= TBSTATE_WRAP;
    461                 bFound = TRUE;
    462                 x = infoPtr->nIndent;
    463                 if (btnPtr[i].fsState & TBSTYLE_SEP )
    464                     bButtonWrap = FALSE;
    465                 else
    466                     bButtonWrap = TRUE;
    467             }               
    468         }
    469         else
    470             x += cx;
    471     }
    472 }
    473                                                                                        
     365        bWrap = FALSE;
     366        btnPtr[i].fsState &= ~TBSTATE_WRAP;
     367
     368        if (btnPtr[i].fsState & TBSTATE_HIDDEN)
     369            continue;
     370
     371        /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
     372        /* it is the actual width of the separator. This is used for */
     373        /* custom controls in toolbars.                              */
     374        if (btnPtr[i].fsStyle & TBSTYLE_SEP)
     375            cx = (btnPtr[i].iBitmap > 0) ?
     376                        btnPtr[i].iBitmap : SEPARATOR_WIDTH;
     377        else
     378            cx = infoPtr->nButtonWidth;
     379
     380        /* Two or more adjacent separators form a separator group.   */
     381        /* The first separator in a group should be wrapped to the   */
     382        /* next row if the previous wrapping is on a button.         */
     383        if( bButtonWrap &&
     384                (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
     385                (i + 1 < infoPtr->nNumButtons ) &&
     386                (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
     387        {
     388            btnPtr[i].fsState |= TBSTATE_WRAP;
     389            x = infoPtr->nIndent;
     390            i++;
     391            bButtonWrap = FALSE;
     392            continue;
     393        }
     394
     395        /* The layout makes sure the bitmap is visible, but not the button. */
     396        if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
     397                 > infoPtr->nWidth )
     398        {
     399            BOOL bFound = FALSE;
     400
     401            /*  If the current button is a separator and not hidden,  */
     402            /*  go to the next until it reaches a non separator.      */
     403            /*  Wrap the last separator if it is before a button.     */
     404            while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
     405                        (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
     406                        i < infoPtr->nNumButtons )
     407            {
     408                i++;
     409                bFound = TRUE;
     410            }
     411
     412            if( bFound && i < infoPtr->nNumButtons )
     413            {
     414                i--;
     415                btnPtr[i].fsState |= TBSTATE_WRAP;
     416                x = infoPtr->nIndent;
     417                bButtonWrap = FALSE;
     418                continue;
     419            }
     420            else if ( i >= infoPtr->nNumButtons)
     421                break;
     422
     423            /*  If the current button is not a separator, find the last  */
     424            /*  separator and wrap it.                                  */
     425            for ( j = i - 1; j >= 0  &&  !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
     426            {
     427                if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
     428                        !(btnPtr[j].fsState & TBSTATE_HIDDEN))
     429                {
     430                    bFound = TRUE;
     431                    i = j;
     432                    x = infoPtr->nIndent;
     433                    btnPtr[j].fsState |= TBSTATE_WRAP;
     434                    bButtonWrap = FALSE;
     435                    break;
     436                }
     437            }
     438
     439            /*  If no separator available for wrapping, wrap one of     */
     440            /*  non-hidden previous button.                             */
     441            if (!bFound)
     442            {
     443                for ( j = i - 1;
     444                        j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
     445                {
     446                    if (btnPtr[j].fsState & TBSTATE_HIDDEN)
     447                        continue;
     448
     449                    bFound = TRUE;
     450                    i = j;
     451                    x = infoPtr->nIndent;
     452                    btnPtr[j].fsState |= TBSTATE_WRAP;
     453                    bButtonWrap = TRUE;
     454                    break;
     455                }
     456            }
     457
     458            /* If all above failed, wrap the current button. */
     459            if (!bFound)
     460            {
     461                btnPtr[i].fsState |= TBSTATE_WRAP;
     462                bFound = TRUE;
     463                x = infoPtr->nIndent;
     464                if (btnPtr[i].fsState & TBSTYLE_SEP )
     465                    bButtonWrap = FALSE;
     466                else
     467                    bButtonWrap = TRUE;
     468            }
     469        }
     470        else
     471            x += cx;
     472    }
     473}
     474
    474475/***********************************************************************
    475 *               TOOLBAR_CalcToolbar
     476*               TOOLBAR_CalcToolbar
    476477*
    477 * This function calculates button and separator placement. It first 
    478 * calculates the button sizes, gets the toolbar window width and then 
    479 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap 
     478* This function calculates button and separator placement. It first
     479* calculates the button sizes, gets the toolbar window width and then
     480* calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
    480481* on. It assigns a new location to each item and sends this location to
    481 * the tooltip window if appropriate. Finally, it updates the rcBound 
    482 * rect and calculates the new required toolbar window height. 
    483 */ 
     482* the tooltip window if appropriate. Finally, it updates the rcBound
     483* rect and calculates the new required toolbar window height.
     484*/
    484485
    485486static void
     
    497498
    498499    if (sizeString.cy > 0)
    499         infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6;
     500        infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6;
    500501    else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
    501         infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
     502        infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
    502503
    503504    if (sizeString.cx > infoPtr->nBitmapWidth)
    504         infoPtr->nButtonWidth = sizeString.cx + 6;
     505        infoPtr->nButtonWidth = sizeString.cx + 6;
    505506    else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
    506         infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
     507        infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
    507508
    508509    TOOLBAR_WrapToolbar( hwnd );
     
    525526    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
    526527    {
    527         bWrap = FALSE;
    528         if (btnPtr->fsState & TBSTATE_HIDDEN)
    529         {
    530             SetRectEmpty (&btnPtr->rect);
    531             continue;
    532         }
    533 
    534             /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
    535             /* it is the actual width of the separator. This is used for */
    536             /* custom controls in toolbars.                              */
    537         if (btnPtr->fsStyle & TBSTYLE_SEP)
    538                 cx = (btnPtr->iBitmap > 0) ?
    539                      btnPtr->iBitmap : SEPARATOR_WIDTH;
    540         else
    541             cx = infoPtr->nButtonWidth;
    542 
    543         if (btnPtr->fsState & TBSTATE_WRAP )
    544                     bWrap = TRUE;
    545 
    546         SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
    547 
    548         if (infoPtr->rcBound.left > x)
    549             infoPtr->rcBound.left = x;
    550         if (infoPtr->rcBound.right < x + cx)
    551             infoPtr->rcBound.right = x + cx;
    552         if (infoPtr->rcBound.bottom < y + cy)
    553             infoPtr->rcBound.bottom = y + cy;
    554 
    555         /* Set the toolTip only for non-hidden, non-separator button */
    556         if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
    557         {
    558             TTTOOLINFOA ti;
    559 
    560             ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    561             ti.cbSize = sizeof(TTTOOLINFOA);
    562             ti.hwnd = hwnd;
    563             ti.uId = btnPtr->idCommand;
    564             ti.rect = btnPtr->rect;
    565             SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
    566                             0, (LPARAM)&ti);
    567         }
    568 
    569         /* btnPtr->nRow is zero based. The space between the rows is    */
    570         /* also considered as a row.                                    */
    571         btnPtr->nRow = nRows + nSepRows;
    572         if( bWrap )
    573         {
    574             if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
    575             y += cy;
    576             else
    577             {   
    578                 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
    579                 /* it is the actual width of the separator. This is used for */
    580                 /* custom controls in toolbars.                              */
    581                 y += cy + ( (btnPtr->iBitmap > 0 ) ?
    582                         btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
    583              
    584                 /* nSepRows is used to calculate the extra height follwoing  */         
    585                 /* the last row.                                             */
    586                 nSepRows++;
    587             }
    588             x = infoPtr->nIndent;
    589                 nRows++;
    590         }
    591         else
    592             x += cx;
     528        bWrap = FALSE;
     529        if (btnPtr->fsState & TBSTATE_HIDDEN)
     530        {
     531            SetRectEmpty (&btnPtr->rect);
     532            continue;
     533        }
     534
     535            /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
     536            /* it is the actual width of the separator. This is used for */
     537            /* custom controls in toolbars.                              */
     538        if (btnPtr->fsStyle & TBSTYLE_SEP)
     539                cx = (btnPtr->iBitmap > 0) ?
     540                     btnPtr->iBitmap : SEPARATOR_WIDTH;
     541        else
     542            cx = infoPtr->nButtonWidth;
     543
     544        if (btnPtr->fsState & TBSTATE_WRAP )
     545                    bWrap = TRUE;
     546
     547        SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
     548
     549        if (infoPtr->rcBound.left > x)
     550            infoPtr->rcBound.left = x;
     551        if (infoPtr->rcBound.right < x + cx)
     552            infoPtr->rcBound.right = x + cx;
     553        if (infoPtr->rcBound.bottom < y + cy)
     554            infoPtr->rcBound.bottom = y + cy;
     555
     556        /* Set the toolTip only for non-hidden, non-separator button */
     557        if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
     558        {
     559            TTTOOLINFOA ti;
     560
     561            ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     562            ti.cbSize = sizeof(TTTOOLINFOA);
     563            ti.hwnd = hwnd;
     564            ti.uId = btnPtr->idCommand;
     565            ti.rect = btnPtr->rect;
     566            SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
     567                            0, (LPARAM)&ti);
     568        }
     569
     570        /* btnPtr->nRow is zero based. The space between the rows is    */
     571        /* also considered as a row.                                    */
     572        btnPtr->nRow = nRows + nSepRows;
     573        if( bWrap )
     574        {
     575            if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
     576            y += cy;
     577            else
     578            {
     579                /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
     580                /* it is the actual width of the separator. This is used for */
     581                /* custom controls in toolbars.                              */
     582                y += cy + ( (btnPtr->iBitmap > 0 ) ?
     583                        btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
     584
     585                /* nSepRows is used to calculate the extra height follwoing  */
     586                /* the last row.                                             */
     587                nSepRows++;
     588            }
     589            x = infoPtr->nIndent;
     590                nRows++;
     591        }
     592        else
     593            x += cx;
    593594    }
    594595
     
    596597    infoPtr->nRows = nRows + nSepRows + 1;
    597598
    598     /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following   */
    599     /* the last row.                                                    */
    600     infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight + 
    601                         nSepRows * SEPARATOR_WIDTH * 2 / 3 +
    602                         nSepRows * (infoPtr->nBitmapHeight + 1) +
    603                         BOTTOM_BORDER;
     599    /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following   */
     600    /* the last row.                                                    */
     601    infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
     602                        nSepRows * SEPARATOR_WIDTH * 2 / 3 +
     603                        nSepRows * (infoPtr->nBitmapHeight + 1) +
     604                        BOTTOM_BORDER;
    604605//    TRACE (toolbar, "toolbar height %d\n", infoPtr->nHeight);
    605606}
     
    612613    TBUTTON_INFO *btnPtr;
    613614    INT i;
    614    
     615
    615616    btnPtr = infoPtr->buttons;
    616617    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
    617         if (btnPtr->fsState & TBSTATE_HIDDEN)
    618             continue;
    619 
    620         if (btnPtr->fsStyle & TBSTYLE_SEP) {
    621             if (PtInRect (&btnPtr->rect, *lpPt)) {
    622 //              TRACE (toolbar, " ON SEPARATOR %d!\n", i);
    623                 return -i;
    624             }
    625         }
    626         else {
    627             if (PtInRect (&btnPtr->rect, *lpPt)) {
    628 //              TRACE (toolbar, " ON BUTTON %d!\n", i);
    629                 return i;
    630             }
    631         }
     618        if (btnPtr->fsState & TBSTATE_HIDDEN)
     619            continue;
     620
     621        if (btnPtr->fsStyle & TBSTYLE_SEP) {
     622            if (PtInRect (&btnPtr->rect, *lpPt)) {
     623//              TRACE (toolbar, " ON SEPARATOR %d!\n", i);
     624                return -i;
     625            }
     626        }
     627        else {
     628            if (PtInRect (&btnPtr->rect, *lpPt)) {
     629//              TRACE (toolbar, " ON BUTTON %d!\n", i);
     630                return i;
     631            }
     632        }
    632633    }
    633634
     
    645646    btnPtr = infoPtr->buttons;
    646647    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
    647         if (btnPtr->idCommand == idCommand) {
    648 //          TRACE (toolbar, "command=%d index=%d\n", idCommand, i);
    649             return i;
    650         }
     648        if (btnPtr->idCommand == idCommand) {
     649//          TRACE (toolbar, "command=%d index=%d\n", idCommand, i);
     650            return i;
     651        }
    651652    }
    652653//    TRACE (toolbar, "no index found for command=%d\n", idCommand);
     
    662663
    663664    if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
    664         return -1;
     665        return -1;
    665666
    666667    /* check index button */
    667668    btnPtr = &infoPtr->buttons[nIndex];
    668669    if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
    669         if (btnPtr->fsState & TBSTATE_CHECKED)
    670             return nIndex;
     670        if (btnPtr->fsState & TBSTATE_CHECKED)
     671            return nIndex;
    671672    }
    672673
     
    674675    nRunIndex = nIndex - 1;
    675676    while (nRunIndex >= 0) {
    676         btnPtr = &infoPtr->buttons[nRunIndex];
    677         if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
    678             if (btnPtr->fsState & TBSTATE_CHECKED)
    679                 return nRunIndex;
    680         }
    681         else
    682             break;
    683         nRunIndex--;
     677        btnPtr = &infoPtr->buttons[nRunIndex];
     678        if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
     679            if (btnPtr->fsState & TBSTATE_CHECKED)
     680                return nRunIndex;
     681        }
     682        else
     683            break;
     684        nRunIndex--;
    684685    }
    685686
     
    687688    nRunIndex = nIndex + 1;
    688689    while (nRunIndex < infoPtr->nNumButtons) {
    689         btnPtr = &infoPtr->buttons[nRunIndex]; 
    690         if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
    691             if (btnPtr->fsState & TBSTATE_CHECKED)
    692                 return nRunIndex;
    693         }
    694         else
    695             break;
    696         nRunIndex++;
     690        btnPtr = &infoPtr->buttons[nRunIndex];
     691        if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
     692            if (btnPtr->fsState & TBSTATE_CHECKED)
     693                return nRunIndex;
     694        }
     695        else
     696            break;
     697        nRunIndex++;
    697698    }
    698699
     
    703704static VOID
    704705TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
    705                     WPARAM wParam, LPARAM lParam)
     706                    WPARAM wParam, LPARAM lParam)
    706707{
    707708    MSG msg;
     
    731732    switch (uMsg)
    732733    {
    733         case WM_INITDIALOG:
    734             infoPtr = (TOOLBAR_INFO *)lParam;
    735             SetWindowLongA (hwnd, DWL_USER, (DWORD)infoPtr);
    736 
    737             hDsa = DSA_Create (sizeof(TBUTTON_INFO), 5);
    738 
    739             if (infoPtr)
    740             {
    741                 TBUTTON_INFO *btnPtr;
    742                 INT i;
    743 
    744                 /* insert 'virtual' separator button into 'available buttons' list */
    745                 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
    746 
    747                 /* copy all buttons and append them to the right listbox */             
    748                 btnPtr = infoPtr->buttons;
    749                 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
    750                 {
    751                     DSA_InsertItem (hDsa, i, btnPtr);
    752 
    753                     if (btnPtr->fsState & TBSTATE_HIDDEN)
    754                     {
    755                         SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
    756                     }
    757                     else
    758                     {
    759                         SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
    760                     }
    761                 }
    762 
    763                 /* append 'virtual' sepatator button to the 'toolbar buttons' list */
    764                 /* TODO */
    765             }
    766             return TRUE;
    767 
    768         case WM_CLOSE:
    769             EndDialog(hwnd, FALSE);
    770             return TRUE;
    771 
    772         case WM_COMMAND:
    773             switch (LOWORD(wParam))
    774             {
    775                 case IDCANCEL:
    776                     EndDialog(hwnd, FALSE);
    777                     break;
    778             }
    779             return TRUE;
    780 
    781         case WM_DESTROY:
    782             if (hDsa)
    783                 DSA_Destroy (hDsa);
    784             return TRUE;
    785 
    786         case WM_DRAWITEM:
    787             if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
    788             {
    789                 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
    790                 RECT rcButton;
    791                 RECT rcText;
    792                 HPEN hOldPen;
    793                 HBRUSH hOldBrush;
    794                 COLORREF oldText = 0;
    795                 COLORREF oldBk = 0;
    796 
    797 //              FIXME(toolbar, "action: %x itemState: %x\n",
    798 //                    lpdis->itemAction, lpdis->itemState);             
    799 
    800                 if (lpdis->itemState & ODS_FOCUS)
    801                 {
    802                     oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
    803                     oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
    804                 }
    805 
    806                 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
    807                 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
    808 
    809                 /* fill background rectangle */
    810                 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
    811                            lpdis->rcItem.right, lpdis->rcItem.bottom);
    812 
    813                 /* calculate button and text rectangles */
    814                 CopyRect (&rcButton, &lpdis->rcItem);
    815                 InflateRect (&rcButton, -1, -1);
    816                 CopyRect (&rcText, &rcButton);
    817                 rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6;
    818                 rcText.left = rcButton.right + 2;
    819 
    820                 /* draw focus rectangle */
    821                 if (lpdis->itemState & ODS_FOCUS)
    822                     DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
    823 
    824                 /* draw button */
    825                 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
    826 
    827                 /* draw text */
    828                 if (wParam == IDC_AVAILBTN_LBOX && lpdis->itemID == 0)
    829                     DrawTextA (lpdis->hDC, "Separator", -1, &rcText,
    830                                DT_LEFT | DT_VCENTER | DT_SINGLELINE);
    831 
    832                 if (lpdis->itemState & ODS_FOCUS)
    833                 {
    834                     SetBkColor (lpdis->hDC, oldBk);
    835                     SetTextColor (lpdis->hDC, oldText);
    836                 }
    837 
    838                 SelectObject (lpdis->hDC, hOldBrush);
    839                 SelectObject (lpdis->hDC, hOldPen);
    840 
    841                 return TRUE;
    842             }
    843             return FALSE;
    844 
    845         case WM_MEASUREITEM:
    846             if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
    847             {
    848                 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
    849 
    850                 if (infoPtr)
    851                     lpmis->itemHeight = infoPtr->nBitmapHeight + 8;
    852                 else
    853                     lpmis->itemHeight = 16 + 8; /* default height */
    854 
    855                 return TRUE;
    856             }
    857             return FALSE;
    858 
    859         default:
    860             return FALSE;
     734        case WM_INITDIALOG:
     735            infoPtr = (TOOLBAR_INFO *)lParam;
     736            SetWindowLongA (hwnd, DWL_USER, (DWORD)infoPtr);
     737
     738            hDsa = DSA_Create (sizeof(TBUTTON_INFO), 5);
     739
     740            if (infoPtr)
     741            {
     742                TBUTTON_INFO *btnPtr;
     743                INT i;
     744
     745                /* insert 'virtual' separator button into 'available buttons' list */
     746                SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
     747
     748                /* copy all buttons and append them to the right listbox */
     749                btnPtr = infoPtr->buttons;
     750                for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
     751                {
     752                    DSA_InsertItem (hDsa, i, btnPtr);
     753
     754                    if (btnPtr->fsState & TBSTATE_HIDDEN)
     755                    {
     756                        SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
     757                    }
     758                    else
     759                    {
     760                        SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
     761                    }
     762                }
     763
     764                /* append 'virtual' sepatator button to the 'toolbar buttons' list */
     765                /* TODO */
     766            }
     767            return TRUE;
     768
     769        case WM_CLOSE:
     770            EndDialog(hwnd, FALSE);
     771            return TRUE;
     772
     773        case WM_COMMAND:
     774            switch (LOWORD(wParam))
     775            {
     776                case IDCANCEL:
     777                    EndDialog(hwnd, FALSE);
     778                    break;
     779            }
     780            return TRUE;
     781
     782        case WM_DESTROY:
     783            if (hDsa)
     784                DSA_Destroy (hDsa);
     785            return TRUE;
     786
     787        case WM_DRAWITEM:
     788            if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
     789            {
     790                LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
     791                RECT rcButton;
     792                RECT rcText;
     793                HPEN hOldPen;
     794                HBRUSH hOldBrush;
     795                COLORREF oldText = 0;
     796                COLORREF oldBk = 0;
     797
     798//              FIXME(toolbar, "action: %x itemState: %x\n",
     799//                    lpdis->itemAction, lpdis->itemState);
     800
     801                if (lpdis->itemState & ODS_FOCUS)
     802                {
     803                    oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
     804                    oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
     805                }
     806
     807                hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
     808                hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
     809
     810                /* fill background rectangle */
     811                Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
     812                           lpdis->rcItem.right, lpdis->rcItem.bottom);
     813
     814                /* calculate button and text rectangles */
     815                CopyRect (&rcButton, &lpdis->rcItem);
     816                InflateRect (&rcButton, -1, -1);
     817                CopyRect (&rcText, &rcButton);
     818                rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6;
     819                rcText.left = rcButton.right + 2;
     820
     821                /* draw focus rectangle */
     822                if (lpdis->itemState & ODS_FOCUS)
     823                    DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
     824
     825                /* draw button */
     826                DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
     827
     828                /* draw text */
     829                if (wParam == IDC_AVAILBTN_LBOX && lpdis->itemID == 0)
     830                    DrawTextA (lpdis->hDC, "Separator", -1, &rcText,
     831                               DT_LEFT | DT_VCENTER | DT_SINGLELINE);
     832
     833                if (lpdis->itemState & ODS_FOCUS)
     834                {
     835                    SetBkColor (lpdis->hDC, oldBk);
     836                    SetTextColor (lpdis->hDC, oldText);
     837                }
     838
     839                SelectObject (lpdis->hDC, hOldBrush);
     840                SelectObject (lpdis->hDC, hOldPen);
     841
     842                return TRUE;
     843            }
     844            return FALSE;
     845
     846        case WM_MEASUREITEM:
     847            if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
     848            {
     849                MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
     850
     851                if (infoPtr)
     852                    lpmis->itemHeight = infoPtr->nBitmapHeight + 8;
     853                else
     854                    lpmis->itemHeight = 16 + 8; /* default height */
     855
     856                return TRUE;
     857            }
     858            return FALSE;
     859
     860        default:
     861            return FALSE;
    861862    }
    862863}
     
    875876
    876877    if ((!lpAddBmp) || ((INT)wParam <= 0))
    877         return -1;
     878        return -1;
    878879
    879880//    TRACE (toolbar, "adding %d bitmaps!\n", wParam);
    880881
    881882    if (!(infoPtr->himlStd)) {
    882         /* create new standard image list */
    883 
    884 //      TRACE (toolbar, "creating standard image list!\n");
    885 
    886 
    887         /* Windows resize all the buttons to the size of a newly added STandard Image*/
    888         /* TODO: The resizing  should be done each time a standard image is added*/
    889         if (lpAddBmp->hInst == HINST_COMMCTRL)
    890         {
    891 
    892             if (lpAddBmp->nID & 1)
    893             {
    894                 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
    895                               MAKELPARAM((WORD)26, (WORD)26));
    896                 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
    897                               MAKELPARAM((WORD)33, (WORD)33));
    898             }
    899             else
    900             {
    901                 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
    902                               MAKELPARAM((WORD)16, (WORD)16));
    903 
    904                 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
    905                               MAKELPARAM((WORD)22, (WORD)22));
    906             }
    907 
    908             TOOLBAR_CalcToolbar (hwnd);
    909         }
    910 
    911         infoPtr->himlStd =
    912             ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
    913                               ILC_COLOR | ILC_MASK, (INT)wParam, 2);
     883        /* create new standard image list */
     884
     885//      TRACE (toolbar, "creating standard image list!\n");
     886
     887
     888        /* Windows resize all the buttons to the size of a newly added STandard Image*/
     889        /* TODO: The resizing  should be done each time a standard image is added*/
     890        if (lpAddBmp->hInst == HINST_COMMCTRL)
     891        {
     892
     893            if (lpAddBmp->nID & 1)
     894            {
     895                SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
     896                              MAKELPARAM((WORD)26, (WORD)26));
     897                SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
     898                              MAKELPARAM((WORD)33, (WORD)33));
     899            }
     900            else
     901            {
     902                SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
     903                              MAKELPARAM((WORD)16, (WORD)16));
     904
     905                SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
     906                              MAKELPARAM((WORD)22, (WORD)22));
     907            }
     908
     909            TOOLBAR_CalcToolbar (hwnd);
     910        }
     911
     912        infoPtr->himlStd =
     913            ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
     914                              ILC_COLOR | ILC_MASK, (INT)wParam, 2);
    914915    }
    915916
    916917    /* Add bitmaps to the standard image list */
    917918    if (lpAddBmp->hInst == (HINSTANCE)0) {
    918         nIndex =
    919             ImageList_AddMasked (infoPtr->himlStd, (HBITMAP)lpAddBmp->nID,
    920                                 CLR_DEFAULT);
     919        nIndex =
     920            ImageList_AddMasked (infoPtr->himlStd, (HBITMAP)lpAddBmp->nID,
     921                                CLR_DEFAULT);
    921922    }
    922923    else if (lpAddBmp->hInst == HINST_COMMCTRL) {
    923         /* add internal bitmaps */
    924        
    925 //      FIXME (toolbar, "internal bitmaps not supported!\n");
    926         /* TODO: Resize all the buttons when a new standard image is added */
    927 
    928         /* Hack to "add" some reserved images within the image list
    929            to get the right image indices */
    930         nIndex = ImageList_GetImageCount (infoPtr->himlStd);
    931         ImageList_SetImageCount (infoPtr->himlStd, nIndex + (INT)wParam);
    932        
     924        /* add internal bitmaps */
     925
     926//      FIXME (toolbar, "internal bitmaps not supported!\n");
     927        /* TODO: Resize all the buttons when a new standard image is added */
     928
     929        /* Hack to "add" some reserved images within the image list
     930           to get the right image indices */
     931        nIndex = ImageList_GetImageCount (infoPtr->himlStd);
     932        ImageList_SetImageCount (infoPtr->himlStd, nIndex + (INT)wParam);
     933
    933934    }
    934935    else {
    935         HBITMAP hBmp =
    936             LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
    937         nIndex = ImageList_AddMasked (infoPtr->himlStd, hBmp, CLR_DEFAULT);
    938 
    939         DeleteObject (hBmp);
     936        HBITMAP hBmp =
     937            LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
     938        nIndex = ImageList_AddMasked (infoPtr->himlStd, hBmp, CLR_DEFAULT);
     939
     940        DeleteObject (hBmp);
    940941    }
    941942
     
    960961
    961962    if (infoPtr->nNumButtons == 0) {
    962         infoPtr->buttons =
    963             COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     963        infoPtr->buttons =
     964            COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    964965    }
    965966    else {
    966         TBUTTON_INFO *oldButtons = infoPtr->buttons;
    967         infoPtr->buttons =
    968             COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    969         memcpy (&infoPtr->buttons[0], &oldButtons[0],
    970                 nOldButtons * sizeof(TBUTTON_INFO));
     967        TBUTTON_INFO *oldButtons = infoPtr->buttons;
     968        infoPtr->buttons =
     969            COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     970        memcpy (&infoPtr->buttons[0], &oldButtons[0],
     971                nOldButtons * sizeof(TBUTTON_INFO));
    971972        COMCTL32_Free (oldButtons);
    972973    }
     
    976977    /* insert new button data */
    977978    for (nCount = 0; nCount < nAddButtons; nCount++) {
    978         TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
    979         btnPtr->iBitmap   = lpTbb[nCount].iBitmap;
    980         btnPtr->idCommand = lpTbb[nCount].idCommand;
    981         btnPtr->fsState   = lpTbb[nCount].fsState;
    982         btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
    983         btnPtr->dwData    = lpTbb[nCount].dwData;
    984         btnPtr->iString   = lpTbb[nCount].iString;
    985         btnPtr->bHot      = FALSE;
    986 
    987         if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
    988             TTTOOLINFOA ti;
    989 
    990             ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    991             ti.cbSize   = sizeof (TTTOOLINFOA);
    992             ti.hwnd     = hwnd;
    993             ti.uId      = btnPtr->idCommand;
    994             ti.hinst    = 0;
    995             ti.lpszText = LPSTR_TEXTCALLBACKA;
    996 
    997             SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
    998                             0, (LPARAM)&ti);
    999         }
     979        TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
     980        btnPtr->iBitmap   = lpTbb[nCount].iBitmap;
     981        btnPtr->idCommand = lpTbb[nCount].idCommand;
     982        btnPtr->fsState   = lpTbb[nCount].fsState;
     983        btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
     984        btnPtr->dwData    = lpTbb[nCount].dwData;
     985        btnPtr->iString   = lpTbb[nCount].iString;
     986        btnPtr->bHot      = FALSE;
     987
     988        if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
     989            TTTOOLINFOA ti;
     990
     991            ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     992            ti.cbSize   = sizeof (TTTOOLINFOA);
     993            ti.hwnd     = hwnd;
     994            ti.uId      = btnPtr->idCommand;
     995            ti.hinst    = 0;
     996            ti.lpszText = LPSTR_TEXTCALLBACKA;
     997
     998            SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
     999                            0, (LPARAM)&ti);
     1000        }
    10001001    }
    10011002
     
    10181019
    10191020    if ((wParam) && (HIWORD(lParam) == 0)) {
    1020         char szString[256];
    1021         INT len;
    1022 //      TRACE (toolbar, "adding string from resource!\n");
    1023 
    1024         len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
    1025                              szString, 256);
    1026 
    1027 //      TRACE (toolbar, "len=%d \"%s\"\n", len, szString);
    1028         nIndex = infoPtr->nNumStrings;
    1029         if (infoPtr->nNumStrings == 0) {
    1030             infoPtr->strings =
    1031                 COMCTL32_Alloc (sizeof(LPWSTR));
    1032         }
    1033         else {
    1034             LPWSTR *oldStrings = infoPtr->strings;
    1035             infoPtr->strings =
    1036                 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    1037             memcpy (&infoPtr->strings[0], &oldStrings[0],
    1038                     sizeof(LPWSTR) * infoPtr->nNumStrings);
    1039             COMCTL32_Free (oldStrings);
    1040         }
    1041 
    1042         infoPtr->strings[infoPtr->nNumStrings] =
    1043             COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
    1044         lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], szString);
    1045         infoPtr->nNumStrings++;
     1021        char szString[256];
     1022        INT len;
     1023//      TRACE (toolbar, "adding string from resource!\n");
     1024
     1025        len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
     1026                             szString, 256);
     1027
     1028//      TRACE (toolbar, "len=%d \"%s\"\n", len, szString);
     1029        nIndex = infoPtr->nNumStrings;
     1030        if (infoPtr->nNumStrings == 0) {
     1031            infoPtr->strings =
     1032                COMCTL32_Alloc (sizeof(LPWSTR));
     1033        }
     1034        else {
     1035            LPWSTR *oldStrings = infoPtr->strings;
     1036            infoPtr->strings =
     1037                COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     1038            memcpy (&infoPtr->strings[0], &oldStrings[0],
     1039                    sizeof(LPWSTR) * infoPtr->nNumStrings);
     1040            COMCTL32_Free (oldStrings);
     1041        }
     1042
     1043        infoPtr->strings[infoPtr->nNumStrings] =
     1044            COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
     1045        lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], szString);
     1046        infoPtr->nNumStrings++;
    10461047    }
    10471048    else {
    1048         LPSTR p = (LPSTR)lParam;
    1049         INT len;
    1050 
    1051         if (p == NULL)
    1052             return -1;
    1053 //      TRACE (toolbar, "adding string(s) from array!\n");
    1054         nIndex = infoPtr->nNumStrings;
    1055         while (*p) {
    1056             len = lstrlenA (p);
    1057 //          TRACE (toolbar, "len=%d \"%s\"\n", len, p);
    1058 
    1059             if (infoPtr->nNumStrings == 0) {
    1060                 infoPtr->strings =
    1061                     COMCTL32_Alloc (sizeof(LPWSTR));
    1062             }
    1063             else {
    1064                 LPWSTR *oldStrings = infoPtr->strings;
    1065                 infoPtr->strings =
    1066                     COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    1067                 memcpy (&infoPtr->strings[0], &oldStrings[0],
    1068                         sizeof(LPWSTR) * infoPtr->nNumStrings);
    1069                 COMCTL32_Free (oldStrings);
    1070             }
    1071 
    1072             infoPtr->strings[infoPtr->nNumStrings] =
    1073                 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
    1074             lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], p);
    1075             infoPtr->nNumStrings++;
    1076 
    1077             p += (len+1);
    1078         }
     1049        LPSTR p = (LPSTR)lParam;
     1050        INT len;
     1051
     1052        if (p == NULL)
     1053            return -1;
     1054//      TRACE (toolbar, "adding string(s) from array!\n");
     1055        nIndex = infoPtr->nNumStrings;
     1056        while (*p) {
     1057            len = lstrlenA (p);
     1058//          TRACE (toolbar, "len=%d \"%s\"\n", len, p);
     1059
     1060            if (infoPtr->nNumStrings == 0) {
     1061                infoPtr->strings =
     1062                    COMCTL32_Alloc (sizeof(LPWSTR));
     1063            }
     1064            else {
     1065                LPWSTR *oldStrings = infoPtr->strings;
     1066                infoPtr->strings =
     1067                    COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     1068                memcpy (&infoPtr->strings[0], &oldStrings[0],
     1069                        sizeof(LPWSTR) * infoPtr->nNumStrings);
     1070                COMCTL32_Free (oldStrings);
     1071            }
     1072
     1073            infoPtr->strings[infoPtr->nNumStrings] =
     1074                COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
     1075            lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], p);
     1076            infoPtr->nNumStrings++;
     1077
     1078            p += (len+1);
     1079        }
    10791080    }
    10801081
     
    10901091
    10911092    if ((wParam) && (HIWORD(lParam) == 0)) {
    1092         WCHAR szString[256];
    1093         INT len;
    1094 //      TRACE (toolbar, "adding string from resource!\n");
    1095 
    1096         len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
    1097                              szString, 256);
    1098 
    1099 //      TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(szString));
    1100         nIndex = infoPtr->nNumStrings;
    1101         if (infoPtr->nNumStrings == 0) {
    1102             infoPtr->strings =
    1103                 COMCTL32_Alloc (sizeof(LPWSTR));
    1104         }
    1105         else {
    1106             LPWSTR *oldStrings = infoPtr->strings;
    1107             infoPtr->strings =
    1108                 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    1109             memcpy (&infoPtr->strings[0], &oldStrings[0],
    1110                     sizeof(LPWSTR) * infoPtr->nNumStrings);
    1111             COMCTL32_Free (oldStrings);
    1112         }
    1113 
    1114         infoPtr->strings[infoPtr->nNumStrings] =
    1115             COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
    1116         lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], szString);
    1117         infoPtr->nNumStrings++;
     1093        WCHAR szString[256];
     1094        INT len;
     1095//      TRACE (toolbar, "adding string from resource!\n");
     1096
     1097        len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
     1098                             szString, 256);
     1099
     1100//      TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(szString));
     1101        nIndex = infoPtr->nNumStrings;
     1102        if (infoPtr->nNumStrings == 0) {
     1103            infoPtr->strings =
     1104                COMCTL32_Alloc (sizeof(LPWSTR));
     1105        }
     1106        else {
     1107            LPWSTR *oldStrings = infoPtr->strings;
     1108            infoPtr->strings =
     1109                COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     1110            memcpy (&infoPtr->strings[0], &oldStrings[0],
     1111                    sizeof(LPWSTR) * infoPtr->nNumStrings);
     1112            COMCTL32_Free (oldStrings);
     1113        }
     1114
     1115        infoPtr->strings[infoPtr->nNumStrings] =
     1116            COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
     1117        lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], szString);
     1118        infoPtr->nNumStrings++;
    11181119    }
    11191120    else {
    1120         LPWSTR p = (LPWSTR)lParam;
    1121         INT len;
    1122 
    1123         if (p == NULL)
    1124             return -1;
    1125 //      TRACE (toolbar, "adding string(s) from array!\n");
    1126         nIndex = infoPtr->nNumStrings;
    1127         while (*p) {
    1128             len = lstrlenW (p);
    1129 //          TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(p));
    1130 
    1131             if (infoPtr->nNumStrings == 0) {
    1132                 infoPtr->strings =
    1133                     COMCTL32_Alloc (sizeof(LPWSTR));
    1134             }
    1135             else {
    1136                 LPWSTR *oldStrings = infoPtr->strings;
    1137                 infoPtr->strings =
    1138                     COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    1139                 memcpy (&infoPtr->strings[0], &oldStrings[0],
    1140                         sizeof(LPWSTR) * infoPtr->nNumStrings);
    1141                 COMCTL32_Free (oldStrings);
    1142             }
    1143 
    1144             infoPtr->strings[infoPtr->nNumStrings] =
    1145                 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
    1146             lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
    1147             infoPtr->nNumStrings++;
    1148 
    1149             p += (len+1);
    1150         }
     1121        LPWSTR p = (LPWSTR)lParam;
     1122        INT len;
     1123
     1124        if (p == NULL)
     1125            return -1;
     1126//      TRACE (toolbar, "adding string(s) from array!\n");
     1127        nIndex = infoPtr->nNumStrings;
     1128        while (*p) {
     1129            len = lstrlenW (p);
     1130//          TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(p));
     1131
     1132            if (infoPtr->nNumStrings == 0) {
     1133                infoPtr->strings =
     1134                    COMCTL32_Alloc (sizeof(LPWSTR));
     1135            }
     1136            else {
     1137                LPWSTR *oldStrings = infoPtr->strings;
     1138                infoPtr->strings =
     1139                    COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     1140                memcpy (&infoPtr->strings[0], &oldStrings[0],
     1141                        sizeof(LPWSTR) * infoPtr->nNumStrings);
     1142                COMCTL32_Free (oldStrings);
     1143            }
     1144
     1145            infoPtr->strings[infoPtr->nNumStrings] =
     1146                COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
     1147            lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
     1148            infoPtr->nNumStrings++;
     1149
     1150            p += (len+1);
     1151        }
    11511152    }
    11521153
     
    11721173
    11731174    if (dwStyle & CCS_NORESIZE) {
    1174         uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
    1175         cx = 0;
    1176         cy = 0;
     1175        uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
     1176        cx = 0;
     1177        cy = 0;
    11771178    }
    11781179    else {
    1179         infoPtr->nWidth = parent_rect.right - parent_rect.left;
    1180         TOOLBAR_CalcToolbar (hwnd);
    1181         InvalidateRect( hwnd, NULL, TRUE );
    1182         cy = infoPtr->nHeight;
    1183         cx = infoPtr->nWidth;
     1180        infoPtr->nWidth = parent_rect.right - parent_rect.left;
     1181        TOOLBAR_CalcToolbar (hwnd);
     1182        InvalidateRect( hwnd, NULL, TRUE );
     1183        cy = infoPtr->nHeight;
     1184        cx = infoPtr->nWidth;
    11841185    }
    11851186
    11861187    if (dwStyle & CCS_NOPARENTALIGN)
    1187         uPosFlags |= SWP_NOMOVE;
     1188        uPosFlags |= SWP_NOMOVE;
    11881189
    11891190    if (!(dwStyle & CCS_NODIVIDER))
    1190         cy += GetSystemMetrics(SM_CYEDGE);
     1191        cy += GetSystemMetrics(SM_CYEDGE);
    11911192
    11921193    infoPtr->bAutoSize = TRUE;
    11931194    SetWindowPos (hwnd, HWND_TOP, parent_rect.left, parent_rect.top,
    1194                     cx, cy, uPosFlags);
     1195                    cx, cy, uPosFlags);
    11951196
    11961197    return 0;
     
    12131214
    12141215    if (infoPtr == NULL) {
    1215 //      ERR (toolbar, "(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
    1216 //      ERR (toolbar, "infoPtr == NULL!\n");
    1217         return 0;
     1216//      ERR (toolbar, "(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
     1217//      ERR (toolbar, "infoPtr == NULL!\n");
     1218        return 0;
    12181219    }
    12191220
     
    12341235    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    12351236    if (nIndex == -1)
    1236         return FALSE;
     1237        return FALSE;
    12371238
    12381239    btnPtr = &infoPtr->buttons[nIndex];
     
    12581259    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    12591260    if (nIndex == -1)
    1260         return FALSE;
     1261        return FALSE;
    12611262
    12621263    btnPtr = &infoPtr->buttons[nIndex];
    12631264
    12641265    if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
    1265         return FALSE;
     1266        return FALSE;
    12661267
    12671268    if (LOWORD(lParam) == FALSE)
    1268         btnPtr->fsState &= ~TBSTATE_CHECKED;
     1269        btnPtr->fsState &= ~TBSTATE_CHECKED;
    12691270    else {
    1270         if (btnPtr->fsStyle & TBSTYLE_GROUP) {
    1271             nOldIndex =
    1272                 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
    1273             if (nOldIndex == nIndex)
    1274                 return 0;
    1275             if (nOldIndex != -1)
    1276                 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
    1277         }
    1278         btnPtr->fsState |= TBSTATE_CHECKED;
     1271        if (btnPtr->fsStyle & TBSTYLE_GROUP) {
     1272            nOldIndex =
     1273                TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
     1274            if (nOldIndex == nIndex)
     1275                return 0;
     1276            if (nOldIndex != -1)
     1277                infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
     1278        }
     1279        btnPtr->fsState |= TBSTATE_CHECKED;
    12791280    }
    12801281
    12811282    hdc = GetDC (hwnd);
    12821283    if (nOldIndex != -1)
    1283         TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
     1284        TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
    12841285    TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
    12851286    ReleaseDC (hwnd, hdc);
     
    13151316
    13161317    SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
    1317                   (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
     1318                  (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
    13181319
    13191320    if (!(hRes = FindResourceA (COMCTL32_hModule,
    13201321                                MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
    13211322                                RT_DIALOGA)))
    1322         return FALSE;
     1323        return FALSE;
    13231324
    13241325    if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
    1325         return FALSE;
     1326        return FALSE;
    13261327
    13271328    ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
     
    13351336
    13361337    SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
    1337                   (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
     1338                  (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
    13381339
    13391340    return ret;
     
    13481349
    13491350    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    1350         return FALSE;
    1351 
    1352     if ((infoPtr->hwndToolTip) && 
    1353         !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
    1354         TTTOOLINFOA ti;
    1355 
    1356         ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    1357         ti.cbSize   = sizeof (TTTOOLINFOA);
    1358         ti.hwnd     = hwnd;
    1359         ti.uId      = infoPtr->buttons[nIndex].idCommand;
    1360 
    1361         SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
     1351        return FALSE;
     1352
     1353    if ((infoPtr->hwndToolTip) &&
     1354        !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
     1355        TTTOOLINFOA ti;
     1356
     1357        ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     1358        ti.cbSize   = sizeof (TTTOOLINFOA);
     1359        ti.hwnd     = hwnd;
     1360        ti.uId      = infoPtr->buttons[nIndex].idCommand;
     1361
     1362        SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
    13621363    }
    13631364
    13641365    if (infoPtr->nNumButtons == 1) {
    1365 //      TRACE (toolbar, " simple delete!\n");
    1366         COMCTL32_Free (infoPtr->buttons);
    1367         infoPtr->buttons = NULL;
    1368         infoPtr->nNumButtons = 0;
     1366//      TRACE (toolbar, " simple delete!\n");
     1367        COMCTL32_Free (infoPtr->buttons);
     1368        infoPtr->buttons = NULL;
     1369        infoPtr->nNumButtons = 0;
    13691370    }
    13701371    else {
    1371         TBUTTON_INFO *oldButtons = infoPtr->buttons;
     1372        TBUTTON_INFO *oldButtons = infoPtr->buttons;
    13721373//        TRACE(toolbar, "complex delete! [nIndex=%d]\n", nIndex);
    13731374
    1374         infoPtr->nNumButtons--;
    1375         infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
     1375        infoPtr->nNumButtons--;
     1376        infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
    13761377        if (nIndex > 0) {
    13771378            memcpy (&infoPtr->buttons[0], &oldButtons[0],
     
    13841385        }
    13851386
    1386         COMCTL32_Free (oldButtons);
     1387        COMCTL32_Free (oldButtons);
    13871388    }
    13881389
     
    14051406    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    14061407    if (nIndex == -1)
    1407         return FALSE;
     1408        return FALSE;
    14081409
    14091410    btnPtr = &infoPtr->buttons[nIndex];
    14101411    if (LOWORD(lParam) == FALSE)
    1411         btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
     1412        btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
    14121413    else
    1413         btnPtr->fsState |= TBSTATE_ENABLED;
     1414        btnPtr->fsState |= TBSTATE_ENABLED;
    14141415
    14151416    hdc = GetDC (hwnd);
     
    14321433    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    14331434    if (nIndex == -1)
    1434         return -1;
     1435        return -1;
    14351436
    14361437    return infoPtr->buttons[nIndex].iBitmap;
     
    14541455
    14551456    if (infoPtr == NULL)
    1456         return FALSE;
     1457        return FALSE;
    14571458
    14581459    if (lpTbb == NULL)
    1459         return FALSE;
     1460        return FALSE;
    14601461
    14611462    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    1462         return FALSE;
     1463        return FALSE;
    14631464
    14641465    btnPtr = &infoPtr->buttons[nIndex];
     
    14831484
    14841485    if (infoPtr == NULL)
    1485         return -1;
     1486        return -1;
    14861487    if (lpTbInfo == NULL)
    1487         return -1;
     1488        return -1;
    14881489    if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
    1489         return -1;
     1490        return -1;
    14901491
    14911492    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    14921493    if (nIndex == -1)
    1493         return -1;
     1494        return -1;
    14941495
    14951496    btnPtr = &infoPtr->buttons[nIndex];
    14961497
    14971498    if (lpTbInfo->dwMask & TBIF_COMMAND)
    1498         lpTbInfo->idCommand = btnPtr->idCommand;
     1499        lpTbInfo->idCommand = btnPtr->idCommand;
    14991500    if (lpTbInfo->dwMask & TBIF_IMAGE)
    1500         lpTbInfo->iImage = btnPtr->iBitmap;
     1501        lpTbInfo->iImage = btnPtr->iBitmap;
    15011502    if (lpTbInfo->dwMask & TBIF_LPARAM)
    1502         lpTbInfo->lParam = btnPtr->dwData;
     1503        lpTbInfo->lParam = btnPtr->dwData;
    15031504    if (lpTbInfo->dwMask & TBIF_SIZE)
    1504         lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
     1505        lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
    15051506    if (lpTbInfo->dwMask & TBIF_STATE)
    1506         lpTbInfo->fsState = btnPtr->fsState;
     1507        lpTbInfo->fsState = btnPtr->fsState;
    15071508    if (lpTbInfo->dwMask & TBIF_STYLE)
    1508         lpTbInfo->fsStyle = btnPtr->fsStyle;
     1509        lpTbInfo->fsStyle = btnPtr->fsStyle;
    15091510    if (lpTbInfo->dwMask & TBIF_TEXT) {
    1510         if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
    1511             lstrcpynA (lpTbInfo->pszText,
    1512                         (LPSTR)infoPtr->strings[btnPtr->iString],
    1513                         lpTbInfo->cchText);
     1511        if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
     1512            lstrcpynA (lpTbInfo->pszText,
     1513                        (LPSTR)infoPtr->strings[btnPtr->iString],
     1514                        lpTbInfo->cchText);
    15141515    }
    15151516
     
    15271528
    15281529    return MAKELONG((WORD)infoPtr->nButtonWidth,
    1529                     (WORD)infoPtr->nButtonHeight);
     1530                    (WORD)infoPtr->nButtonHeight);
    15301531}
    15311532
     
    15391540    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    15401541    if (nIndex == -1)
    1541         return -1;
     1542        return -1;
    15421543
    15431544    nStringIndex = infoPtr->buttons[nIndex].iString;
     
    15461547
    15471548    if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
    1548         return -1;
     1549        return -1;
    15491550
    15501551    if (lParam == 0) return -1;
     
    15661567
    15671568    if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
    1568         return (LRESULT)infoPtr->himlDis;
     1569        return (LRESULT)infoPtr->himlDis;
    15691570    else
    1570         return 0;
     1571        return 0;
    15711572}
    15721573
     
    15871588
    15881589    if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
    1589         return (LRESULT)infoPtr->himlHot;
     1590        return (LRESULT)infoPtr->himlHot;
    15901591    else
    1591         return 0;
     1592        return 0;
    15921593}
    15931594
     
    16021603
    16031604    if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
    1604         return (LRESULT)infoPtr->himlDef;
     1605        return (LRESULT)infoPtr->himlDef;
    16051606    else
    1606         return 0;
     1607        return 0;
    16071608}
    16081609
     
    16211622
    16221623    if (infoPtr == NULL)
    1623         return FALSE;
     1624        return FALSE;
    16241625    nIndex = (INT)wParam;
    16251626    btnPtr = &infoPtr->buttons[nIndex];
    16261627    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    1627         return FALSE;
     1628        return FALSE;
    16281629    lpRect = (LPRECT)lParam;
    16291630    if (lpRect == NULL)
    1630         return FALSE;
     1631        return FALSE;
    16311632    if (btnPtr->fsState & TBSTATE_HIDDEN)
    1632         return FALSE;
    1633    
     1633        return FALSE;
     1634
    16341635    TOOLBAR_CalcToolbar( hwnd );
    1635    
     1636
    16361637    lpRect->left   = btnPtr->rect.left;
    16371638    lpRect->right  = btnPtr->rect.right;
     
    16501651
    16511652    if (lpSize == NULL)
    1652         return FALSE;
     1653        return FALSE;
    16531654
    16541655    lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
     
    16561657
    16571658//    TRACE (toolbar, "maximum size %d x %d\n",
    1658 //         infoPtr->rcBound.right - infoPtr->rcBound.left,
    1659 //         infoPtr->rcBound.bottom - infoPtr->rcBound.top);
     1659//         infoPtr->rcBound.right - infoPtr->rcBound.left,
     1660//         infoPtr->rcBound.bottom - infoPtr->rcBound.top);
    16601661
    16611662    return TRUE;
     
    16761677
    16771678    if (infoPtr == NULL)
    1678         return FALSE;
     1679        return FALSE;
    16791680    nIndex = (INT)wParam;
    16801681    btnPtr = &infoPtr->buttons[nIndex];
    16811682    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    1682         return FALSE;
     1683        return FALSE;
    16831684    lpRect = (LPRECT)lParam;
    16841685    if (lpRect == NULL)
    1685         return FALSE;
    1686    
     1686        return FALSE;
     1687
    16871688    lpRect->left   = btnPtr->rect.left;
    16881689    lpRect->right  = btnPtr->rect.right;
     
    17001701
    17011702    if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
    1702         return infoPtr->nRows;
     1703        return infoPtr->nRows;
    17031704    else
    1704         return 1;
     1705        return 1;
    17051706}
    17061707
     
    17141715    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    17151716    if (nIndex == -1)
    1716         return -1;
     1717        return -1;
    17171718
    17181719    return infoPtr->buttons[nIndex].fsState;
     
    17281729    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    17291730    if (nIndex == -1)
    1730         return -1;
     1731        return -1;
    17311732
    17321733    return infoPtr->buttons[nIndex].fsStyle;
     
    17401741
    17411742    if (infoPtr == NULL)
    1742         return 0;
     1743        return 0;
    17431744
    17441745    return infoPtr->nMaxTextRows;
     
    17521753
    17531754    if (infoPtr == NULL)
    1754         return 0;
     1755        return 0;
    17551756    return infoPtr->hwndToolTip;
    17561757}
     
    17621763    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    17631764
    1764 //    TRACE (toolbar, "%s hwnd=0x%x stub!\n", 
    1765 //         infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
     1765//    TRACE (toolbar, "%s hwnd=0x%x stub!\n",
     1766//         infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
    17661767
    17671768    return infoPtr->bUnicode;
     
    17781779    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    17791780    if (nIndex == -1)
    1780         return FALSE;
     1781        return FALSE;
    17811782
    17821783    btnPtr = &infoPtr->buttons[nIndex];
    17831784    if (LOWORD(lParam) == FALSE)
    1784         btnPtr->fsState &= ~TBSTATE_HIDDEN;
     1785        btnPtr->fsState &= ~TBSTATE_HIDDEN;
    17851786    else
    1786         btnPtr->fsState |= TBSTATE_HIDDEN;
     1787        btnPtr->fsState |= TBSTATE_HIDDEN;
    17871788
    17881789    TOOLBAR_CalcToolbar (hwnd);
     
    18111812    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    18121813    if (nIndex == -1)
    1813         return FALSE;
     1814        return FALSE;
    18141815
    18151816    btnPtr = &infoPtr->buttons[nIndex];
    18161817    if (LOWORD(lParam) == FALSE)
    1817         btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
     1818        btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
    18181819    else
    1819         btnPtr->fsState |= TBSTATE_INDETERMINATE;
     1820        btnPtr->fsState |= TBSTATE_INDETERMINATE;
    18201821
    18211822    hdc = GetDC (hwnd);
     
    18361837
    18371838    if (lpTbb == NULL)
    1838         return FALSE;
     1839        return FALSE;
    18391840    if (nIndex < 0)
    1840         return FALSE;
     1841        return FALSE;
    18411842
    18421843//    TRACE (toolbar, "inserting button index=%d\n", nIndex);
    18431844    if (nIndex > infoPtr->nNumButtons) {
    1844         nIndex = infoPtr->nNumButtons;
    1845 //      TRACE (toolbar, "adjust index=%d\n", nIndex);
     1845        nIndex = infoPtr->nNumButtons;
     1846//      TRACE (toolbar, "adjust index=%d\n", nIndex);
    18461847    }
    18471848
     
    18511852    /* pre insert copy */
    18521853    if (nIndex > 0) {
    1853         memcpy (&infoPtr->buttons[0], &oldButtons[0],
    1854                 nIndex * sizeof(TBUTTON_INFO));
     1854        memcpy (&infoPtr->buttons[0], &oldButtons[0],
     1855                nIndex * sizeof(TBUTTON_INFO));
    18551856    }
    18561857
     
    18641865
    18651866    if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
    1866         TTTOOLINFOA ti;
    1867 
    1868         ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    1869         ti.cbSize   = sizeof (TTTOOLINFOA);
    1870         ti.hwnd     = hwnd;
    1871         ti.uId      = lpTbb->idCommand;
    1872         ti.hinst    = 0;
    1873         ti.lpszText = LPSTR_TEXTCALLBACKA;
    1874 
    1875         SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
    1876                         0, (LPARAM)&ti);
     1867        TTTOOLINFOA ti;
     1868
     1869        ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     1870        ti.cbSize   = sizeof (TTTOOLINFOA);
     1871        ti.hwnd     = hwnd;
     1872        ti.uId      = lpTbb->idCommand;
     1873        ti.hinst    = 0;
     1874        ti.lpszText = LPSTR_TEXTCALLBACKA;
     1875
     1876        SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
     1877                        0, (LPARAM)&ti);
    18771878    }
    18781879
    18791880    /* post insert copy */
    18801881    if (nIndex < infoPtr->nNumButtons - 1) {
    1881         memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
    1882                 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
     1882        memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
     1883                (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
    18831884    }
    18841885
     
    19051906    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    19061907    if (nIndex == -1)
    1907         return FALSE;
     1908        return FALSE;
    19081909
    19091910    return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
     
    19191920    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    19201921    if (nIndex == -1)
    1921         return FALSE;
     1922        return FALSE;
    19221923
    19231924    return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
     
    19331934    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    19341935    if (nIndex == -1)
    1935         return FALSE;
     1936        return FALSE;
    19361937
    19371938    return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
     
    19471948    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    19481949    if (nIndex == -1)
    1949         return FALSE;
     1950        return FALSE;
    19501951
    19511952    return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
     
    19611962    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    19621963    if (nIndex == -1)
    1963         return FALSE;
     1964        return FALSE;
    19641965
    19651966    return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
     
    19751976    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    19761977    if (nIndex == -1)
    1977         return FALSE;
     1978        return FALSE;
    19781979
    19791980    return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
     
    19971998    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    19981999    if (nIndex == -1)
    1999         return FALSE;
     2000        return FALSE;
    20002001
    20012002    btnPtr = &infoPtr->buttons[nIndex];
    20022003    if (LOWORD(lParam) == FALSE)
    2003         btnPtr->fsState &= ~TBSTATE_PRESSED;
     2004        btnPtr->fsState &= ~TBSTATE_PRESSED;
    20042005    else
    2005         btnPtr->fsState |= TBSTATE_PRESSED;
     2006        btnPtr->fsState |= TBSTATE_PRESSED;
    20062007
    20072008    hdc = GetDC (hwnd);
     
    20262027
    20272028    if ((BOOL)wParam) {
    2028         /* save toolbar information */
    2029 //      FIXME (toolbar, "save to \"%s\" \"%s\"\n",
    2030 //             lpSave->pszSubKey, lpSave->pszValueName);
     2029        /* save toolbar information */
     2030//      FIXME (toolbar, "save to \"%s\" \"%s\"\n",
     2031//             lpSave->pszSubKey, lpSave->pszValueName);
    20312032
    20322033
    20332034    }
    20342035    else {
    2035         /* restore toolbar information */
    2036 
    2037 //      FIXME (toolbar, "restore from \"%s\" \"%s\"\n",
    2038 //             lpSave->pszSubKey, lpSave->pszValueName);
     2036        /* restore toolbar information */
     2037
     2038//      FIXME (toolbar, "restore from \"%s\" \"%s\"\n",
     2039//             lpSave->pszSubKey, lpSave->pszValueName);
    20392040
    20402041
     
    20562057
    20572058    if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
    2058         return FALSE;
     2059        return FALSE;
    20592060
    20602061    infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
     
    20742075
    20752076    if (lptbbi == NULL)
    2076         return FALSE;
     2077        return FALSE;
    20772078    if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
    2078         return FALSE;
    2079    
     2079        return FALSE;
     2080
    20802081    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    20812082    if (nIndex == -1)
    2082         return FALSE;
     2083        return FALSE;
    20832084
    20842085    btnPtr = &infoPtr->buttons[nIndex];
    20852086    if (lptbbi->dwMask & TBIF_COMMAND)
    2086         btnPtr->idCommand = lptbbi->idCommand;
     2087        btnPtr->idCommand = lptbbi->idCommand;
    20872088    if (lptbbi->dwMask & TBIF_IMAGE)
    2088         btnPtr->iBitmap = lptbbi->iImage;
     2089        btnPtr->iBitmap = lptbbi->iImage;
    20892090    if (lptbbi->dwMask & TBIF_LPARAM)
    2090         btnPtr->dwData = lptbbi->lParam;
     2091        btnPtr->dwData = lptbbi->lParam;
    20912092/*    if (lptbbi->dwMask & TBIF_SIZE) */
    2092 /*      btnPtr->cx = lptbbi->cx; */
     2093/*      btnPtr->cx = lptbbi->cx; */
    20932094    if (lptbbi->dwMask & TBIF_STATE)
    2094         btnPtr->fsState = lptbbi->fsState;
     2095        btnPtr->fsState = lptbbi->fsState;
    20952096    if (lptbbi->dwMask & TBIF_STYLE)
    2096         btnPtr->fsStyle = lptbbi->fsStyle;
     2097        btnPtr->fsStyle = lptbbi->fsStyle;
    20972098
    20982099    if (lptbbi->dwMask & TBIF_TEXT) {
    2099         if ((btnPtr->iString >= 0) ||
    2100             (btnPtr->iString < infoPtr->nNumStrings)) {
     2100        if ((btnPtr->iString >= 0) ||
     2101            (btnPtr->iString < infoPtr->nNumStrings)) {
    21012102#if 0
    2102             CHAR **lpString = &infoPtr->strings[btnPtr->iString];
    2103             INT len = lstrlenA (lptbbi->pszText);
    2104             *lpString = COMCTL32_ReAlloc (lpString, sizeof(char)*(len+1));
     2103            CHAR **lpString = &infoPtr->strings[btnPtr->iString];
     2104            INT len = lstrlenA (lptbbi->pszText);
     2105            *lpString = COMCTL32_ReAlloc (lpString, sizeof(char)*(len+1));
    21052106#endif
    21062107
    2107             /* this is the ultimate sollution */
    2108 /*          Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
    2109         }
     2108            /* this is the ultimate sollution */
     2109/*          Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
     2110        }
    21102111    }
    21112112
     
    21232124
    21242125    if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
    2125         return FALSE;
     2126        return FALSE;
    21262127
    21272128    infoPtr->nButtonWidth = (INT)LOWORD(lParam);
     
    21382139
    21392140    if (infoPtr == NULL)
    2140         return FALSE;
     2141        return FALSE;
    21412142
    21422143    infoPtr->cxMin = (INT)LOWORD(lParam);
     
    21542155
    21552156    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    2156         return FALSE;
     2157        return FALSE;
    21572158
    21582159    infoPtr->buttons[nIndex].idCommand = (INT)lParam;
     
    21602161    if (infoPtr->hwndToolTip) {
    21612162
    2162 //      FIXME (toolbar, "change tool tip!\n");
     2163//      FIXME (toolbar, "change tool tip!\n");
    21632164
    21642165    }
     
    21782179
    21792180    if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
    2180         return 0;
     2181        return 0;
    21812182
    21822183    himlTemp = infoPtr->himlDis;
     
    21852186    /* FIXME: redraw ? */
    21862187
    2187     return (LRESULT)himlTemp; 
     2188    return (LRESULT)himlTemp;
    21882189}
    21892190
     
    21972198    dwTemp = infoPtr->dwDTFlags;
    21982199    infoPtr->dwDTFlags =
    2199         (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
     2200        (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
    22002201
    22012202    return (LRESULT)dwTemp;
     
    22122213    infoPtr->dwExStyle = (DWORD)lParam;
    22132214
    2214     return (LRESULT)dwTemp; 
     2215    return (LRESULT)dwTemp;
    22152216}
    22162217
     
    22232224
    22242225    if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
    2225         return 0;
     2226        return 0;
    22262227
    22272228    himlTemp = infoPtr->himlHot;
     
    22302231    /* FIXME: redraw ? */
    22312232
    2232     return (LRESULT)himlTemp; 
     2233    return (LRESULT)himlTemp;
    22332234}
    22342235
     
    22442245
    22452246    if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
    2246         return 0;
     2247        return 0;
    22472248
    22482249    himlTemp = infoPtr->himlDef;
     
    22512252    /* FIXME: redraw ? */
    22522253
    2253     return (LRESULT)himlTemp; 
     2254    return (LRESULT)himlTemp;
    22542255}
    22552256
     
    22922293
    22932294    if (infoPtr == NULL)
    2294         return FALSE;
     2295        return FALSE;
    22952296
    22962297    infoPtr->nMaxTextRows = (INT)wParam;
     
    23102311
    23112312    if (infoPtr == NULL)
    2312         return 0;
     2313        return 0;
    23132314    hwndOldNotify = infoPtr->hwndNotify;
    23142315    infoPtr->hwndNotify = (HWND)wParam;
     
    23262327    if (LOWORD(wParam) > 1) {
    23272328
    2328 //      FIXME (toolbar, "multiple rows not supported!\n");
     2329//      FIXME (toolbar, "multiple rows not supported!\n");
    23292330
    23302331    }
     
    23352336    /* return bounding rectangle */
    23362337    if (lprc) {
    2337         lprc->left   = infoPtr->rcBound.left;
    2338         lprc->right  = infoPtr->rcBound.right;
    2339         lprc->top    = infoPtr->rcBound.top;
    2340         lprc->bottom = infoPtr->rcBound.bottom;
     2338        lprc->left   = infoPtr->rcBound.left;
     2339        lprc->right  = infoPtr->rcBound.right;
     2340        lprc->top    = infoPtr->rcBound.top;
     2341        lprc->bottom = infoPtr->rcBound.bottom;
    23412342    }
    23422343
     
    23582359    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    23592360    if (nIndex == -1)
    2360         return FALSE;
     2361        return FALSE;
    23612362
    23622363    btnPtr = &infoPtr->buttons[nIndex];
     
    23812382    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    23822383    if (nIndex == -1)
    2383         return FALSE;
     2384        return FALSE;
    23842385
    23852386    btnPtr = &infoPtr->buttons[nIndex];
     
    23922393    if (infoPtr->hwndToolTip) {
    23932394
    2394 //      FIXME (toolbar, "change tool tip!\n");
     2395//      FIXME (toolbar, "change tool tip!\n");
    23952396
    23962397    }
     
    24062407
    24072408    if (infoPtr == NULL)
    2408         return 0;
     2409        return 0;
    24092410    infoPtr->hwndToolTip = (HWND)wParam;
    24102411    return 0;
     
    24182419    BOOL bTemp;
    24192420
    2420 //    TRACE (toolbar, "%s hwnd=0x%04x stub!\n", 
    2421 //         ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
     2421//    TRACE (toolbar, "%s hwnd=0x%04x stub!\n",
     2422//         ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
    24222423
    24232424    bTemp = infoPtr->bUnicode;
     
    24602461
    24612462    if (dwStyle & TBSTYLE_TOOLTIPS) {
    2462         /* Create tooltip control */
    2463         infoPtr->hwndToolTip =
    2464             CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    2465                                CW_USEDEFAULT, CW_USEDEFAULT,
    2466                                CW_USEDEFAULT, CW_USEDEFAULT,
    2467                                hwnd, 0, 0, 0);
    2468 
    2469         /* Send NM_TOOLTIPSCREATED notification */
    2470         if (infoPtr->hwndToolTip) {
    2471             NMTOOLTIPSCREATED nmttc;
    2472 
    2473             nmttc.hdr.hwndFrom = hwnd;
    2474             nmttc.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    2475             nmttc.hdr.code = NM_TOOLTIPSCREATED;
    2476             nmttc.hwndToolTips = infoPtr->hwndToolTip;
    2477 
    2478             SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
    2479                           (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
    2480         }
     2463        /* Create tooltip control */
     2464        infoPtr->hwndToolTip =
     2465            CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
     2466                               CW_USEDEFAULT, CW_USEDEFAULT,
     2467                               CW_USEDEFAULT, CW_USEDEFAULT,
     2468                               hwnd, 0, 0, 0);
     2469
     2470        /* Send NM_TOOLTIPSCREATED notification */
     2471        if (infoPtr->hwndToolTip) {
     2472            NMTOOLTIPSCREATED nmttc;
     2473
     2474            nmttc.hdr.hwndFrom = hwnd;
     2475            nmttc.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     2476            nmttc.hdr.code = NM_TOOLTIPSCREATED;
     2477            nmttc.hwndToolTips = infoPtr->hwndToolTip;
     2478
     2479            SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
     2480                          (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
     2481        }
    24812482    }
    24822483
     
    24922493    /* delete tooltip control */
    24932494    if (infoPtr->hwndToolTip)
    2494         DestroyWindow (infoPtr->hwndToolTip);
     2495        DestroyWindow (infoPtr->hwndToolTip);
    24952496
    24962497    /* delete button data */
    24972498    if (infoPtr->buttons)
    2498         COMCTL32_Free (infoPtr->buttons);
     2499        COMCTL32_Free (infoPtr->buttons);
    24992500
    25002501    /* delete strings */
    25012502    if (infoPtr->strings) {
    2502         INT i;
    2503         for (i = 0; i < infoPtr->nNumStrings; i++)
    2504             if (infoPtr->strings[i])
    2505                 COMCTL32_Free (infoPtr->strings[i]);
    2506 
    2507         COMCTL32_Free (infoPtr->strings);
     2503        INT i;
     2504        for (i = 0; i < infoPtr->nNumStrings; i++)
     2505            if (infoPtr->strings[i])
     2506                COMCTL32_Free (infoPtr->strings[i]);
     2507
     2508        COMCTL32_Free (infoPtr->strings);
    25082509    }
    25092510
    25102511    /* destroy default image list */
    25112512    if (infoPtr->himlDef)
    2512         ImageList_Destroy (infoPtr->himlDef);
     2513        ImageList_Destroy (infoPtr->himlDef);
    25132514
    25142515    /* destroy disabled image list */
    25152516    if (infoPtr->himlDis)
    2516         ImageList_Destroy (infoPtr->himlDis);
     2517        ImageList_Destroy (infoPtr->himlDis);
    25172518
    25182519    /* destroy hot image list */
    25192520    if (infoPtr->himlHot)
    2520         ImageList_Destroy (infoPtr->himlHot);
     2521        ImageList_Destroy (infoPtr->himlHot);
    25212522
    25222523    /* delete default font */
    25232524    if (infoPtr->hFont)
    2524         DeleteObject (infoPtr->hFont);
     2525        DeleteObject (infoPtr->hFont);
    25252526
    25262527    /* free toolbar info data */
     
    25372538
    25382539    if (infoPtr->bTransparent)
    2539         return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
     2540        return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
    25402541
    25412542    return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
     
    25572558
    25582559    if (nHit >= 0) {
    2559         btnPtr = &infoPtr->buttons[nHit];
    2560         if (!(btnPtr->fsState & TBSTATE_ENABLED))
    2561             return 0;
    2562         SetCapture (hwnd);
    2563         infoPtr->bCaptured = TRUE;
    2564         infoPtr->nButtonDown = nHit;
    2565 
    2566         btnPtr->fsState |= TBSTATE_PRESSED;
    2567 
    2568         hdc = GetDC (hwnd);
    2569         TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
    2570         ReleaseDC (hwnd, hdc);
     2560        btnPtr = &infoPtr->buttons[nHit];
     2561        if (!(btnPtr->fsState & TBSTATE_ENABLED))
     2562            return 0;
     2563        SetCapture (hwnd);
     2564        infoPtr->bCaptured = TRUE;
     2565        infoPtr->nButtonDown = nHit;
     2566
     2567        btnPtr->fsState |= TBSTATE_PRESSED;
     2568
     2569        hdc = GetDC (hwnd);
     2570        TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
     2571        ReleaseDC (hwnd, hdc);
    25712572    }
    25722573    else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
    2573         TOOLBAR_Customize (hwnd);
     2574        TOOLBAR_Customize (hwnd);
    25742575
    25752576    return 0;
     
    25872588
    25882589    if (infoPtr->hwndToolTip)
    2589         TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
    2590                             WM_LBUTTONDOWN, wParam, lParam);
     2590        TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
     2591                            WM_LBUTTONDOWN, wParam, lParam);
    25912592
    25922593    pt.x = (INT)LOWORD(lParam);
     
    25952596
    25962597    if (nHit >= 0) {
    2597         btnPtr = &infoPtr->buttons[nHit];
    2598         if (!(btnPtr->fsState & TBSTATE_ENABLED))
    2599             return 0;
    2600 
    2601         SetCapture (hwnd);
    2602         infoPtr->bCaptured = TRUE;
    2603         infoPtr->nButtonDown = nHit;
    2604         infoPtr->nOldHit = nHit;
    2605 
    2606         btnPtr->fsState |= TBSTATE_PRESSED;
    2607 
    2608         hdc = GetDC (hwnd);
    2609         TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
    2610         ReleaseDC (hwnd, hdc);
     2598        btnPtr = &infoPtr->buttons[nHit];
     2599        if (!(btnPtr->fsState & TBSTATE_ENABLED))
     2600            return 0;
     2601
     2602        SetCapture (hwnd);
     2603        infoPtr->bCaptured = TRUE;
     2604        infoPtr->nButtonDown = nHit;
     2605        infoPtr->nOldHit = nHit;
     2606
     2607        btnPtr->fsState |= TBSTATE_PRESSED;
     2608
     2609        hdc = GetDC (hwnd);
     2610        TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
     2611        ReleaseDC (hwnd, hdc);
    26112612    }
    26122613
     
    26272628
    26282629    if (infoPtr->hwndToolTip)
    2629         TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
    2630                             WM_LBUTTONUP, wParam, lParam);
     2630        TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
     2631                            WM_LBUTTONUP, wParam, lParam);
    26312632
    26322633    pt.x = (INT)LOWORD(lParam);
     
    26352636
    26362637    if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
    2637         infoPtr->bCaptured = FALSE;
    2638         ReleaseCapture ();
    2639         btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
    2640         btnPtr->fsState &= ~TBSTATE_PRESSED;
    2641 
    2642         if (nHit == infoPtr->nButtonDown) {
    2643             if (btnPtr->fsStyle & TBSTYLE_CHECK) {
    2644                 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
    2645                     nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
    2646                         infoPtr->nButtonDown);
    2647                     if (nOldIndex == infoPtr->nButtonDown)
    2648                         bSendMessage = FALSE;
    2649                     if ((nOldIndex != infoPtr->nButtonDown) &&
    2650                         (nOldIndex != -1))
    2651                         infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
    2652                     btnPtr->fsState |= TBSTATE_CHECKED;
    2653                 }
    2654                 else {
    2655                     if (btnPtr->fsState & TBSTATE_CHECKED)
    2656                         btnPtr->fsState &= ~TBSTATE_CHECKED;
    2657                     else
    2658                         btnPtr->fsState |= TBSTATE_CHECKED;
    2659                 }
    2660             }
    2661         }
    2662         else
    2663             bSendMessage = FALSE;
    2664 
    2665         hdc = GetDC (hwnd);
    2666         if (nOldIndex != -1)
    2667             TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
    2668         TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
    2669         ReleaseDC (hwnd, hdc);
    2670 
    2671         if (bSendMessage)
    2672             SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
    2673                           MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
    2674 
    2675         infoPtr->nButtonDown = -1;
    2676         infoPtr->nOldHit = -1;
     2638        infoPtr->bCaptured = FALSE;
     2639        ReleaseCapture ();
     2640        btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
     2641        btnPtr->fsState &= ~TBSTATE_PRESSED;
     2642
     2643        if (nHit == infoPtr->nButtonDown) {
     2644            if (btnPtr->fsStyle & TBSTYLE_CHECK) {
     2645                if (btnPtr->fsStyle & TBSTYLE_GROUP) {
     2646                    nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
     2647                        infoPtr->nButtonDown);
     2648                    if (nOldIndex == infoPtr->nButtonDown)
     2649                        bSendMessage = FALSE;
     2650                    if ((nOldIndex != infoPtr->nButtonDown) &&
     2651                        (nOldIndex != -1))
     2652                        infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
     2653                    btnPtr->fsState |= TBSTATE_CHECKED;
     2654                }
     2655                else {
     2656                    if (btnPtr->fsState & TBSTATE_CHECKED)
     2657                        btnPtr->fsState &= ~TBSTATE_CHECKED;
     2658                    else
     2659                        btnPtr->fsState |= TBSTATE_CHECKED;
     2660                }
     2661            }
     2662        }
     2663        else
     2664            bSendMessage = FALSE;
     2665
     2666        hdc = GetDC (hwnd);
     2667        if (nOldIndex != -1)
     2668            TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
     2669        TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
     2670        ReleaseDC (hwnd, hdc);
     2671
     2672        if (bSendMessage)
     2673            SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
     2674                          MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
     2675
     2676        infoPtr->nButtonDown = -1;
     2677        infoPtr->nOldHit = -1;
    26772678    }
    26782679
     
    26912692
    26922693    if (infoPtr->hwndToolTip)
    2693         TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
    2694                             WM_MOUSEMOVE, wParam, lParam);
     2694        TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
     2695                            WM_MOUSEMOVE, wParam, lParam);
    26952696
    26962697    pt.x = (INT)LOWORD(lParam);
     
    27022703    {
    27032704        /* Remove the effect of an old hot button */
    2704         if(infoPtr->nOldHit == infoPtr->nHotItem)
    2705         {
    2706             oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
    2707             oldBtnPtr->bHot = FALSE;
    2708                    
    2709             InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE);
    2710         }
    2711 
    2712         /* It's not a separator or in nowhere. It's a hot button. */
    2713         if (nHit >= 0)
    2714         {
    2715             btnPtr = &infoPtr->buttons[nHit];
    2716             btnPtr->bHot = TRUE;
    2717 
    2718             hdc = GetDC (hwnd);
    2719             TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
    2720             ReleaseDC (hwnd, hdc);
    2721 
    2722             infoPtr->nHotItem = nHit;
    2723         }
     2705        if(infoPtr->nOldHit == infoPtr->nHotItem)
     2706        {
     2707            oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
     2708            oldBtnPtr->bHot = FALSE;
     2709
     2710            InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE);
     2711        }
     2712
     2713        /* It's not a separator or in nowhere. It's a hot button. */
     2714        if (nHit >= 0)
     2715        {
     2716            btnPtr = &infoPtr->buttons[nHit];
     2717            btnPtr->bHot = TRUE;
     2718
     2719            hdc = GetDC (hwnd);
     2720            TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
     2721            ReleaseDC (hwnd, hdc);
     2722
     2723            infoPtr->nHotItem = nHit;
     2724        }
    27242725
    27252726    if (infoPtr->bCaptured) {
    2726             btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
    2727             if (infoPtr->nOldHit == infoPtr->nButtonDown) {
    2728                 btnPtr->fsState &= ~TBSTATE_PRESSED;
    2729                 hdc = GetDC (hwnd);
    2730                 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
    2731                 ReleaseDC (hwnd, hdc);
    2732             }
    2733             else if (nHit == infoPtr->nButtonDown) {
    2734                 btnPtr->fsState |= TBSTATE_PRESSED;
    2735                 hdc = GetDC (hwnd);
    2736                 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
    2737                 ReleaseDC (hwnd, hdc);
    2738             }
    2739         }
    2740         infoPtr->nOldHit = nHit;
     2727            btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
     2728            if (infoPtr->nOldHit == infoPtr->nButtonDown) {
     2729                btnPtr->fsState &= ~TBSTATE_PRESSED;
     2730                hdc = GetDC (hwnd);
     2731                TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
     2732                ReleaseDC (hwnd, hdc);
     2733            }
     2734            else if (nHit == infoPtr->nButtonDown) {
     2735                btnPtr->fsState |= TBSTATE_PRESSED;
     2736                hdc = GetDC (hwnd);
     2737                TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
     2738                ReleaseDC (hwnd, hdc);
     2739            }
     2740        }
     2741        infoPtr->nOldHit = nHit;
    27412742    }
    27422743    return 0;
     
    27482749{
    27492750/*    if (wndPtr->dwStyle & CCS_NODIVIDER) */
    2750         return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
     2751        return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
    27512752/*    else */
    2752 /*      return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
     2753/*      return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
    27532754}
    27542755
     
    27582759{
    27592760    if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
    2760         ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
     2761        ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
    27612762
    27622763    return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
     
    27792780    if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
    27802781        HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
    2781         SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
     2782        SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
    27822783    }
    27832784
     
    27942795
    27952796    if (dwStyle & WS_MINIMIZE)
    2796         return 0; /* Nothing to do */
     2797        return 0; /* Nothing to do */
    27972798
    27982799    DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
    27992800
    28002801    if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
    2801         return 0;
     2802        return 0;
    28022803
    28032804    if (!(dwStyle & CCS_NODIVIDER))
    28042805    {
    2805         GetWindowRect (hwnd, &rcWindow);
    2806         OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
    2807         DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
     2806        GetWindowRect (hwnd, &rcWindow);
     2807        OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
     2808        DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
    28082809    }
    28092810
     
    28232824
    28242825    if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
    2825         SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,   wParam, lParam);
     2826        SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,   wParam, lParam);
    28262827
    28272828#if 0
    2828         if (lpnmh->code == TTN_GETDISPINFOA) {
    2829             LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
    2830 
    2831 //          FIXME (toolbar, "retrieving ASCII string\n");
    2832 
    2833         }
    2834         else if (lpnmh->code == TTN_GETDISPINFOW) {
    2835             LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
    2836 
    2837 //          FIXME (toolbar, "retrieving UNICODE string\n");
    2838 
    2839         }
     2829        if (lpnmh->code == TTN_GETDISPINFOA) {
     2830            LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
     2831
     2832//          FIXME (toolbar, "retrieving ASCII string\n");
     2833
     2834        }
     2835        else if (lpnmh->code == TTN_GETDISPINFOW) {
     2836            LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
     2837
     2838//          FIXME (toolbar, "retrieving UNICODE string\n");
     2839
     2840        }
    28402841#endif
    28412842    }
     
    28552856    TOOLBAR_Refresh (hwnd, hdc);
    28562857    if (!wParam)
    2857         EndPaint (hwnd, &ps);
     2858        EndPaint (hwnd, &ps);
    28582859    return 0;
    28592860}
     
    28742875    /* Resize deadlock check */
    28752876    if (infoPtr->bAutoSize) {
    2876         infoPtr->bAutoSize = FALSE;
    2877         return 0;
     2877        infoPtr->bAutoSize = FALSE;
     2878        return 0;
    28782879    }
    28792880
     
    28872888
    28882889    if (flags == SIZE_RESTORED) {
    2889         /* width and height don't apply */
    2890         parent = GetParent (hwnd);
    2891         GetClientRect(parent, &parent_rect);
    2892 
    2893         if (dwStyle & CCS_NORESIZE) {
    2894             uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
    2895 
    2896             /* FIXME */
    2897 /*          infoPtr->nWidth = parent_rect.right - parent_rect.left; */
    2898             cy = infoPtr->nHeight;
    2899             cx = infoPtr->nWidth;
    2900             TOOLBAR_CalcToolbar (hwnd);
    2901             infoPtr->nWidth = cx;
    2902             infoPtr->nHeight = cy;
    2903         }
    2904         else {
    2905             infoPtr->nWidth = parent_rect.right - parent_rect.left;
    2906             TOOLBAR_CalcToolbar (hwnd);
    2907             cy = infoPtr->nHeight;
    2908             cx = infoPtr->nWidth;
    2909         }
    2910 
    2911         if (dwStyle & CCS_NOPARENTALIGN) {
    2912             uPosFlags |= SWP_NOMOVE;
    2913             cy = infoPtr->nHeight;
    2914             cx = infoPtr->nWidth;
    2915         }
    2916 
    2917         if (!(dwStyle & CCS_NODIVIDER))
    2918             cy += GetSystemMetrics(SM_CYEDGE);
    2919 
    2920         SetWindowPos (hwnd, 0, parent_rect.left, parent_rect.top,
    2921                         cx, cy, uPosFlags | SWP_NOZORDER);
     2890        /* width and height don't apply */
     2891        parent = GetParent (hwnd);
     2892        GetClientRect(parent, &parent_rect);
     2893
     2894        if (dwStyle & CCS_NORESIZE) {
     2895            uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
     2896
     2897            /* FIXME */
     2898/*          infoPtr->nWidth = parent_rect.right - parent_rect.left; */
     2899            cy = infoPtr->nHeight;
     2900            cx = infoPtr->nWidth;
     2901            TOOLBAR_CalcToolbar (hwnd);
     2902            infoPtr->nWidth = cx;
     2903            infoPtr->nHeight = cy;
     2904        }
     2905        else {
     2906            infoPtr->nWidth = parent_rect.right - parent_rect.left;
     2907            TOOLBAR_CalcToolbar (hwnd);
     2908            cy = infoPtr->nHeight;
     2909            cx = infoPtr->nWidth;
     2910        }
     2911
     2912        if (dwStyle & CCS_NOPARENTALIGN) {
     2913            uPosFlags |= SWP_NOMOVE;
     2914            cy = infoPtr->nHeight;
     2915            cx = infoPtr->nWidth;
     2916        }
     2917
     2918        if (!(dwStyle & CCS_NODIVIDER))
     2919            cy += GetSystemMetrics(SM_CYEDGE);
     2920
     2921        SetWindowPos (hwnd, 0, parent_rect.left, parent_rect.top,
     2922                        cx, cy, uPosFlags | SWP_NOZORDER);
    29222923    }
    29232924    return 0;
     
    29422943    switch (uMsg)
    29432944    {
    2944         case TB_ADDBITMAP:
    2945             return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
    2946 
    2947         case TB_ADDBUTTONSA:
    2948             return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
    2949 
    2950 /*      case TB_ADDBUTTONSW: */
    2951 
    2952         case TB_ADDSTRINGA:
    2953             return TOOLBAR_AddStringA (hwnd, wParam, lParam);
    2954 
    2955         case TB_ADDSTRINGW:
    2956             return TOOLBAR_AddStringW (hwnd, wParam, lParam);
    2957 
    2958         case TB_AUTOSIZE:
    2959             return TOOLBAR_AutoSize (hwnd, wParam, lParam);
    2960 
    2961         case TB_BUTTONCOUNT:
    2962             return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
    2963 
    2964         case TB_BUTTONSTRUCTSIZE:
    2965             return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
    2966 
    2967         case TB_CHANGEBITMAP:
    2968             return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
    2969 
    2970         case TB_CHECKBUTTON:
    2971             return TOOLBAR_CheckButton (hwnd, wParam, lParam);
    2972 
    2973         case TB_COMMANDTOINDEX:
    2974             return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
    2975 
    2976         case TB_CUSTOMIZE:
    2977             return TOOLBAR_Customize (hwnd);
    2978 
    2979         case TB_DELETEBUTTON:
    2980             return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
    2981 
    2982         case TB_ENABLEBUTTON:
    2983             return TOOLBAR_EnableButton (hwnd, wParam, lParam);
    2984 
    2985 /*      case TB_GETANCHORHIGHLIGHT:             */ /* 4.71 */
    2986 
    2987         case TB_GETBITMAP:
    2988             return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
    2989 
    2990         case TB_GETBITMAPFLAGS:
    2991             return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
    2992 
    2993         case TB_GETBUTTON:
    2994             return TOOLBAR_GetButton (hwnd, wParam, lParam);
    2995 
    2996         case TB_GETBUTTONINFOA:
    2997             return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
    2998 
    2999 /*      case TB_GETBUTTONINFOW:         */ /* 4.71 */
    3000 
    3001         case TB_GETBUTTONSIZE:
    3002             return TOOLBAR_GetButtonSize (hwnd);
    3003 
    3004         case TB_GETBUTTONTEXTA:
    3005             return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
    3006 
    3007 /*      case TB_GETBUTTONTEXTW: */
    3008 /*      case TB_GETCOLORSCHEME:                 */ /* 4.71 */
    3009 
    3010         case TB_GETDISABLEDIMAGELIST:
    3011             return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
    3012 
    3013         case TB_GETEXTENDEDSTYLE:
    3014             return TOOLBAR_GetExtendedStyle (hwnd);
    3015 
    3016         case TB_GETHOTIMAGELIST:
    3017             return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
    3018 
    3019 /*      case TB_GETHOTITEM:                     */ /* 4.71 */
    3020 
    3021         case TB_GETIMAGELIST:
    3022             return TOOLBAR_GetImageList (hwnd, wParam, lParam);
    3023 
    3024 /*      case TB_GETINSERTMARK:                  */ /* 4.71 */
    3025 /*      case TB_GETINSERTMARKCOLOR:             */ /* 4.71 */
    3026 
    3027         case TB_GETITEMRECT:
    3028             return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
    3029 
    3030         case TB_GETMAXSIZE:
    3031             return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
    3032 
    3033 /*      case TB_GETOBJECT:                      */ /* 4.71 */
    3034 /*      case TB_GETPADDING:                     */ /* 4.71 */
    3035 
    3036         case TB_GETRECT:
    3037             return TOOLBAR_GetRect (hwnd, wParam, lParam);
    3038 
    3039         case TB_GETROWS:
    3040             return TOOLBAR_GetRows (hwnd, wParam, lParam);
    3041 
    3042         case TB_GETSTATE:
    3043             return TOOLBAR_GetState (hwnd, wParam, lParam);
    3044 
    3045         case TB_GETSTYLE:
    3046             return TOOLBAR_GetStyle (hwnd, wParam, lParam);
    3047 
    3048         case TB_GETTEXTROWS:
    3049             return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
    3050 
    3051         case TB_GETTOOLTIPS:
    3052             return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
    3053 
    3054         case TB_GETUNICODEFORMAT:
    3055             return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
    3056 
    3057         case TB_HIDEBUTTON:
    3058             return TOOLBAR_HideButton (hwnd, wParam, lParam);
    3059 
    3060         case TB_HITTEST:
    3061             return TOOLBAR_HitTest (hwnd, wParam, lParam);
    3062 
    3063         case TB_INDETERMINATE:
    3064             return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
    3065 
    3066         case TB_INSERTBUTTONA:
    3067             return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
    3068 
    3069 /*      case TB_INSERTBUTTONW: */
    3070 /*      case TB_INSERTMARKHITTEST:              */ /* 4.71 */
    3071 
    3072         case TB_ISBUTTONCHECKED:
    3073             return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
    3074 
    3075         case TB_ISBUTTONENABLED:
    3076             return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
    3077 
    3078         case TB_ISBUTTONHIDDEN:
    3079             return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
    3080 
    3081         case TB_ISBUTTONHIGHLIGHTED:
    3082             return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
    3083 
    3084         case TB_ISBUTTONINDETERMINATE:
    3085             return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
    3086 
    3087         case TB_ISBUTTONPRESSED:
    3088             return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
    3089 
    3090 /*      case TB_LOADIMAGES:                     */ /* 4.70 */
    3091 /*      case TB_MAPACCELERATORA:                */ /* 4.71 */
    3092 /*      case TB_MAPACCELERATORW:                */ /* 4.71 */
    3093 /*      case TB_MARKBUTTON:                     */ /* 4.71 */
    3094 /*      case TB_MOVEBUTTON:                     */ /* 4.71 */
    3095 
    3096         case TB_PRESSBUTTON:
    3097             return TOOLBAR_PressButton (hwnd, wParam, lParam);
    3098 
    3099 /*      case TB_REPLACEBITMAP: */
    3100 
    3101         case TB_SAVERESTOREA:
    3102             return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
    3103 
    3104 /*      case TB_SAVERESTOREW: */
    3105 /*      case TB_SETANCHORHIGHLIGHT:             */ /* 4.71 */
    3106 
    3107         case TB_SETBITMAPSIZE:
    3108             return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
    3109 
    3110         case TB_SETBUTTONINFOA:
    3111             return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
    3112 
    3113 /*      case TB_SETBUTTONINFOW:                 */ /* 4.71 */
    3114 
    3115         case TB_SETBUTTONSIZE:
    3116             return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
    3117 
    3118         case TB_SETBUTTONWIDTH:
    3119             return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
    3120 
    3121         case TB_SETCMDID:
    3122             return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
    3123 
    3124 /*      case TB_SETCOLORSCHEME:                 */ /* 4.71 */
    3125 
    3126         case TB_SETDISABLEDIMAGELIST:
    3127             return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
    3128 
    3129         case TB_SETDRAWTEXTFLAGS:
    3130             return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
    3131 
    3132         case TB_SETEXTENDEDSTYLE:
    3133             return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
    3134 
    3135         case TB_SETHOTIMAGELIST:
    3136             return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
    3137 
    3138 /*      case TB_SETHOTITEM:                     */ /* 4.71 */
    3139 
    3140         case TB_SETIMAGELIST:
    3141             return TOOLBAR_SetImageList (hwnd, wParam, lParam);
    3142 
    3143         case TB_SETINDENT:
    3144             return TOOLBAR_SetIndent (hwnd, wParam, lParam);
    3145 
    3146 /*      case TB_SETINSERTMARK:                  */ /* 4.71 */
    3147 
    3148         case TB_SETINSERTMARKCOLOR:
    3149             return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
    3150 
    3151         case TB_SETMAXTEXTROWS:
    3152             return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
    3153 
    3154 /*      case TB_SETPADDING:                     */ /* 4.71 */
    3155 
    3156         case TB_SETPARENT:
    3157             return TOOLBAR_SetParent (hwnd, wParam, lParam);
    3158 
    3159         case TB_SETROWS:
    3160             return TOOLBAR_SetRows (hwnd, wParam, lParam);
    3161 
    3162         case TB_SETSTATE:
    3163             return TOOLBAR_SetState (hwnd, wParam, lParam);
    3164 
    3165         case TB_SETSTYLE:
    3166             return TOOLBAR_SetStyle (hwnd, wParam, lParam);
    3167 
    3168         case TB_SETTOOLTIPS:
    3169             return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
    3170 
    3171         case TB_SETUNICODEFORMAT:
    3172             return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
    3173 
    3174 
    3175 /*      case WM_CHAR: */
    3176 
    3177         case WM_CREATE:
    3178             return TOOLBAR_Create (hwnd, wParam, lParam);
    3179 
    3180         case WM_DESTROY:
    3181             return TOOLBAR_Destroy (hwnd, wParam, lParam);
    3182 
    3183         case WM_ERASEBKGND:
    3184             return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
    3185 
    3186 /*      case WM_GETFONT: */
    3187 /*      case WM_KEYDOWN: */
    3188 /*      case WM_KILLFOCUS: */
    3189 
    3190         case WM_LBUTTONDBLCLK:
    3191             return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
    3192 
    3193         case WM_LBUTTONDOWN:
    3194             return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
    3195 
    3196         case WM_LBUTTONUP:
    3197             return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
    3198 
    3199         case WM_MOUSEMOVE:
    3200             return TOOLBAR_MouseMove (hwnd, wParam, lParam);
    3201 
    3202         case WM_NCACTIVATE:
    3203             return TOOLBAR_NCActivate (hwnd, wParam, lParam);
    3204 
    3205         case WM_NCCALCSIZE:
    3206             return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
    3207 
    3208         case WM_NCCREATE:
    3209             return TOOLBAR_NCCreate (hwnd, wParam, lParam);
    3210 
    3211         case WM_NCPAINT:
    3212             return TOOLBAR_NCPaint (hwnd, wParam, lParam);
    3213 
    3214         case WM_NOTIFY:
    3215             return TOOLBAR_Notify (hwnd, wParam, lParam);
    3216 
    3217 /*      case WM_NOTIFYFORMAT: */
    3218 
    3219         case WM_PAINT:
    3220             return TOOLBAR_Paint (hwnd, wParam);
    3221 
    3222         case WM_SIZE:
    3223             return TOOLBAR_Size (hwnd, wParam, lParam);
    3224 
    3225         case WM_STYLECHANGED:
    3226             return TOOLBAR_StyleChanged (hwnd, wParam, lParam);
    3227 
    3228 /*      case WM_SYSCOLORCHANGE: */
    3229 
    3230 /*      case WM_WININICHANGE: */
    3231 
    3232         case WM_CHARTOITEM:
    3233         case WM_COMMAND:
    3234         case WM_DRAWITEM:
    3235         case WM_MEASUREITEM:
    3236         case WM_VKEYTOITEM:
    3237             return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
    3238 
    3239         default:
    3240             if (uMsg >= WM_USER)
    3241 //              ERR (toolbar, "unknown msg %04x wp=%08x lp=%08lx\n",
    3242 //                   uMsg, wParam, lParam);
    3243             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     2945        case TB_ADDBITMAP:
     2946            return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
     2947
     2948        case TB_ADDBUTTONSA:
     2949            return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
     2950
     2951/*      case TB_ADDBUTTONSW: */
     2952
     2953        case TB_ADDSTRINGA:
     2954            return TOOLBAR_AddStringA (hwnd, wParam, lParam);
     2955
     2956        case TB_ADDSTRINGW:
     2957            return TOOLBAR_AddStringW (hwnd, wParam, lParam);
     2958
     2959        case TB_AUTOSIZE:
     2960            return TOOLBAR_AutoSize (hwnd, wParam, lParam);
     2961
     2962        case TB_BUTTONCOUNT:
     2963            return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
     2964
     2965        case TB_BUTTONSTRUCTSIZE:
     2966            return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
     2967
     2968        case TB_CHANGEBITMAP:
     2969            return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
     2970
     2971        case TB_CHECKBUTTON:
     2972            return TOOLBAR_CheckButton (hwnd, wParam, lParam);
     2973
     2974        case TB_COMMANDTOINDEX:
     2975            return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
     2976
     2977        case TB_CUSTOMIZE:
     2978            return TOOLBAR_Customize (hwnd);
     2979
     2980        case TB_DELETEBUTTON:
     2981            return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
     2982
     2983        case TB_ENABLEBUTTON:
     2984            return TOOLBAR_EnableButton (hwnd, wParam, lParam);
     2985
     2986/*      case TB_GETANCHORHIGHLIGHT:             */ /* 4.71 */
     2987
     2988        case TB_GETBITMAP:
     2989            return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
     2990
     2991        case TB_GETBITMAPFLAGS:
     2992            return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
     2993
     2994        case TB_GETBUTTON:
     2995            return TOOLBAR_GetButton (hwnd, wParam, lParam);
     2996
     2997        case TB_GETBUTTONINFOA:
     2998            return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
     2999
     3000/*      case TB_GETBUTTONINFOW:         */ /* 4.71 */
     3001
     3002        case TB_GETBUTTONSIZE:
     3003            return TOOLBAR_GetButtonSize (hwnd);
     3004
     3005        case TB_GETBUTTONTEXTA:
     3006            return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
     3007
     3008/*      case TB_GETBUTTONTEXTW: */
     3009/*      case TB_GETCOLORSCHEME:                 */ /* 4.71 */
     3010
     3011        case TB_GETDISABLEDIMAGELIST:
     3012            return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
     3013
     3014        case TB_GETEXTENDEDSTYLE:
     3015            return TOOLBAR_GetExtendedStyle (hwnd);
     3016
     3017        case TB_GETHOTIMAGELIST:
     3018            return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
     3019
     3020/*      case TB_GETHOTITEM:                     */ /* 4.71 */
     3021
     3022        case TB_GETIMAGELIST:
     3023            return TOOLBAR_GetImageList (hwnd, wParam, lParam);
     3024
     3025/*      case TB_GETINSERTMARK:                  */ /* 4.71 */
     3026/*      case TB_GETINSERTMARKCOLOR:             */ /* 4.71 */
     3027
     3028        case TB_GETITEMRECT:
     3029            return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
     3030
     3031        case TB_GETMAXSIZE:
     3032            return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
     3033
     3034/*      case TB_GETOBJECT:                      */ /* 4.71 */
     3035/*      case TB_GETPADDING:                     */ /* 4.71 */
     3036
     3037        case TB_GETRECT:
     3038            return TOOLBAR_GetRect (hwnd, wParam, lParam);
     3039
     3040        case TB_GETROWS:
     3041            return TOOLBAR_GetRows (hwnd, wParam, lParam);
     3042
     3043        case TB_GETSTATE:
     3044            return TOOLBAR_GetState (hwnd, wParam, lParam);
     3045
     3046        case TB_GETSTYLE:
     3047            return TOOLBAR_GetStyle (hwnd, wParam, lParam);
     3048
     3049        case TB_GETTEXTROWS:
     3050            return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
     3051
     3052        case TB_GETTOOLTIPS:
     3053            return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
     3054
     3055        case TB_GETUNICODEFORMAT:
     3056            return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
     3057
     3058        case TB_HIDEBUTTON:
     3059            return TOOLBAR_HideButton (hwnd, wParam, lParam);
     3060
     3061        case TB_HITTEST:
     3062            return TOOLBAR_HitTest (hwnd, wParam, lParam);
     3063
     3064        case TB_INDETERMINATE:
     3065            return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
     3066
     3067        case TB_INSERTBUTTONA:
     3068            return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
     3069
     3070/*      case TB_INSERTBUTTONW: */
     3071/*      case TB_INSERTMARKHITTEST:              */ /* 4.71 */
     3072
     3073        case TB_ISBUTTONCHECKED:
     3074            return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
     3075
     3076        case TB_ISBUTTONENABLED:
     3077            return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
     3078
     3079        case TB_ISBUTTONHIDDEN:
     3080            return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
     3081
     3082        case TB_ISBUTTONHIGHLIGHTED:
     3083            return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
     3084
     3085        case TB_ISBUTTONINDETERMINATE:
     3086            return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
     3087
     3088        case TB_ISBUTTONPRESSED:
     3089            return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
     3090
     3091/*      case TB_LOADIMAGES:                     */ /* 4.70 */
     3092/*      case TB_MAPACCELERATORA:                */ /* 4.71 */
     3093/*      case TB_MAPACCELERATORW:                */ /* 4.71 */
     3094/*      case TB_MARKBUTTON:                     */ /* 4.71 */
     3095/*      case TB_MOVEBUTTON:                     */ /* 4.71 */
     3096
     3097        case TB_PRESSBUTTON:
     3098            return TOOLBAR_PressButton (hwnd, wParam, lParam);
     3099
     3100/*      case TB_REPLACEBITMAP: */
     3101
     3102        case TB_SAVERESTOREA:
     3103            return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
     3104
     3105/*      case TB_SAVERESTOREW: */
     3106/*      case TB_SETANCHORHIGHLIGHT:             */ /* 4.71 */
     3107
     3108        case TB_SETBITMAPSIZE:
     3109            return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
     3110
     3111        case TB_SETBUTTONINFOA:
     3112            return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
     3113
     3114/*      case TB_SETBUTTONINFOW:                 */ /* 4.71 */
     3115
     3116        case TB_SETBUTTONSIZE:
     3117            return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
     3118
     3119        case TB_SETBUTTONWIDTH:
     3120            return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
     3121
     3122        case TB_SETCMDID:
     3123            return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
     3124
     3125/*      case TB_SETCOLORSCHEME:                 */ /* 4.71 */
     3126
     3127        case TB_SETDISABLEDIMAGELIST:
     3128            return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
     3129
     3130        case TB_SETDRAWTEXTFLAGS:
     3131            return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
     3132
     3133        case TB_SETEXTENDEDSTYLE:
     3134            return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
     3135
     3136        case TB_SETHOTIMAGELIST:
     3137            return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
     3138
     3139/*      case TB_SETHOTITEM:                     */ /* 4.71 */
     3140
     3141        case TB_SETIMAGELIST:
     3142            return TOOLBAR_SetImageList (hwnd, wParam, lParam);
     3143
     3144        case TB_SETINDENT:
     3145            return TOOLBAR_SetIndent (hwnd, wParam, lParam);
     3146
     3147/*      case TB_SETINSERTMARK:                  */ /* 4.71 */
     3148
     3149        case TB_SETINSERTMARKCOLOR:
     3150            return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
     3151
     3152        case TB_SETMAXTEXTROWS:
     3153            return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
     3154
     3155/*      case TB_SETPADDING:                     */ /* 4.71 */
     3156
     3157        case TB_SETPARENT:
     3158            return TOOLBAR_SetParent (hwnd, wParam, lParam);
     3159
     3160        case TB_SETROWS:
     3161            return TOOLBAR_SetRows (hwnd, wParam, lParam);
     3162
     3163        case TB_SETSTATE:
     3164            return TOOLBAR_SetState (hwnd, wParam, lParam);
     3165
     3166        case TB_SETSTYLE:
     3167            return TOOLBAR_SetStyle (hwnd, wParam, lParam);
     3168
     3169        case TB_SETTOOLTIPS:
     3170            return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
     3171
     3172        case TB_SETUNICODEFORMAT:
     3173            return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
     3174
     3175
     3176/*      case WM_CHAR: */
     3177
     3178        case WM_CREATE:
     3179            return TOOLBAR_Create (hwnd, wParam, lParam);
     3180
     3181        case WM_DESTROY:
     3182            return TOOLBAR_Destroy (hwnd, wParam, lParam);
     3183
     3184        case WM_ERASEBKGND:
     3185            return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
     3186
     3187/*      case WM_GETFONT: */
     3188/*      case WM_KEYDOWN: */
     3189/*      case WM_KILLFOCUS: */
     3190
     3191        case WM_LBUTTONDBLCLK:
     3192            return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
     3193
     3194        case WM_LBUTTONDOWN:
     3195            return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
     3196
     3197        case WM_LBUTTONUP:
     3198            return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
     3199
     3200        case WM_MOUSEMOVE:
     3201            return TOOLBAR_MouseMove (hwnd, wParam, lParam);
     3202
     3203        case WM_NCACTIVATE:
     3204            return TOOLBAR_NCActivate (hwnd, wParam, lParam);
     3205
     3206        case WM_NCCALCSIZE:
     3207            return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
     3208
     3209        case WM_NCCREATE:
     3210            return TOOLBAR_NCCreate (hwnd, wParam, lParam);
     3211
     3212        case WM_NCPAINT:
     3213            return TOOLBAR_NCPaint (hwnd, wParam, lParam);
     3214
     3215        case WM_NOTIFY:
     3216            return TOOLBAR_Notify (hwnd, wParam, lParam);
     3217
     3218/*      case WM_NOTIFYFORMAT: */
     3219
     3220        case WM_PAINT:
     3221            return TOOLBAR_Paint (hwnd, wParam);
     3222
     3223        case WM_SIZE:
     3224            return TOOLBAR_Size (hwnd, wParam, lParam);
     3225
     3226        case WM_STYLECHANGED:
     3227            return TOOLBAR_StyleChanged (hwnd, wParam, lParam);
     3228
     3229/*      case WM_SYSCOLORCHANGE: */
     3230
     3231/*      case WM_WININICHANGE: */
     3232
     3233        case WM_CHARTOITEM:
     3234        case WM_COMMAND:
     3235        case WM_DRAWITEM:
     3236        case WM_MEASUREITEM:
     3237        case WM_VKEYTOITEM:
     3238            return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
     3239
     3240        default:
     3241//            if (uMsg >= WM_USER)
     3242//              ERR (toolbar, "unknown msg %04x wp=%08x lp=%08lx\n",
     3243//                   uMsg, wParam, lParam);
     3244            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    32443245    }
    32453246    return 0;
     
    32623263    wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
    32633264    wndClass.lpszClassName = TOOLBARCLASSNAMEA;
    3264  
     3265
    32653266    RegisterClassA (&wndClass);
    32663267}
     
    32713272{
    32723273    if (GlobalFindAtomA (TOOLBARCLASSNAMEA))
    3273         UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);
    3274 }
    3275 
     3274        UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);
     3275}
     3276
  • trunk/src/comctl32/tooltips.c

    r94 r110  
    1 /* $Id: tooltips.c,v 1.4 1999-06-10 16:22:02 achimha Exp $ */
     1/* $Id: tooltips.c,v 1.5 1999-06-16 20:25:44 cbratschi Exp $ */
    22/*
    33 * Tool tip control
     
    55 * Copyright 1998 Eric Kohl
    66 * Copyright 1999 Achim Hasenmueller
     7 * Copyright 1999 Christoph Bratschi
    78 *
    89 * TODO:
     
    5354
    5455    if (infoPtr->nMaxTipWidth > -1)
    55         uFlags |= DT_WORDBREAK;
     56        uFlags |= DT_WORDBREAK;
    5657    if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX)
    57         uFlags |= DT_NOPREFIX;
     58        uFlags |= DT_NOPREFIX;
    5859    GetClientRect (hwnd, &rc);
    5960
     
    7677    SelectObject (hdc, hOldFont);
    7778    if (oldBkMode != TRANSPARENT)
    78         SetBkMode (hdc, oldBkMode);
     79        SetBkMode (hdc, oldBkMode);
    7980}
    8081
     
    8687
    8788    if ((toolPtr->hinst) && (HIWORD((UINT)toolPtr->lpszText) == 0)) {
    88         /* load a resource */
    89 //      TRACE (tooltips, "load res string %x %x\n",
    90 //             toolPtr->hinst, (int)toolPtr->lpszText);
    91         LoadStringW (toolPtr->hinst, (UINT)toolPtr->lpszText,
    92                        infoPtr->szTipText, INFOTIPSIZE);
     89        /* load a resource */
     90//      TRACE (tooltips, "load res string %x %x\n",
     91//             toolPtr->hinst, (int)toolPtr->lpszText);
     92        LoadStringW (toolPtr->hinst, (UINT)toolPtr->lpszText,
     93                       infoPtr->szTipText, INFOTIPSIZE);
    9394    }
    9495    else if (toolPtr->lpszText) {
    95         if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW) {
    96             NMTTDISPINFOA ttnmdi;
    97 
    98             /* fill NMHDR struct */
    99             ZeroMemory (&ttnmdi, sizeof(NMTTDISPINFOA));
    100             ttnmdi.hdr.hwndFrom = hwnd;
    101             ttnmdi.hdr.idFrom = toolPtr->uId;
    102             ttnmdi.hdr.code = TTN_GETDISPINFOA;
    103             ttnmdi.lpszText = (LPSTR)&ttnmdi.szText;
    104             ttnmdi.uFlags = toolPtr->uFlags;
    105             ttnmdi.lParam = toolPtr->lParam;
    106 
    107 //          TRACE (tooltips, "hdr.idFrom = %x\n", ttnmdi.hdr.idFrom);
    108             SendMessageA (toolPtr->hwnd, WM_NOTIFY,
    109                             (WPARAM)toolPtr->uId, (LPARAM)&ttnmdi);
    110 
    111             if ((ttnmdi.hinst) && (HIWORD((UINT)ttnmdi.szText) == 0)) {
    112                 LoadStringW (ttnmdi.hinst, (UINT)ttnmdi.szText,
    113                                infoPtr->szTipText, INFOTIPSIZE);
    114                 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
    115                     toolPtr->hinst = ttnmdi.hinst;
    116                     toolPtr->lpszText = (LPWSTR)ttnmdi.szText;
    117                 }
    118             }
    119             else if (ttnmdi.szText[0]) {
    120                 lstrcpynAtoW (infoPtr->szTipText, ttnmdi.szText, 80);
    121                 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
    122                     INT len = lstrlenA (ttnmdi.szText);
    123                     toolPtr->hinst = 0;
    124                     toolPtr->lpszText = COMCTL32_Alloc ((len+1)* sizeof(WCHAR));
    125                     lstrcpyAtoW (toolPtr->lpszText, ttnmdi.szText);
    126                 }
    127             }
    128             else if (ttnmdi.lpszText == 0) {
    129                 /* no text available */
    130                 infoPtr->szTipText[0] = L'\0';
    131             }
    132             else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA) {
    133                 lstrcpynAtoW (infoPtr->szTipText, ttnmdi.lpszText, INFOTIPSIZE);
    134                 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
    135                     INT len = lstrlenA (ttnmdi.lpszText);
    136                     toolPtr->hinst = 0;
    137                     toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    138                     lstrcpyAtoW (toolPtr->lpszText, ttnmdi.lpszText);
    139                 }
    140             }
    141             else {
    142 //              ERR (tooltips, "recursive text callback!\n");
    143                 infoPtr->szTipText[0] = '\0';
    144             }
    145         }
    146         else {
    147             /* the item is a usual (unicode) text */
    148 //          lstrcpynW (infoPtr->szTipText, toolPtr->lpszText, INFOTIPSIZE);
    149             strncpy(infoPtr->szTipText, toolPtr->lpszText, INFOTIPSIZE);
    150         }
     96        if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW) {
     97            NMTTDISPINFOA ttnmdi;
     98
     99            /* fill NMHDR struct */
     100            ZeroMemory (&ttnmdi, sizeof(NMTTDISPINFOA));
     101            ttnmdi.hdr.hwndFrom = hwnd;
     102            ttnmdi.hdr.idFrom = toolPtr->uId;
     103            ttnmdi.hdr.code = TTN_GETDISPINFOA;
     104            ttnmdi.lpszText = (LPSTR)&ttnmdi.szText;
     105            ttnmdi.uFlags = toolPtr->uFlags;
     106            ttnmdi.lParam = toolPtr->lParam;
     107
     108//          TRACE (tooltips, "hdr.idFrom = %x\n", ttnmdi.hdr.idFrom);
     109            SendMessageA (toolPtr->hwnd, WM_NOTIFY,
     110                            (WPARAM)toolPtr->uId, (LPARAM)&ttnmdi);
     111
     112            if ((ttnmdi.hinst) && (HIWORD((UINT)ttnmdi.szText) == 0)) {
     113                LoadStringW (ttnmdi.hinst, (UINT)ttnmdi.szText,
     114                               infoPtr->szTipText, INFOTIPSIZE);
     115                if (ttnmdi.uFlags & TTF_DI_SETITEM) {
     116                    toolPtr->hinst = ttnmdi.hinst;
     117                    toolPtr->lpszText = (LPWSTR)ttnmdi.szText;
     118                }
     119            }
     120            else if (ttnmdi.szText[0]) {
     121                lstrcpynAtoW (infoPtr->szTipText, ttnmdi.szText, 80);
     122                if (ttnmdi.uFlags & TTF_DI_SETITEM) {
     123                    INT len = lstrlenA (ttnmdi.szText);
     124                    toolPtr->hinst = 0;
     125                    toolPtr->lpszText = COMCTL32_Alloc ((len+1)* sizeof(WCHAR));
     126                    lstrcpyAtoW (toolPtr->lpszText, ttnmdi.szText);
     127                }
     128            }
     129            else if (ttnmdi.lpszText == 0) {
     130                /* no text available */
     131                infoPtr->szTipText[0] = L'\0';
     132            }
     133            else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA) {
     134                lstrcpynAtoW (infoPtr->szTipText, ttnmdi.lpszText, INFOTIPSIZE);
     135                if (ttnmdi.uFlags & TTF_DI_SETITEM) {
     136                    INT len = lstrlenA (ttnmdi.lpszText);
     137                    toolPtr->hinst = 0;
     138                    toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     139                    lstrcpyAtoW (toolPtr->lpszText, ttnmdi.lpszText);
     140                }
     141            }
     142            else {
     143//              ERR (tooltips, "recursive text callback!\n");
     144                infoPtr->szTipText[0] = '\0';
     145            }
     146        }
     147        else {
     148            /* the item is a usual (unicode) text */
     149//          lstrcpynW (infoPtr->szTipText, toolPtr->lpszText, INFOTIPSIZE);
     150            strncpy(infoPtr->szTipText, toolPtr->lpszText, INFOTIPSIZE);
     151        }
    151152    }
    152153    else {
    153         /* no text available */
    154         infoPtr->szTipText[0] = L'\0';
     154        /* no text available */
     155        infoPtr->szTipText[0] = L'\0';
    155156    }
    156157
     
    168169
    169170    if (infoPtr->nMaxTipWidth > -1) {
    170         rc.right = infoPtr->nMaxTipWidth;
    171         uFlags |= DT_WORDBREAK;
     171        rc.right = infoPtr->nMaxTipWidth;
     172        uFlags |= DT_WORDBREAK;
    172173    }
    173174    if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX)
    174         uFlags |= DT_NOPREFIX;
     175        uFlags |= DT_NOPREFIX;
    175176//    TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
    176177
     
    181182    ReleaseDC (hwnd, hdc);
    182183
    183     lpSize->cx = rc.right - rc.left + 4 + 
    184                 infoPtr->rcMargin.left + infoPtr->rcMargin.right;
     184    lpSize->cx = rc.right - rc.left + 4 +
     185                infoPtr->rcMargin.left + infoPtr->rcMargin.right;
    185186    lpSize->cy = rc.bottom - rc.top + 4 +
    186                 infoPtr->rcMargin.bottom + infoPtr->rcMargin.top;
     187                infoPtr->rcMargin.bottom + infoPtr->rcMargin.top;
    187188}
    188189
     
    198199
    199200    if (infoPtr->nTool == -1) {
    200 //      TRACE (tooltips, "invalid tool (-1)!\n");
    201         return;
     201//      TRACE (tooltips, "invalid tool (-1)!\n");
     202        return;
    202203    }
    203204
     
    209210
    210211    if (infoPtr->szTipText[0] == L'\0') {
    211         infoPtr->nCurrentTool = -1;
    212         return;
     212        infoPtr->nCurrentTool = -1;
     213        return;
    213214    }
    214215
     
    220221    hdr.code = TTN_SHOW;
    221222    SendMessageA (toolPtr->hwnd, WM_NOTIFY,
    222                     (WPARAM)toolPtr->uId, (LPARAM)&hdr);
     223                    (WPARAM)toolPtr->uId, (LPARAM)&hdr);
    223224
    224225//    TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
     
    228229
    229230    if (toolPtr->uFlags & TTF_CENTERTIP) {
    230         RECT rc;
    231 
    232         if (toolPtr->uFlags & TTF_IDISHWND)
    233             GetWindowRect ((HWND)toolPtr->uId, &rc);
    234         else {
    235             rc = toolPtr->rect;
    236             MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2);
    237         }
    238         rect.left = (rc.left + rc.right - size.cx) / 2;
    239         rect.top  = rc.bottom + 2;
     231        RECT rc;
     232
     233        if (toolPtr->uFlags & TTF_IDISHWND)
     234            GetWindowRect ((HWND)toolPtr->uId, &rc);
     235        else {
     236            rc = toolPtr->rect;
     237            MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2);
     238        }
     239        rect.left = (rc.left + rc.right - size.cx) / 2;
     240        rect.top  = rc.bottom + 2;
    240241    }
    241242    else {
    242         GetCursorPos ((LPPOINT)&rect);
    243         rect.top += 20;
     243        GetCursorPos ((LPPOINT)&rect);
     244        rect.top += 20;
    244245    }
    245246
     
    252253
    253254    AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE),
    254                         FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE));
     255                        FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE));
    255256
    256257    SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top,
    257                     rect.right - rect.left, rect.bottom - rect.top,
    258                     SWP_SHOWWINDOW | SWP_NOACTIVATE);
     258                    rect.right - rect.left, rect.bottom - rect.top,
     259                    SWP_SHOWWINDOW | SWP_NOACTIVATE);
    259260
    260261    /* repaint the tooltip */
     
    274275
    275276    if (infoPtr->nCurrentTool == -1)
    276         return;
     277        return;
    277278
    278279    toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
     
    284285    hdr.code = TTN_POP;
    285286    SendMessageA (toolPtr->hwnd, WM_NOTIFY,
    286                     (WPARAM)toolPtr->uId, (LPARAM)&hdr);
     287                    (WPARAM)toolPtr->uId, (LPARAM)&hdr);
    287288
    288289    infoPtr->nCurrentTool = -1;
    289290
    290291    SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,
    291                     SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
     292                    SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
    292293}
    293294
     
    303304
    304305    if (infoPtr->nTrackTool == -1) {
    305 //      TRACE (tooltips, "invalid tracking tool (-1)!\n");
    306         return;
     306//      TRACE (tooltips, "invalid tracking tool (-1)!\n");
     307        return;
    307308    }
    308309
     
    312313
    313314    if (infoPtr->szTipText[0] == L'\0') {
    314         infoPtr->nTrackTool = -1;
    315         return;
     315        infoPtr->nTrackTool = -1;
     316        return;
    316317    }
    317318
     
    323324    hdr.code = TTN_SHOW;
    324325    SendMessageA (toolPtr->hwnd, WM_NOTIFY,
    325                     (WPARAM)toolPtr->uId, (LPARAM)&hdr);
     326                    (WPARAM)toolPtr->uId, (LPARAM)&hdr);
    326327
    327328//    TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
     
    331332
    332333    if (toolPtr->uFlags & TTF_ABSOLUTE) {
    333         rect.left = infoPtr->xTrackPos;
    334         rect.top  = infoPtr->yTrackPos;
    335 
    336         if (toolPtr->uFlags & TTF_CENTERTIP) {
    337             rect.left -= (size.cx / 2);
    338             rect.top  -= (size.cy / 2);
    339         }
     334        rect.left = infoPtr->xTrackPos;
     335        rect.top  = infoPtr->yTrackPos;
     336
     337        if (toolPtr->uFlags & TTF_CENTERTIP) {
     338            rect.left -= (size.cx / 2);
     339            rect.top  -= (size.cy / 2);
     340        }
    340341    }
    341342    else {
    342         RECT rcTool;
    343 
    344         if (toolPtr->uFlags & TTF_IDISHWND)
    345             GetWindowRect ((HWND)toolPtr->uId, &rcTool);
    346         else {
    347             rcTool = toolPtr->rect;
    348             MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rcTool, 2);
    349         }
    350 
    351         GetCursorPos ((LPPOINT)&rect);
    352         rect.top += 20;
    353 
    354         if (toolPtr->uFlags & TTF_CENTERTIP) {
    355             rect.left -= (size.cx / 2);
    356             rect.top  -= (size.cy / 2);
    357         }
    358 
    359         /* smart placement */
    360         if ((rect.left + size.cx > rcTool.left) && (rect.left < rcTool.right) &&
    361             (rect.top + size.cy > rcTool.top) && (rect.top < rcTool.bottom))
    362             rect.left = rcTool.right;
     343        RECT rcTool;
     344
     345        if (toolPtr->uFlags & TTF_IDISHWND)
     346            GetWindowRect ((HWND)toolPtr->uId, &rcTool);
     347        else {
     348            rcTool = toolPtr->rect;
     349            MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rcTool, 2);
     350        }
     351
     352        GetCursorPos ((LPPOINT)&rect);
     353        rect.top += 20;
     354
     355        if (toolPtr->uFlags & TTF_CENTERTIP) {
     356            rect.left -= (size.cx / 2);
     357            rect.top  -= (size.cy / 2);
     358        }
     359
     360        /* smart placement */
     361        if ((rect.left + size.cx > rcTool.left) && (rect.left < rcTool.right) &&
     362            (rect.top + size.cy > rcTool.top) && (rect.top < rcTool.bottom))
     363            rect.left = rcTool.right;
    363364    }
    364365
     
    369370
    370371    AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE),
    371                         FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE));
     372                        FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE));
    372373
    373374    SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top,
    374                     rect.right - rect.left, rect.bottom - rect.top,
    375                     SWP_SHOWWINDOW | SWP_NOACTIVATE );
     375                    rect.right - rect.left, rect.bottom - rect.top,
     376                    SWP_SHOWWINDOW | SWP_NOACTIVATE );
    376377
    377378    hdc = GetDC (hwnd);
     
    388389
    389390    if (infoPtr->nTrackTool == -1)
    390         return;
     391        return;
    391392
    392393    toolPtr = &infoPtr->tools[infoPtr->nTrackTool];
     
    397398    hdr.code = TTN_POP;
    398399    SendMessageA (toolPtr->hwnd, WM_NOTIFY,
    399                     (WPARAM)toolPtr->uId, (LPARAM)&hdr);
     400                    (WPARAM)toolPtr->uId, (LPARAM)&hdr);
    400401
    401402    SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,
    402                     SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
     403                    SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
    403404}
    404405
     
    411412
    412413    for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
    413         toolPtr = &infoPtr->tools[nTool];
    414 
    415         if (!(toolPtr->uFlags & TTF_IDISHWND) &&
    416             (lpToolInfo->hwnd == toolPtr->hwnd) &&
    417             (lpToolInfo->uId == toolPtr->uId))
    418             return nTool;
     414        toolPtr = &infoPtr->tools[nTool];
     415
     416        if (!(toolPtr->uFlags & TTF_IDISHWND) &&
     417            (lpToolInfo->hwnd == toolPtr->hwnd) &&
     418            (lpToolInfo->uId == toolPtr->uId))
     419            return nTool;
    419420    }
    420421
    421422    for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
    422         toolPtr = &infoPtr->tools[nTool];
    423 
    424         if ((toolPtr->uFlags & TTF_IDISHWND) &&
    425             (lpToolInfo->uId == toolPtr->uId))
    426             return nTool;
     423        toolPtr = &infoPtr->tools[nTool];
     424
     425        if ((toolPtr->uFlags & TTF_IDISHWND) &&
     426            (lpToolInfo->uId == toolPtr->uId))
     427            return nTool;
    427428    }
    428429
     
    438439
    439440    for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
    440         toolPtr = &infoPtr->tools[nTool];
    441 
    442         if (!(toolPtr->uFlags & TTF_IDISHWND) &&
    443             (lpToolInfo->hwnd == toolPtr->hwnd) &&
    444             (lpToolInfo->uId == toolPtr->uId))
    445             return nTool;
     441        toolPtr = &infoPtr->tools[nTool];
     442
     443        if (!(toolPtr->uFlags & TTF_IDISHWND) &&
     444            (lpToolInfo->hwnd == toolPtr->hwnd) &&
     445            (lpToolInfo->uId == toolPtr->uId))
     446            return nTool;
    446447    }
    447448
    448449    for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
    449         toolPtr = &infoPtr->tools[nTool];
    450 
    451         if ((toolPtr->uFlags & TTF_IDISHWND) &&
    452             (lpToolInfo->uId == toolPtr->uId))
    453             return nTool;
     450        toolPtr = &infoPtr->tools[nTool];
     451
     452        if ((toolPtr->uFlags & TTF_IDISHWND) &&
     453            (lpToolInfo->uId == toolPtr->uId))
     454            return nTool;
    454455    }
    455456
     
    465466
    466467    for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
    467         toolPtr = &infoPtr->tools[nTool];
    468 
    469         if (!(toolPtr->uFlags & TTF_IDISHWND)) {
    470             if (hwnd != toolPtr->hwnd)
    471                 continue;
    472             if (!PtInRect (&toolPtr->rect, *lpPt))
    473                 continue;
    474             return nTool;
    475         }
     468        toolPtr = &infoPtr->tools[nTool];
     469
     470        if (!(toolPtr->uFlags & TTF_IDISHWND)) {
     471            if (hwnd != toolPtr->hwnd)
     472                continue;
     473            if (!PtInRect (&toolPtr->rect, *lpPt))
     474                continue;
     475            return nTool;
     476        }
    476477    }
    477478
    478479    for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
    479         toolPtr = &infoPtr->tools[nTool];
    480 
    481         if (toolPtr->uFlags & TTF_IDISHWND) {
    482             if ((HWND)toolPtr->uId == hwnd)
    483                 return nTool;
    484         }
     480        toolPtr = &infoPtr->tools[nTool];
     481
     482        if (toolPtr->uFlags & TTF_IDISHWND) {
     483            if ((HWND)toolPtr->uId == hwnd)
     484                return nTool;
     485        }
    485486    }
    486487
     
    509510    HWND hwndActive = GetActiveWindow ();
    510511    if (!hwndActive)
    511         return FALSE;
     512        return FALSE;
    512513    if (hwndActive == hwnd)
    513         return TRUE;
     514        return TRUE;
    514515    return IsChild (hwndActive, hwnd);
    515516}
     
    527528    hwndTool = SendMessageA (hwnd, TTM_WINDOWFROMPOINT, 0, (LPARAM)&pt);
    528529    if (hwndTool == 0)
    529         return -1;
     530        return -1;
    530531
    531532    ScreenToClient (hwndTool, &pt);
    532533    nTool = TOOLTIPS_GetToolFromPoint (infoPtr, hwndTool, &pt);
    533534    if (nTool == -1)
    534         return -1;
     535        return -1;
    535536
    536537    if (!(GetWindowLongA (hwnd, GWL_STYLE) & TTS_ALWAYSTIP) && bShowTest) {
    537         if (!TOOLTIPS_IsWindowActive (GetWindow (hwnd, GW_OWNER)))
    538             return -1;
     538        if (!TOOLTIPS_IsWindowActive (GetWindow (hwnd, GW_OWNER)))
     539            return -1;
    539540    }
    540541
     
    553554
    554555//    if (infoPtr->bActive)
    555 //      TRACE (tooltips, "activate!\n");
    556 
    557     if (!(infoPtr->bActive) && (infoPtr->nCurrentTool != -1)) 
    558         TOOLTIPS_Hide (hwnd, infoPtr);
     556//      TRACE (tooltips, "activate!\n");
     557
     558    if (!(infoPtr->bActive) && (infoPtr->nCurrentTool != -1))
     559        TOOLTIPS_Hide (hwnd, infoPtr);
    559560
    560561    return 0;
     
    570571
    571572    if (lpToolInfo == NULL)
    572         return FALSE;
     573        return FALSE;
    573574    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    574         return FALSE;
     575        return FALSE;
    575576
    576577//    TRACE (tooltips, "add tool (%x) %x %d%s!\n",
    577 //         hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
    578 //         (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
     578//         hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
     579//         (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
    579580
    580581    if (infoPtr->uNumTools == 0) {
    581         infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO));
    582         toolPtr = infoPtr->tools;
     582        infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO));
     583        toolPtr = infoPtr->tools;
    583584    }
    584585    else {
    585         TTTOOL_INFO *oldTools = infoPtr->tools;
    586         infoPtr->tools =
    587             COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1));
    588         memcpy (infoPtr->tools, oldTools,
    589                 infoPtr->uNumTools * sizeof(TTTOOL_INFO));
    590         COMCTL32_Free (oldTools);
    591         toolPtr = &infoPtr->tools[infoPtr->uNumTools];
     586        TTTOOL_INFO *oldTools = infoPtr->tools;
     587        infoPtr->tools =
     588            COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1));
     589        memcpy (infoPtr->tools, oldTools,
     590                infoPtr->uNumTools * sizeof(TTTOOL_INFO));
     591        COMCTL32_Free (oldTools);
     592        toolPtr = &infoPtr->tools[infoPtr->uNumTools];
    592593    }
    593594
     
    602603
    603604    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
    604 //      TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText);
    605         toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
     605//      TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText);
     606        toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
    606607    }
    607608    else if (lpToolInfo->lpszText) {
    608         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) {
    609 //          TRACE (tooltips, "add CALLBACK!\n");
    610             toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    611         }
    612         else {
    613             INT len = lstrlenA (lpToolInfo->lpszText);
    614 //          TRACE (tooltips, "add text \"%s\"!\n", lpToolInfo->lpszText);
    615             toolPtr->lpszText = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    616             lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
    617         }
     609        if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) {
     610//          TRACE (tooltips, "add CALLBACK!\n");
     611            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     612        }
     613        else {
     614            INT len = lstrlenA (lpToolInfo->lpszText);
     615//          TRACE (tooltips, "add text \"%s\"!\n", lpToolInfo->lpszText);
     616            toolPtr->lpszText = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     617            lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
     618        }
    618619    }
    619620
    620621    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
    621         toolPtr->lParam = lpToolInfo->lParam;
     622        toolPtr->lParam = lpToolInfo->lParam;
    622623
    623624    /* install subclassing hook */
    624625    if (toolPtr->uFlags & TTF_SUBCLASS) {
    625         if (toolPtr->uFlags & TTF_IDISHWND) {
    626             LPTT_SUBCLASS_INFO lpttsi =
    627                 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    628             if (lpttsi == NULL) {
    629                 lpttsi =
    630                     (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
    631                 lpttsi->wpOrigProc =
    632                     (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId,
    633                     GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
    634                 lpttsi->hwndToolTip = hwnd;
    635                 lpttsi->uRefCount++;
    636                 SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass,
    637                             (HANDLE)lpttsi);
    638             }
    639 //          else
    640 //              WARN (tooltips, "A window tool must only be listed once!\n");
    641         }
    642         else {
    643             LPTT_SUBCLASS_INFO lpttsi =
    644                 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
    645             if (lpttsi == NULL) {
    646                 lpttsi =
    647                     (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
    648                 lpttsi->wpOrigProc =
    649                     (WNDPROC)SetWindowLongA (toolPtr->hwnd,
    650                     GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
    651                 lpttsi->hwndToolTip = hwnd;
    652                 lpttsi->uRefCount++;
    653                 SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi);
    654             }
    655             else
    656                 lpttsi->uRefCount++;
    657         }
    658 //      TRACE (tooltips, "subclassing installed!\n");
     626        if (toolPtr->uFlags & TTF_IDISHWND) {
     627            LPTT_SUBCLASS_INFO lpttsi =
     628                (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
     629            if (lpttsi == NULL) {
     630                lpttsi =
     631                    (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
     632                lpttsi->wpOrigProc =
     633                    (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId,
     634                    GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
     635                lpttsi->hwndToolTip = hwnd;
     636                lpttsi->uRefCount++;
     637                SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass,
     638                            (HANDLE)lpttsi);
     639            }
     640//          else
     641//              WARN (tooltips, "A window tool must only be listed once!\n");
     642        }
     643        else {
     644            LPTT_SUBCLASS_INFO lpttsi =
     645                (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
     646            if (lpttsi == NULL) {
     647                lpttsi =
     648                    (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
     649                lpttsi->wpOrigProc =
     650                    (WNDPROC)SetWindowLongA (toolPtr->hwnd,
     651                    GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
     652                lpttsi->hwndToolTip = hwnd;
     653                lpttsi->uRefCount++;
     654                SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi);
     655            }
     656            else
     657                lpttsi->uRefCount++;
     658        }
     659//      TRACE (tooltips, "subclassing installed!\n");
    659660    }
    660661
     
    671672
    672673    if (lpToolInfo == NULL)
    673         return FALSE;
     674        return FALSE;
    674675    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    675         return FALSE;
     676        return FALSE;
    676677
    677678//    TRACE (tooltips, "add tool (%x) %x %d%s!\n",
    678 //         hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
    679 //         (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
     679//         hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
     680//         (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
    680681
    681682    if (infoPtr->uNumTools == 0) {
    682         infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO));
    683         toolPtr = infoPtr->tools;
     683        infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO));
     684        toolPtr = infoPtr->tools;
    684685    }
    685686    else {
    686         TTTOOL_INFO *oldTools = infoPtr->tools;
    687         infoPtr->tools =
    688             COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1));
    689         memcpy (infoPtr->tools, oldTools,
    690                 infoPtr->uNumTools * sizeof(TTTOOL_INFO));
    691         COMCTL32_Free (oldTools);
    692         toolPtr = &infoPtr->tools[infoPtr->uNumTools];
     687        TTTOOL_INFO *oldTools = infoPtr->tools;
     688        infoPtr->tools =
     689            COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1));
     690        memcpy (infoPtr->tools, oldTools,
     691                infoPtr->uNumTools * sizeof(TTTOOL_INFO));
     692        COMCTL32_Free (oldTools);
     693        toolPtr = &infoPtr->tools[infoPtr->uNumTools];
    693694    }
    694695
     
    703704
    704705    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
    705 //      TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText);
    706         toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
     706//      TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText);
     707        toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
    707708    }
    708709    else if (lpToolInfo->lpszText) {
    709         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) {
    710 //          TRACE (tooltips, "add CALLBACK!\n");
    711             toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    712         }
    713         else {
    714             INT len = lstrlenW (lpToolInfo->lpszText);
    715 //          TRACE (tooltips, "add text \"%s\"!\n",
    716 //                 debugstr_w(lpToolInfo->lpszText));
    717             toolPtr->lpszText = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    718             lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
    719         }
     710        if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) {
     711//          TRACE (tooltips, "add CALLBACK!\n");
     712            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     713        }
     714        else {
     715            INT len = lstrlenW (lpToolInfo->lpszText);
     716//          TRACE (tooltips, "add text \"%s\"!\n",
     717//                 debugstr_w(lpToolInfo->lpszText));
     718            toolPtr->lpszText = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     719            lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
     720        }
    720721    }
    721722
    722723    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
    723         toolPtr->lParam = lpToolInfo->lParam;
     724        toolPtr->lParam = lpToolInfo->lParam;
    724725
    725726    /* install subclassing hook */
    726727    if (toolPtr->uFlags & TTF_SUBCLASS) {
    727         if (toolPtr->uFlags & TTF_IDISHWND) {
    728             LPTT_SUBCLASS_INFO lpttsi =
    729                 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    730             if (lpttsi == NULL) {
    731                 lpttsi =
    732                     (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
    733                 lpttsi->wpOrigProc =
    734                     (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId,
    735                     GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
    736                 lpttsi->hwndToolTip = hwnd;
    737                 lpttsi->uRefCount++;
    738                 SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass,
    739                             (HANDLE)lpttsi);
    740             }
    741 //          else
    742 //              WARN (tooltips, "A window tool must only be listed once!\n");
    743         }
    744         else {
    745             LPTT_SUBCLASS_INFO lpttsi =
    746                 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
    747             if (lpttsi == NULL) {
    748                 lpttsi =
    749                     (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
    750                 lpttsi->wpOrigProc =
    751                     (WNDPROC)SetWindowLongA (toolPtr->hwnd,
    752                     GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
    753                 lpttsi->hwndToolTip = hwnd;
    754                 lpttsi->uRefCount++;
    755                 SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi);
    756             }
    757             else
    758                 lpttsi->uRefCount++;
    759         }
    760 //      TRACE (tooltips, "subclassing installed!\n");
     728        if (toolPtr->uFlags & TTF_IDISHWND) {
     729            LPTT_SUBCLASS_INFO lpttsi =
     730                (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
     731            if (lpttsi == NULL) {
     732                lpttsi =
     733                    (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
     734                lpttsi->wpOrigProc =
     735                    (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId,
     736                    GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
     737                lpttsi->hwndToolTip = hwnd;
     738                lpttsi->uRefCount++;
     739                SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass,
     740                            (HANDLE)lpttsi);
     741            }
     742//          else
     743//              WARN (tooltips, "A window tool must only be listed once!\n");
     744        }
     745        else {
     746            LPTT_SUBCLASS_INFO lpttsi =
     747                (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
     748            if (lpttsi == NULL) {
     749                lpttsi =
     750                    (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
     751                lpttsi->wpOrigProc =
     752                    (WNDPROC)SetWindowLongA (toolPtr->hwnd,
     753                    GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
     754                lpttsi->hwndToolTip = hwnd;
     755                lpttsi->uRefCount++;
     756                SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi);
     757            }
     758            else
     759                lpttsi->uRefCount++;
     760        }
     761//      TRACE (tooltips, "subclassing installed!\n");
    761762    }
    762763
     
    774775
    775776    if (lpToolInfo == NULL)
    776         return 0;
     777        return 0;
    777778    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    778         return 0;
     779        return 0;
    779780    if (infoPtr->uNumTools == 0)
    780         return 0;
     781        return 0;
    781782
    782783    nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
     
    786787
    787788    /* delete text string */
    788     toolPtr = &infoPtr->tools[nTool]; 
     789    toolPtr = &infoPtr->tools[nTool];
    789790    if ((toolPtr->hinst) && (toolPtr->lpszText)) {
    790         if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW)
    791             COMCTL32_Free (toolPtr->lpszText);
     791        if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW)
     792            COMCTL32_Free (toolPtr->lpszText);
    792793    }
    793794
    794795    /* remove subclassing */
    795796    if (toolPtr->uFlags & TTF_SUBCLASS) {
    796         if (toolPtr->uFlags & TTF_IDISHWND) {
    797             LPTT_SUBCLASS_INFO lpttsi =
    798                 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    799             if (lpttsi) {
    800                 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
    801                                   (LONG)lpttsi->wpOrigProc);
    802                 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    803                 COMCTL32_Free (&lpttsi);
    804             }
    805 //          else
    806 //              ERR (tooltips, "Invalid data handle!\n");
    807         }
    808         else {
    809             LPTT_SUBCLASS_INFO lpttsi =
    810                 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
    811             if (lpttsi) {
    812                 if (lpttsi->uRefCount == 1) {
    813                     SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
    814                                       (LONG)lpttsi->wpOrigProc);
    815                     RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    816                     COMCTL32_Free (&lpttsi);
    817                 }
    818                 else
    819                     lpttsi->uRefCount--;
    820             }
    821 //          else
    822 //              ERR (tooltips, "Invalid data handle!\n");
    823         }
     797        if (toolPtr->uFlags & TTF_IDISHWND) {
     798            LPTT_SUBCLASS_INFO lpttsi =
     799                (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
     800            if (lpttsi) {
     801                SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
     802                                  (LONG)lpttsi->wpOrigProc);
     803                RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
     804                COMCTL32_Free (&lpttsi);
     805            }
     806//          else
     807//              ERR (tooltips, "Invalid data handle!\n");
     808        }
     809        else {
     810            LPTT_SUBCLASS_INFO lpttsi =
     811                (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
     812            if (lpttsi) {
     813                if (lpttsi->uRefCount == 1) {
     814                    SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
     815                                      (LONG)lpttsi->wpOrigProc);
     816                    RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
     817                    COMCTL32_Free (&lpttsi);
     818                }
     819                else
     820                    lpttsi->uRefCount--;
     821            }
     822//          else
     823//              ERR (tooltips, "Invalid data handle!\n");
     824        }
    824825    }
    825826
    826827    /* delete tool from tool list */
    827828    if (infoPtr->uNumTools == 1) {
    828         COMCTL32_Free (infoPtr->tools);
    829         infoPtr->tools = NULL;
     829        COMCTL32_Free (infoPtr->tools);
     830        infoPtr->tools = NULL;
    830831    }
    831832    else {
    832         TTTOOL_INFO *oldTools = infoPtr->tools;
    833         infoPtr->tools =
    834             COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
    835 
    836         if (nTool > 0)
    837             memcpy (&infoPtr->tools[0], &oldTools[0],
    838                     nTool * sizeof(TTTOOL_INFO));
    839 
    840         if (nTool < infoPtr->uNumTools - 1)
    841             memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
    842                     (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
    843 
    844         COMCTL32_Free (oldTools);
     833        TTTOOL_INFO *oldTools = infoPtr->tools;
     834        infoPtr->tools =
     835            COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
     836
     837        if (nTool > 0)
     838            memcpy (&infoPtr->tools[0], &oldTools[0],
     839                    nTool * sizeof(TTTOOL_INFO));
     840
     841        if (nTool < infoPtr->uNumTools - 1)
     842            memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
     843                    (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
     844
     845        COMCTL32_Free (oldTools);
    845846    }
    846847
     
    860861
    861862    if (lpToolInfo == NULL)
    862         return 0;
     863        return 0;
    863864    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    864         return 0;
     865        return 0;
    865866    if (infoPtr->uNumTools == 0)
    866         return 0;
     867        return 0;
    867868
    868869    nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
     
    872873
    873874    /* delete text string */
    874     toolPtr = &infoPtr->tools[nTool]; 
     875    toolPtr = &infoPtr->tools[nTool];
    875876    if ((toolPtr->hinst) && (toolPtr->lpszText)) {
    876         if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW)
    877             COMCTL32_Free (toolPtr->lpszText);
     877        if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW)
     878            COMCTL32_Free (toolPtr->lpszText);
    878879    }
    879880
    880881    /* remove subclassing */
    881882    if (toolPtr->uFlags & TTF_SUBCLASS) {
    882         if (toolPtr->uFlags & TTF_IDISHWND) {
    883             LPTT_SUBCLASS_INFO lpttsi =
    884                 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    885             if (lpttsi) {
    886                 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
    887                                   (LONG)lpttsi->wpOrigProc);
    888                 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    889                 COMCTL32_Free (&lpttsi);
    890             }
    891 //          else
    892 //              ERR (tooltips, "Invalid data handle!\n");
    893         }
    894         else {
    895             LPTT_SUBCLASS_INFO lpttsi =
    896                 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
    897             if (lpttsi) {
    898                 if (lpttsi->uRefCount == 1) {
    899                     SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
    900                                       (LONG)lpttsi->wpOrigProc);
    901                     RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    902                     COMCTL32_Free (&lpttsi);
    903                 }
    904                 else
    905                     lpttsi->uRefCount--;
    906             }
    907 //          else
    908 //              ERR (tooltips, "Invalid data handle!\n");
    909         }
     883        if (toolPtr->uFlags & TTF_IDISHWND) {
     884            LPTT_SUBCLASS_INFO lpttsi =
     885                (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
     886            if (lpttsi) {
     887                SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
     888                                  (LONG)lpttsi->wpOrigProc);
     889                RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
     890                COMCTL32_Free (&lpttsi);
     891            }
     892//          else
     893//              ERR (tooltips, "Invalid data handle!\n");
     894        }
     895        else {
     896            LPTT_SUBCLASS_INFO lpttsi =
     897                (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
     898            if (lpttsi) {
     899                if (lpttsi->uRefCount == 1) {
     900                    SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
     901                                      (LONG)lpttsi->wpOrigProc);
     902                    RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
     903                    COMCTL32_Free (&lpttsi);
     904                }
     905                else
     906                    lpttsi->uRefCount--;
     907            }
     908//          else
     909//              ERR (tooltips, "Invalid data handle!\n");
     910        }
    910911    }
    911912
    912913    /* delete tool from tool list */
    913914    if (infoPtr->uNumTools == 1) {
    914         COMCTL32_Free (infoPtr->tools);
    915         infoPtr->tools = NULL;
     915        COMCTL32_Free (infoPtr->tools);
     916        infoPtr->tools = NULL;
    916917    }
    917918    else {
    918         TTTOOL_INFO *oldTools = infoPtr->tools;
    919         infoPtr->tools =
    920             COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
    921 
    922         if (nTool > 0)
    923             memcpy (&infoPtr->tools[0], &oldTools[0],
    924                     nTool * sizeof(TTTOOL_INFO));
    925 
    926         if (nTool < infoPtr->uNumTools - 1)
    927             memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
    928                     (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
    929 
    930         COMCTL32_Free (oldTools);
     919        TTTOOL_INFO *oldTools = infoPtr->tools;
     920        infoPtr->tools =
     921            COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
     922
     923        if (nTool > 0)
     924            memcpy (&infoPtr->tools[0], &oldTools[0],
     925                    nTool * sizeof(TTTOOL_INFO));
     926
     927        if (nTool < infoPtr->uNumTools - 1)
     928            memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
     929                    (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
     930
     931        COMCTL32_Free (oldTools);
    931932    }
    932933
     
    946947
    947948    if (lpToolInfo == NULL)
    948         return FALSE;
     949        return FALSE;
    949950    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    950         return FALSE;
     951        return FALSE;
    951952    if (uIndex >= infoPtr->uNumTools)
    952         return FALSE;
     953        return FALSE;
    953954
    954955//    TRACE (tooltips, "index=%u\n", uIndex);
     
    966967
    967968    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
    968         lpToolInfo->lParam = toolPtr->lParam;
     969        lpToolInfo->lParam = toolPtr->lParam;
    969970
    970971    return TRUE;
     
    981982
    982983    if (lpToolInfo == NULL)
    983         return FALSE;
     984        return FALSE;
    984985    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    985         return FALSE;
     986        return FALSE;
    986987    if (uIndex >= infoPtr->uNumTools)
    987         return FALSE;
     988        return FALSE;
    988989
    989990//    TRACE (tooltips, "index=%u\n", uIndex);
     
    10011002
    10021003    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
    1003         lpToolInfo->lParam = toolPtr->lParam;
     1004        lpToolInfo->lParam = toolPtr->lParam;
    10041005
    10051006    return TRUE;
     
    10151016
    10161017    if (lpToolInfo == NULL)
    1017         return FALSE;
     1018        return FALSE;
    10181019    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    1019         return FALSE;
     1020        return FALSE;
    10201021
    10211022    if (lpToolInfo) {
    1022         if (infoPtr->nCurrentTool > -1) {
    1023             toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
    1024 
    1025             /* copy tool data */
    1026             lpToolInfo->uFlags   = toolPtr->uFlags;
    1027             lpToolInfo->rect     = toolPtr->rect;
    1028             lpToolInfo->hinst    = toolPtr->hinst;
    1029 /*          lpToolInfo->lpszText = toolPtr->lpszText; */
    1030             lpToolInfo->lpszText = NULL;  /* FIXME */
    1031 
    1032             if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
    1033                 lpToolInfo->lParam = toolPtr->lParam;
    1034 
    1035             return TRUE;
    1036         }
    1037         else
    1038             return FALSE;
     1023        if (infoPtr->nCurrentTool > -1) {
     1024            toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
     1025
     1026            /* copy tool data */
     1027            lpToolInfo->uFlags   = toolPtr->uFlags;
     1028            lpToolInfo->rect     = toolPtr->rect;
     1029            lpToolInfo->hinst    = toolPtr->hinst;
     1030/*          lpToolInfo->lpszText = toolPtr->lpszText; */
     1031            lpToolInfo->lpszText = NULL;  /* FIXME */
     1032
     1033            if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
     1034                lpToolInfo->lParam = toolPtr->lParam;
     1035
     1036            return TRUE;
     1037        }
     1038        else
     1039            return FALSE;
    10391040    }
    10401041    else
    1041         return (infoPtr->nCurrentTool != -1);
     1042        return (infoPtr->nCurrentTool != -1);
    10421043
    10431044    return FALSE;
     
    10531054
    10541055    if (lpToolInfo == NULL)
    1055         return FALSE;
     1056        return FALSE;
    10561057    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    1057         return FALSE;
     1058        return FALSE;
    10581059
    10591060    if (lpToolInfo) {
    1060         if (infoPtr->nCurrentTool > -1) {
    1061             toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
    1062 
    1063             /* copy tool data */
    1064             lpToolInfo->uFlags   = toolPtr->uFlags;
    1065             lpToolInfo->rect     = toolPtr->rect;
    1066             lpToolInfo->hinst    = toolPtr->hinst;
    1067 /*          lpToolInfo->lpszText = toolPtr->lpszText; */
    1068             lpToolInfo->lpszText = NULL;  /* FIXME */
    1069 
    1070             if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
    1071                 lpToolInfo->lParam = toolPtr->lParam;
    1072 
    1073             return TRUE;
    1074         }
    1075         else
    1076             return FALSE;
     1061        if (infoPtr->nCurrentTool > -1) {
     1062            toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
     1063
     1064            /* copy tool data */
     1065            lpToolInfo->uFlags   = toolPtr->uFlags;
     1066            lpToolInfo->rect     = toolPtr->rect;
     1067            lpToolInfo->hinst    = toolPtr->hinst;
     1068/*          lpToolInfo->lpszText = toolPtr->lpszText; */
     1069            lpToolInfo->lpszText = NULL;  /* FIXME */
     1070
     1071            if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
     1072                lpToolInfo->lParam = toolPtr->lParam;
     1073
     1074            return TRUE;
     1075        }
     1076        else
     1077            return FALSE;
    10771078    }
    10781079    else
    1079         return (infoPtr->nCurrentTool != -1);
     1080        return (infoPtr->nCurrentTool != -1);
    10801081
    10811082    return FALSE;
     
    10891090
    10901091    switch (wParam) {
    1091         case TTDT_AUTOMATIC:
    1092             return infoPtr->nAutomaticTime;
    1093 
    1094         case TTDT_RESHOW:
    1095             return infoPtr->nReshowTime;
    1096 
    1097         case TTDT_AUTOPOP:
    1098             return infoPtr->nAutoPopTime;
    1099 
    1100         case TTDT_INITIAL:
    1101             return infoPtr->nInitialTime;
     1092        case TTDT_AUTOMATIC:
     1093            return infoPtr->nAutomaticTime;
     1094
     1095        case TTDT_RESHOW:
     1096            return infoPtr->nReshowTime;
     1097
     1098        case TTDT_AUTOPOP:
     1099            return infoPtr->nAutoPopTime;
     1100
     1101        case TTDT_INITIAL:
     1102            return infoPtr->nInitialTime;
    11021103    }
    11031104
     
    11381139
    11391140    if (lpToolInfo == NULL)
    1140         return 0;
     1141        return 0;
    11411142    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    1142         return 0;
     1143        return 0;
    11431144
    11441145    nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
     
    11591160
    11601161    if (lpToolInfo == NULL)
    1161         return 0;
     1162        return 0;
    11621163    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    1163         return 0;
     1164        return 0;
    11641165
    11651166    nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
     
    12051206
    12061207    if (lpToolInfo == NULL)
    1207         return FALSE;
     1208        return FALSE;
    12081209    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    1209         return FALSE;
     1210        return FALSE;
    12101211    if (infoPtr->uNumTools == 0)
    1211         return FALSE;
     1212        return FALSE;
    12121213
    12131214    nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
    12141215    if (nTool == -1)
    1215         return FALSE;
     1216        return FALSE;
    12161217
    12171218//    TRACE (tooltips, "tool %d\n", nTool);
     
    12271228
    12281229    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
    1229         lpToolInfo->lParam = toolPtr->lParam;
     1230        lpToolInfo->lParam = toolPtr->lParam;
    12301231
    12311232    return TRUE;
     
    12421243
    12431244    if (lpToolInfo == NULL)
    1244         return FALSE;
     1245        return FALSE;
    12451246    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    1246         return FALSE;
     1247        return FALSE;
    12471248    if (infoPtr->uNumTools == 0)
    1248         return FALSE;
     1249        return FALSE;
    12491250
    12501251    nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
    12511252    if (nTool == -1)
    1252         return FALSE;
     1253        return FALSE;
    12531254
    12541255//    TRACE (tooltips, "tool %d\n", nTool);
     
    12641265
    12651266    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
    1266         lpToolInfo->lParam = toolPtr->lParam;
     1267        lpToolInfo->lParam = toolPtr->lParam;
    12671268
    12681269    return TRUE;
     
    12791280
    12801281    if (lptthit == 0)
    1281         return FALSE;
     1282        return FALSE;
    12821283
    12831284    nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt);
    12841285    if (nTool == -1)
    1285         return FALSE;
     1286        return FALSE;
    12861287
    12871288//    TRACE (tooltips, "tool %d!\n", nTool);
     
    12891290    /* copy tool data */
    12901291    if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOA)) {
    1291         toolPtr = &infoPtr->tools[nTool];
    1292 
    1293         lptthit->ti.uFlags   = toolPtr->uFlags;
    1294         lptthit->ti.hwnd     = toolPtr->hwnd;
    1295         lptthit->ti.uId      = toolPtr->uId;
    1296         lptthit->ti.rect     = toolPtr->rect;
    1297         lptthit->ti.hinst    = toolPtr->hinst;
    1298 /*      lptthit->ti.lpszText = toolPtr->lpszText; */
    1299         lptthit->ti.lpszText = NULL;  /* FIXME */
    1300         lptthit->ti.lParam   = toolPtr->lParam;
     1292        toolPtr = &infoPtr->tools[nTool];
     1293
     1294        lptthit->ti.uFlags   = toolPtr->uFlags;
     1295        lptthit->ti.hwnd     = toolPtr->hwnd;
     1296        lptthit->ti.uId      = toolPtr->uId;
     1297        lptthit->ti.rect     = toolPtr->rect;
     1298        lptthit->ti.hinst    = toolPtr->hinst;
     1299/*      lptthit->ti.lpszText = toolPtr->lpszText; */
     1300        lptthit->ti.lpszText = NULL;  /* FIXME */
     1301        lptthit->ti.lParam   = toolPtr->lParam;
    13011302    }
    13021303
     
    13141315
    13151316    if (lptthit == 0)
    1316         return FALSE;
     1317        return FALSE;
    13171318
    13181319    nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt);
    13191320    if (nTool == -1)
    1320         return FALSE;
     1321        return FALSE;
    13211322
    13221323//    TRACE (tooltips, "tool %d!\n", nTool);
     
    13241325    /* copy tool data */
    13251326    if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOW)) {
    1326         toolPtr = &infoPtr->tools[nTool];
    1327 
    1328         lptthit->ti.uFlags   = toolPtr->uFlags;
    1329         lptthit->ti.hwnd     = toolPtr->hwnd;
    1330         lptthit->ti.uId      = toolPtr->uId;
    1331         lptthit->ti.rect     = toolPtr->rect;
    1332         lptthit->ti.hinst    = toolPtr->hinst;
    1333 /*      lptthit->ti.lpszText = toolPtr->lpszText; */
    1334         lptthit->ti.lpszText = NULL;  /* FIXME */
    1335         lptthit->ti.lParam   = toolPtr->lParam;
     1327        toolPtr = &infoPtr->tools[nTool];
     1328
     1329        lptthit->ti.uFlags   = toolPtr->uFlags;
     1330        lptthit->ti.hwnd     = toolPtr->hwnd;
     1331        lptthit->ti.uId      = toolPtr->uId;
     1332        lptthit->ti.rect     = toolPtr->rect;
     1333        lptthit->ti.hinst    = toolPtr->hinst;
     1334/*      lptthit->ti.lpszText = toolPtr->lpszText; */
     1335        lptthit->ti.lpszText = NULL;  /* FIXME */
     1336        lptthit->ti.lParam   = toolPtr->lParam;
    13361337    }
    13371338
     
    13481349
    13491350    if (lpti == NULL)
    1350         return 0;
     1351        return 0;
    13511352    if (lpti->cbSize < TTTOOLINFO_V1_SIZEA)
    1352         return FALSE;
     1353        return FALSE;
    13531354
    13541355    nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpti);
     
    13691370
    13701371    if (lpti == NULL)
    1371         return 0;
     1372        return 0;
    13721373    if (lpti->cbSize < TTTOOLINFO_V1_SIZEW)
    1373         return FALSE;
     1374        return FALSE;
    13741375
    13751376    nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpti);
     
    14011402
    14021403    if (lParam == 0) {
    1403 //      ERR (tooltips, "lpMsg == NULL!\n");
    1404         return 0;
     1404//      ERR (tooltips, "lpMsg == NULL!\n");
     1405        return 0;
    14051406    }
    14061407
    14071408    switch (lpMsg->message) {
    1408         case WM_LBUTTONDOWN:
    1409         case WM_LBUTTONUP:
    1410         case WM_MBUTTONDOWN:
    1411         case WM_MBUTTONUP:
    1412         case WM_RBUTTONDOWN:
    1413         case WM_RBUTTONUP:
    1414             pt = lpMsg->pt;
    1415             ScreenToClient (lpMsg->hwnd, &pt);
    1416             infoPtr->nOldTool = infoPtr->nTool;
    1417             infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd, &pt);
    1418 //          TRACE (tooltips, "tool (%x) %d %d\n",
    1419 //                 hwnd, infoPtr->nOldTool, infoPtr->nTool);
    1420             TOOLTIPS_Hide (hwnd, infoPtr);
    1421             break;
    1422 
    1423         case WM_MOUSEMOVE:
    1424             pt = lpMsg->pt;
    1425             ScreenToClient (lpMsg->hwnd, &pt);
    1426             infoPtr->nOldTool = infoPtr->nTool;
    1427             infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd, &pt);
    1428 //          TRACE (tooltips, "tool (%x) %d %d\n",
    1429 //                 hwnd, infoPtr->nOldTool, infoPtr->nTool);
    1430 //          TRACE (tooltips, "WM_MOUSEMOVE (%04x %ld %ld)\n",
    1431 //                 hwnd, pt.x, pt.y);
    1432             if ((infoPtr->bActive) && (infoPtr->nTool != infoPtr->nOldTool)) {
    1433                 if (infoPtr->nOldTool == -1) {
    1434                     SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nInitialTime, 0);
    1435 //                  TRACE (tooltips, "timer 1 started!\n");
    1436                 }
    1437                 else {
    1438                     TOOLTIPS_Hide (hwnd, infoPtr);
    1439                     SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0);
    1440 //                  TRACE (tooltips, "timer 2 started!\n");
    1441                 }
    1442             }
    1443             if (infoPtr->nCurrentTool != -1) {
    1444                 SetTimer (hwnd, ID_TIMERLEAVE, 100, 0);
    1445 //              TRACE (tooltips, "timer 3 started!\n");
    1446             }
    1447             break;
     1409        case WM_LBUTTONDOWN:
     1410        case WM_LBUTTONUP:
     1411        case WM_MBUTTONDOWN:
     1412        case WM_MBUTTONUP:
     1413        case WM_RBUTTONDOWN:
     1414        case WM_RBUTTONUP:
     1415            pt = lpMsg->pt;
     1416            ScreenToClient (lpMsg->hwnd, &pt);
     1417            infoPtr->nOldTool = infoPtr->nTool;
     1418            infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd, &pt);
     1419//          TRACE (tooltips, "tool (%x) %d %d\n",
     1420//                 hwnd, infoPtr->nOldTool, infoPtr->nTool);
     1421            TOOLTIPS_Hide (hwnd, infoPtr);
     1422            break;
     1423
     1424        case WM_MOUSEMOVE:
     1425            pt = lpMsg->pt;
     1426            ScreenToClient (lpMsg->hwnd, &pt);
     1427            infoPtr->nOldTool = infoPtr->nTool;
     1428            infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd, &pt);
     1429//          TRACE (tooltips, "tool (%x) %d %d\n",
     1430//                 hwnd, infoPtr->nOldTool, infoPtr->nTool);
     1431//          TRACE (tooltips, "WM_MOUSEMOVE (%04x %ld %ld)\n",
     1432//                 hwnd, pt.x, pt.y);
     1433            if ((infoPtr->bActive) && (infoPtr->nTool != infoPtr->nOldTool)) {
     1434                if (infoPtr->nOldTool == -1) {
     1435                    SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nInitialTime, 0);
     1436//                  TRACE (tooltips, "timer 1 started!\n");
     1437                }
     1438                else {
     1439                    TOOLTIPS_Hide (hwnd, infoPtr);
     1440                    SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0);
     1441//                  TRACE (tooltips, "timer 2 started!\n");
     1442                }
     1443            }
     1444            if (infoPtr->nCurrentTool != -1) {
     1445                SetTimer (hwnd, ID_TIMERLEAVE, 100, 0);
     1446//              TRACE (tooltips, "timer 3 started!\n");
     1447            }
     1448            break;
    14481449    }
    14491450
     
    14591460
    14601461    switch (wParam) {
    1461         case TTDT_AUTOMATIC:
    1462             if (nTime == 0) {
    1463                 infoPtr->nAutomaticTime = 500;
    1464                 infoPtr->nReshowTime    = 100;
    1465                 infoPtr->nAutoPopTime   = 5000;
    1466                 infoPtr->nInitialTime   = 500;
    1467             }
    1468             else {
    1469                 infoPtr->nAutomaticTime = nTime;
    1470                 infoPtr->nReshowTime    = nTime / 5;
    1471                 infoPtr->nAutoPopTime   = nTime * 10;
    1472                 infoPtr->nInitialTime   = nTime;
    1473             }
    1474             break;
    1475 
    1476         case TTDT_RESHOW:
    1477             infoPtr->nReshowTime = nTime;
    1478             break;
    1479 
    1480         case TTDT_AUTOPOP:
    1481             infoPtr->nAutoPopTime = nTime;
    1482             break;
    1483 
    1484         case TTDT_INITIAL:
    1485             infoPtr->nInitialTime = nTime;
    1486             break;
     1462        case TTDT_AUTOMATIC:
     1463            if (nTime == 0) {
     1464                infoPtr->nAutomaticTime = 500;
     1465                infoPtr->nReshowTime    = 100;
     1466                infoPtr->nAutoPopTime   = 5000;
     1467                infoPtr->nInitialTime   = 500;
     1468            }
     1469            else {
     1470                infoPtr->nAutomaticTime = nTime;
     1471                infoPtr->nReshowTime    = nTime / 5;
     1472                infoPtr->nAutoPopTime   = nTime * 10;
     1473                infoPtr->nInitialTime   = nTime;
     1474            }
     1475            break;
     1476
     1477        case TTDT_RESHOW:
     1478            infoPtr->nReshowTime = nTime;
     1479            break;
     1480
     1481        case TTDT_AUTOPOP:
     1482            infoPtr->nAutoPopTime = nTime;
     1483            break;
     1484
     1485        case TTDT_INITIAL:
     1486            infoPtr->nInitialTime = nTime;
     1487            break;
    14871488    }
    14881489
     
    15491550
    15501551    if (lpToolInfo == NULL)
    1551         return 0;
     1552        return 0;
    15521553    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    1553         return 0;
     1554        return 0;
    15541555
    15551556    nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
     
    15681569
    15691570    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
    1570 //      TRACE (tooltips, "set string id %x!\n", (INT)lpToolInfo->lpszText);
    1571         toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
     1571//      TRACE (tooltips, "set string id %x!\n", (INT)lpToolInfo->lpszText);
     1572        toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
    15721573    }
    15731574    else if (lpToolInfo->lpszText) {
    1574         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
    1575             toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    1576         else {
    1577             if (toolPtr->lpszText) {
    1578                 COMCTL32_Free (toolPtr->lpszText);
    1579                 toolPtr->lpszText = NULL;
    1580             }
    1581             if (lpToolInfo->lpszText) {
    1582                 INT len = lstrlenA (lpToolInfo->lpszText);
    1583                 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    1584                 lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
    1585             }
    1586         }
     1575        if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
     1576            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     1577        else {
     1578            if (toolPtr->lpszText) {
     1579                COMCTL32_Free (toolPtr->lpszText);
     1580                toolPtr->lpszText = NULL;
     1581            }
     1582            if (lpToolInfo->lpszText) {
     1583                INT len = lstrlenA (lpToolInfo->lpszText);
     1584                toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1585                lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
     1586            }
     1587        }
    15871588    }
    15881589
    15891590    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
    1590         toolPtr->lParam = lpToolInfo->lParam;
     1591        toolPtr->lParam = lpToolInfo->lParam;
    15911592
    15921593    return 0;
     
    16031604
    16041605    if (lpToolInfo == NULL)
    1605         return 0;
     1606        return 0;
    16061607    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    1607         return 0;
     1608        return 0;
    16081609
    16091610    nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
     
    16221623
    16231624    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
    1624 //      TRACE (tooltips, "set string id %x!\n", (INT)lpToolInfo->lpszText);
    1625         toolPtr->lpszText = lpToolInfo->lpszText;
     1625//      TRACE (tooltips, "set string id %x!\n", (INT)lpToolInfo->lpszText);
     1626        toolPtr->lpszText = lpToolInfo->lpszText;
    16261627    }
    16271628    else if (lpToolInfo->lpszText) {
    1628         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
    1629             toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    1630         else {
    1631             if (toolPtr->lpszText) {
    1632                 COMCTL32_Free (toolPtr->lpszText);
    1633                 toolPtr->lpszText = NULL;
    1634             }
    1635             if (lpToolInfo->lpszText) {
    1636                 INT len = lstrlenW (lpToolInfo->lpszText);
    1637                 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    1638                 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
    1639             }
    1640         }
     1629        if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
     1630            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     1631        else {
     1632            if (toolPtr->lpszText) {
     1633                COMCTL32_Free (toolPtr->lpszText);
     1634                toolPtr->lpszText = NULL;
     1635            }
     1636            if (lpToolInfo->lpszText) {
     1637                INT len = lstrlenW (lpToolInfo->lpszText);
     1638                toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1639                lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
     1640            }
     1641        }
    16411642    }
    16421643
    16431644    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
    1644         toolPtr->lParam = lpToolInfo->lParam;
     1645        toolPtr->lParam = lpToolInfo->lParam;
    16451646
    16461647    return 0;
     
    16551656
    16561657    if (lpToolInfo == NULL)
    1657         return 0;
     1658        return 0;
    16581659    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    1659         return FALSE;
     1660        return FALSE;
    16601661
    16611662    if ((BOOL)wParam) {
    1662         /* activate */
    1663         infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
    1664         if (infoPtr->nTrackTool != -1) {
    1665 //          TRACE (tooltips, "activated!\n");
    1666             infoPtr->bTrackActive = TRUE;
    1667             TOOLTIPS_TrackShow (hwnd, infoPtr);
    1668         }
     1663        /* activate */
     1664        infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
     1665        if (infoPtr->nTrackTool != -1) {
     1666//          TRACE (tooltips, "activated!\n");
     1667            infoPtr->bTrackActive = TRUE;
     1668            TOOLTIPS_TrackShow (hwnd, infoPtr);
     1669        }
    16691670    }
    16701671    else {
    1671         /* deactivate */
    1672         TOOLTIPS_TrackHide (hwnd, infoPtr);
    1673 
    1674         infoPtr->bTrackActive = FALSE;
    1675         infoPtr->nTrackTool = -1;
    1676 
    1677 //      TRACE (tooltips, "deactivated!\n");
     1672        /* deactivate */
     1673        TOOLTIPS_TrackHide (hwnd, infoPtr);
     1674
     1675        infoPtr->bTrackActive = FALSE;
     1676        infoPtr->nTrackTool = -1;
     1677
     1678//      TRACE (tooltips, "deactivated!\n");
    16781679    }
    16791680
     
    16911692
    16921693    if (infoPtr->bTrackActive) {
    1693 //      TRACE (tooltips, "[%d %d]\n",
    1694 //             infoPtr->xTrackPos, infoPtr->yTrackPos);
    1695 
    1696         TOOLTIPS_TrackShow (hwnd, infoPtr);
     1694//      TRACE (tooltips, "[%d %d]\n",
     1695//             infoPtr->xTrackPos, infoPtr->yTrackPos);
     1696
     1697        TOOLTIPS_TrackShow (hwnd, infoPtr);
    16971698    }
    16981699
     
    17071708
    17081709    if (infoPtr->nCurrentTool != -1)
    1709         UpdateWindow (hwnd);
     1710        UpdateWindow (hwnd);
    17101711
    17111712    return 0;
     
    17221723
    17231724    if (lpToolInfo == NULL)
    1724         return 0;
     1725        return 0;
    17251726    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    1726         return FALSE;
     1727        return FALSE;
    17271728
    17281729    nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
     
    17371738
    17381739    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){
    1739         toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
     1740        toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
    17401741    }
    17411742    else if (lpToolInfo->lpszText) {
    1742         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
    1743             toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    1744         else {
    1745             if (toolPtr->lpszText) {
    1746                 COMCTL32_Free (toolPtr->lpszText);
    1747                 toolPtr->lpszText = NULL;
    1748             }
    1749             if (lpToolInfo->lpszText) {
    1750                 INT len = lstrlenA (lpToolInfo->lpszText);
    1751                 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    1752                 lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
    1753             }
    1754         }
     1743        if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
     1744            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     1745        else {
     1746            if (toolPtr->lpszText) {
     1747                COMCTL32_Free (toolPtr->lpszText);
     1748                toolPtr->lpszText = NULL;
     1749            }
     1750            if (lpToolInfo->lpszText) {
     1751                INT len = lstrlenA (lpToolInfo->lpszText);
     1752                toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1753                lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
     1754            }
     1755        }
    17551756    }
    17561757
    17571758    /* force repaint */
    17581759    if (infoPtr->bActive)
    1759         TOOLTIPS_Show (hwnd, infoPtr);
     1760        TOOLTIPS_Show (hwnd, infoPtr);
    17601761    else if (infoPtr->bTrackActive)
    1761         TOOLTIPS_TrackShow (hwnd, infoPtr);
     1762        TOOLTIPS_TrackShow (hwnd, infoPtr);
    17621763
    17631764    return 0;
     
    17741775
    17751776    if (lpToolInfo == NULL)
    1776         return 0;
     1777        return 0;
    17771778    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    1778         return FALSE;
     1779        return FALSE;
    17791780
    17801781    nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
    17811782    if (nTool == -1)
    1782         return 0;
     1783        return 0;
    17831784
    17841785//    TRACE (tooltips, "tool %d\n", nTool);
     
    17901791
    17911792    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){
    1792         toolPtr->lpszText = lpToolInfo->lpszText;
     1793        toolPtr->lpszText = lpToolInfo->lpszText;
    17931794    }
    17941795    else if (lpToolInfo->lpszText) {
    1795         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
    1796             toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    1797         else {
    1798             if (toolPtr->lpszText) {
    1799                 COMCTL32_Free (toolPtr->lpszText);
    1800                 toolPtr->lpszText = NULL;
    1801             }
    1802             if (lpToolInfo->lpszText) {
    1803                 INT len = lstrlenW (lpToolInfo->lpszText);
    1804                 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    1805                 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
    1806             }
    1807         }
     1796        if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
     1797            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     1798        else {
     1799            if (toolPtr->lpszText) {
     1800                COMCTL32_Free (toolPtr->lpszText);
     1801                toolPtr->lpszText = NULL;
     1802            }
     1803            if (lpToolInfo->lpszText) {
     1804                INT len = lstrlenW (lpToolInfo->lpszText);
     1805                toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1806                lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
     1807            }
     1808        }
    18081809    }
    18091810
    18101811    /* force repaint */
    18111812    if (infoPtr->bActive)
    1812         TOOLTIPS_Show (hwnd, infoPtr);
     1813        TOOLTIPS_Show (hwnd, infoPtr);
    18131814    else if (infoPtr->bTrackActive)
    1814         TOOLTIPS_TrackShow (hwnd, infoPtr);
     1815        TOOLTIPS_TrackShow (hwnd, infoPtr);
    18151816
    18161817    return 0;
     
    18591860
    18601861    nResult = (INT) SendMessageA (GetParent (hwnd), WM_NOTIFYFORMAT,
    1861                                   (WPARAM)hwnd, (LPARAM)NF_QUERY);
     1862                                  (WPARAM)hwnd, (LPARAM)NF_QUERY);
    18621863//    if (nResult == NFR_ANSI)
    1863 //      TRACE (tooltips, " -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
     1864//      TRACE (tooltips, " -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
    18641865//    else if (nResult == NFR_UNICODE)
    1865 //      FIXME (tooltips, " -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
     1866//      FIXME (tooltips, " -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
    18661867//    else
    1867 //      FIXME (tooltips, " -- WM_NOTIFYFORMAT returns: error!\n");
     1868//      FIXME (tooltips, " -- WM_NOTIFYFORMAT returns: error!\n");
    18681869
    18691870    SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
     
    18821883    /* free tools */
    18831884    if (infoPtr->tools) {
    1884         for (i = 0; i < infoPtr->uNumTools; i++) {
    1885             toolPtr = &infoPtr->tools[i];
    1886             if ((toolPtr->hinst) && (toolPtr->lpszText)) {
    1887                 if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW)
    1888                     COMCTL32_Free (toolPtr->lpszText);
    1889             }
    1890 
    1891             /* remove subclassing */
    1892             if (toolPtr->uFlags & TTF_SUBCLASS) {
    1893                 LPTT_SUBCLASS_INFO lpttsi;
    1894 
    1895                 if (toolPtr->uFlags & TTF_IDISHWND)
    1896                     lpttsi = (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    1897                 else
    1898                     lpttsi = (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
    1899 
    1900                 if (lpttsi) {
    1901                     SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
    1902                                       (LONG)lpttsi->wpOrigProc);
    1903                     RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    1904                     COMCTL32_Free (&lpttsi);
    1905                 }
    1906             }
    1907         }
    1908         COMCTL32_Free (infoPtr->tools);
     1885        for (i = 0; i < infoPtr->uNumTools; i++) {
     1886            toolPtr = &infoPtr->tools[i];
     1887            if ((toolPtr->hinst) && (toolPtr->lpszText)) {
     1888                if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW)
     1889                    COMCTL32_Free (toolPtr->lpszText);
     1890            }
     1891
     1892            /* remove subclassing */
     1893            if (toolPtr->uFlags & TTF_SUBCLASS) {
     1894                LPTT_SUBCLASS_INFO lpttsi;
     1895
     1896                if (toolPtr->uFlags & TTF_IDISHWND)
     1897                    lpttsi = (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
     1898                else
     1899                    lpttsi = (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
     1900
     1901                if (lpttsi) {
     1902                    SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
     1903                                      (LONG)lpttsi->wpOrigProc);
     1904                    RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
     1905                    COMCTL32_Free (&lpttsi);
     1906                }
     1907            }
     1908        }
     1909        COMCTL32_Free (infoPtr->tools);
    19091910    }
    19101911
     
    19771978
    19781979    if ((nTool > -1) && (nTool < infoPtr->uNumTools)) {
    1979         if (infoPtr->tools[nTool].uFlags & TTF_TRANSPARENT) {
    1980 //          TRACE (tooltips, "-- in transparent mode!\n");
    1981             return HTTRANSPARENT;
    1982         }
     1980        if (infoPtr->tools[nTool].uFlags & TTF_TRANSPARENT) {
     1981//          TRACE (tooltips, "-- in transparent mode!\n");
     1982            return HTTRANSPARENT;
     1983        }
    19831984    }
    19841985
     
    19961997    TOOLTIPS_Refresh (hwnd, hdc);
    19971998    if (!wParam)
    1998         EndPaint (hwnd, &ps);
     1999        EndPaint (hwnd, &ps);
    19992000    return 0;
    20002001}
     
    20092010
    20102011    if ((LOWORD(lParam)) & (infoPtr->nCurrentTool != -1)) {
    2011 //      FIXME (tooltips, "full redraw needed!\n");
     2012//      FIXME (tooltips, "full redraw needed!\n");
    20122013    }
    20132014
     
    20722073    switch (wParam)
    20732074    {
    2074         case ID_TIMERSHOW:
    2075             KillTimer (hwnd, ID_TIMERSHOW);
    2076             if (TOOLTIPS_CheckTool (hwnd, TRUE) == infoPtr->nTool)
    2077                 TOOLTIPS_Show (hwnd, infoPtr);
    2078             break;
    2079 
    2080         case ID_TIMERPOP:
    2081             TOOLTIPS_Hide (hwnd, infoPtr);
    2082             break;
    2083 
    2084         case ID_TIMERLEAVE:
    2085             KillTimer (hwnd, ID_TIMERLEAVE);
    2086             if (TOOLTIPS_CheckTool (hwnd, FALSE) == -1) {
    2087                 infoPtr->nTool = -1;
    2088                 infoPtr->nOldTool = -1;
    2089                 TOOLTIPS_Hide (hwnd, infoPtr);
    2090             }
    2091             break;
     2075        case ID_TIMERSHOW:
     2076            KillTimer (hwnd, ID_TIMERSHOW);
     2077            if (TOOLTIPS_CheckTool (hwnd, TRUE) == infoPtr->nTool)
     2078                TOOLTIPS_Show (hwnd, infoPtr);
     2079            break;
     2080
     2081        case ID_TIMERPOP:
     2082            TOOLTIPS_Hide (hwnd, infoPtr);
     2083            break;
     2084
     2085        case ID_TIMERLEAVE:
     2086            KillTimer (hwnd, ID_TIMERLEAVE);
     2087            if (TOOLTIPS_CheckTool (hwnd, FALSE) == -1) {
     2088                infoPtr->nTool = -1;
     2089                infoPtr->nOldTool = -1;
     2090                TOOLTIPS_Hide (hwnd, infoPtr);
     2091            }
     2092            break;
    20922093    }
    20932094    return 0;
     
    21172118{
    21182119    LPTT_SUBCLASS_INFO lpttsi =
    2119         (LPTT_SUBCLASS_INFO)GetPropA (hwnd, COMCTL32_aSubclass);
     2120        (LPTT_SUBCLASS_INFO)GetPropA (hwnd, COMCTL32_aSubclass);
    21202121    TOOLTIPS_INFO *infoPtr;
    21212122    UINT nTool;
    21222123
    21232124    switch (uMsg) {
    2124         case WM_LBUTTONDOWN:
    2125         case WM_LBUTTONUP:
    2126         case WM_MBUTTONDOWN:
    2127         case WM_MBUTTONUP:
    2128         case WM_RBUTTONDOWN:
    2129         case WM_RBUTTONUP:
    2130             infoPtr = TOOLTIPS_GetInfoPtr(lpttsi->hwndToolTip);
    2131                 nTool = TOOLTIPS_GetToolFromMessage (infoPtr, hwnd);
    2132 
    2133 //              TRACE (tooltips, "subclassed mouse message %04x\n", uMsg);
    2134                 infoPtr->nOldTool = infoPtr->nTool;
    2135                 infoPtr->nTool = nTool;
    2136             TOOLTIPS_Hide (lpttsi->hwndToolTip, infoPtr);
    2137             break;
    2138 
    2139         case WM_MOUSEMOVE:
    2140             infoPtr = TOOLTIPS_GetInfoPtr (lpttsi->hwndToolTip);
    2141                 nTool = TOOLTIPS_GetToolFromMessage (infoPtr, hwnd);
    2142 
    2143 //              TRACE (tooltips, "subclassed WM_MOUSEMOVE\n");
    2144                 infoPtr->nOldTool = infoPtr->nTool;
    2145                 infoPtr->nTool = nTool;
    2146 
    2147                 if ((infoPtr->bActive) &&
    2148                     (infoPtr->nTool != infoPtr->nOldTool)) {
    2149                     if (infoPtr->nOldTool == -1) {
    2150                     SetTimer (hwnd, ID_TIMERSHOW,
    2151                                     infoPtr->nInitialTime, 0);
    2152 //                      TRACE (tooltips, "timer 1 started!\n");
    2153                     }
    2154                     else {
    2155                     TOOLTIPS_Hide (lpttsi->hwndToolTip, infoPtr);
    2156                     SetTimer (hwnd, ID_TIMERSHOW,
    2157                                 infoPtr->nReshowTime, 0);
    2158 //                      TRACE (tooltips, "timer 2 started!\n");
    2159                     }
    2160                 }
    2161                 if (infoPtr->nCurrentTool != -1) {
    2162                 SetTimer (hwnd, ID_TIMERLEAVE, 100, 0);
    2163 //                  TRACE (tooltips, "timer 3 started!\n");
    2164                 }
    2165             break;
     2125        case WM_LBUTTONDOWN:
     2126        case WM_LBUTTONUP:
     2127        case WM_MBUTTONDOWN:
     2128        case WM_MBUTTONUP:
     2129        case WM_RBUTTONDOWN:
     2130        case WM_RBUTTONUP:
     2131            infoPtr = TOOLTIPS_GetInfoPtr(lpttsi->hwndToolTip);
     2132                nTool = TOOLTIPS_GetToolFromMessage (infoPtr, hwnd);
     2133
     2134//              TRACE (tooltips, "subclassed mouse message %04x\n", uMsg);
     2135                infoPtr->nOldTool = infoPtr->nTool;
     2136                infoPtr->nTool = nTool;
     2137            TOOLTIPS_Hide (lpttsi->hwndToolTip, infoPtr);
     2138            break;
     2139
     2140        case WM_MOUSEMOVE:
     2141            infoPtr = TOOLTIPS_GetInfoPtr (lpttsi->hwndToolTip);
     2142                nTool = TOOLTIPS_GetToolFromMessage (infoPtr, hwnd);
     2143
     2144//              TRACE (tooltips, "subclassed WM_MOUSEMOVE\n");
     2145                infoPtr->nOldTool = infoPtr->nTool;
     2146                infoPtr->nTool = nTool;
     2147
     2148                if ((infoPtr->bActive) &&
     2149                    (infoPtr->nTool != infoPtr->nOldTool)) {
     2150                    if (infoPtr->nOldTool == -1) {
     2151                    SetTimer (hwnd, ID_TIMERSHOW,
     2152                                    infoPtr->nInitialTime, 0);
     2153//                      TRACE (tooltips, "timer 1 started!\n");
     2154                    }
     2155                    else {
     2156                    TOOLTIPS_Hide (lpttsi->hwndToolTip, infoPtr);
     2157                    SetTimer (hwnd, ID_TIMERSHOW,
     2158                                infoPtr->nReshowTime, 0);
     2159//                      TRACE (tooltips, "timer 2 started!\n");
     2160                    }
     2161                }
     2162                if (infoPtr->nCurrentTool != -1) {
     2163                SetTimer (hwnd, ID_TIMERLEAVE, 100, 0);
     2164//                  TRACE (tooltips, "timer 3 started!\n");
     2165                }
     2166            break;
    21662167    }
    21672168
     
    21752176    switch (uMsg)
    21762177    {
    2177         case TTM_ACTIVATE:
    2178             return TOOLTIPS_Activate (hwnd, wParam, lParam);
    2179 
    2180         case TTM_ADDTOOLA:
    2181             return TOOLTIPS_AddToolA (hwnd, wParam, lParam);
    2182 
    2183         case TTM_ADDTOOLW:
    2184             return TOOLTIPS_AddToolW (hwnd, wParam, lParam);
    2185 
    2186         case TTM_DELTOOLA:
    2187             return TOOLTIPS_DelToolA (hwnd, wParam, lParam);
    2188 
    2189         case TTM_DELTOOLW:
    2190             return TOOLTIPS_DelToolW (hwnd, wParam, lParam);
    2191 
    2192         case TTM_ENUMTOOLSA:
    2193             return TOOLTIPS_EnumToolsA (hwnd, wParam, lParam);
    2194 
    2195         case TTM_ENUMTOOLSW:
    2196             return TOOLTIPS_EnumToolsW (hwnd, wParam, lParam);
    2197 
    2198         case TTM_GETCURRENTTOOLA:
    2199             return TOOLTIPS_GetCurrentToolA (hwnd, wParam, lParam);
    2200 
    2201         case TTM_GETCURRENTTOOLW:
    2202             return TOOLTIPS_GetCurrentToolW (hwnd, wParam, lParam);
    2203 
    2204         case TTM_GETDELAYTIME:
    2205             return TOOLTIPS_GetDelayTime (hwnd, wParam, lParam);
    2206 
    2207         case TTM_GETMARGIN:
    2208             return TOOLTIPS_GetMargin (hwnd, wParam, lParam);
    2209 
    2210         case TTM_GETMAXTIPWIDTH:
    2211             return TOOLTIPS_GetMaxTipWidth (hwnd, wParam, lParam);
    2212 
    2213         case TTM_GETTEXTA:
    2214             return TOOLTIPS_GetTextA (hwnd, wParam, lParam);
    2215 
    2216         case TTM_GETTEXTW:
    2217             return TOOLTIPS_GetTextW (hwnd, wParam, lParam);
    2218 
    2219         case TTM_GETTIPBKCOLOR:
    2220             return TOOLTIPS_GetTipBkColor (hwnd, wParam, lParam);
    2221 
    2222         case TTM_GETTIPTEXTCOLOR:
    2223             return TOOLTIPS_GetTipTextColor (hwnd, wParam, lParam);
    2224 
    2225         case TTM_GETTOOLCOUNT:
    2226             return TOOLTIPS_GetToolCount (hwnd, wParam, lParam);
    2227 
    2228         case TTM_GETTOOLINFOA:
    2229             return TOOLTIPS_GetToolInfoA (hwnd, wParam, lParam);
    2230 
    2231         case TTM_GETTOOLINFOW:
    2232             return TOOLTIPS_GetToolInfoW (hwnd, wParam, lParam);
    2233 
    2234         case TTM_HITTESTA:
    2235             return TOOLTIPS_HitTestA (hwnd, wParam, lParam);
    2236 
    2237         case TTM_HITTESTW:
    2238             return TOOLTIPS_HitTestW (hwnd, wParam, lParam);
    2239 
    2240         case TTM_NEWTOOLRECTA:
    2241             return TOOLTIPS_NewToolRectA (hwnd, wParam, lParam);
    2242 
    2243         case TTM_NEWTOOLRECTW:
    2244             return TOOLTIPS_NewToolRectW (hwnd, wParam, lParam);
    2245 
    2246         case TTM_POP:
    2247             return TOOLTIPS_Pop (hwnd, wParam, lParam);
    2248 
    2249         case TTM_RELAYEVENT:
    2250             return TOOLTIPS_RelayEvent (hwnd, wParam, lParam);
    2251 
    2252         case TTM_SETDELAYTIME:
    2253             return TOOLTIPS_SetDelayTime (hwnd, wParam, lParam);
    2254 
    2255         case TTM_SETMARGIN:
    2256             return TOOLTIPS_SetMargin (hwnd, wParam, lParam);
    2257 
    2258         case TTM_SETMAXTIPWIDTH:
    2259             return TOOLTIPS_SetMaxTipWidth (hwnd, wParam, lParam);
    2260 
    2261         case TTM_SETTIPBKCOLOR:
    2262             return TOOLTIPS_SetTipBkColor (hwnd, wParam, lParam);
    2263 
    2264         case TTM_SETTIPTEXTCOLOR:
    2265             return TOOLTIPS_SetTipTextColor (hwnd, wParam, lParam);
    2266 
    2267         case TTM_SETTOOLINFOA:
    2268             return TOOLTIPS_SetToolInfoA (hwnd, wParam, lParam);
    2269 
    2270         case TTM_SETTOOLINFOW:
    2271             return TOOLTIPS_SetToolInfoW (hwnd, wParam, lParam);
    2272 
    2273         case TTM_TRACKACTIVATE:
    2274             return TOOLTIPS_TrackActivate (hwnd, wParam, lParam);
    2275 
    2276         case TTM_TRACKPOSITION:
    2277             return TOOLTIPS_TrackPosition (hwnd, wParam, lParam);
    2278 
    2279         case TTM_UPDATE:
    2280             return TOOLTIPS_Update (hwnd, wParam, lParam);
    2281 
    2282         case TTM_UPDATETIPTEXTA:
    2283             return TOOLTIPS_UpdateTipTextA (hwnd, wParam, lParam);
    2284 
    2285         case TTM_UPDATETIPTEXTW:
    2286             return TOOLTIPS_UpdateTipTextW (hwnd, wParam, lParam);
    2287 
    2288         case TTM_WINDOWFROMPOINT:
    2289             return TOOLTIPS_WindowFromPoint (hwnd, wParam, lParam);
    2290 
    2291 
    2292         case WM_CREATE:
    2293             return TOOLTIPS_Create (hwnd, wParam, lParam);
    2294 
    2295         case WM_DESTROY:
    2296             return TOOLTIPS_Destroy (hwnd, wParam, lParam);
    2297 
    2298         case WM_ERASEBKGND:
    2299             return TOOLTIPS_EraseBackground (hwnd, wParam, lParam);
    2300 
    2301         case WM_GETFONT:
    2302             return TOOLTIPS_GetFont (hwnd, wParam, lParam);
     2178        case TTM_ACTIVATE:
     2179            return TOOLTIPS_Activate (hwnd, wParam, lParam);
     2180
     2181        case TTM_ADDTOOLA:
     2182            return TOOLTIPS_AddToolA (hwnd, wParam, lParam);
     2183
     2184        case TTM_ADDTOOLW:
     2185            return TOOLTIPS_AddToolW (hwnd, wParam, lParam);
     2186
     2187        case TTM_DELTOOLA:
     2188            return TOOLTIPS_DelToolA (hwnd, wParam, lParam);
     2189
     2190        case TTM_DELTOOLW:
     2191            return TOOLTIPS_DelToolW (hwnd, wParam, lParam);
     2192
     2193        case TTM_ENUMTOOLSA:
     2194            return TOOLTIPS_EnumToolsA (hwnd, wParam, lParam);
     2195
     2196        case TTM_ENUMTOOLSW:
     2197            return TOOLTIPS_EnumToolsW (hwnd, wParam, lParam);
     2198
     2199        case TTM_GETCURRENTTOOLA:
     2200            return TOOLTIPS_GetCurrentToolA (hwnd, wParam, lParam);
     2201
     2202        case TTM_GETCURRENTTOOLW:
     2203            return TOOLTIPS_GetCurrentToolW (hwnd, wParam, lParam);
     2204
     2205        case TTM_GETDELAYTIME:
     2206            return TOOLTIPS_GetDelayTime (hwnd, wParam, lParam);
     2207
     2208        case TTM_GETMARGIN:
     2209            return TOOLTIPS_GetMargin (hwnd, wParam, lParam);
     2210
     2211        case TTM_GETMAXTIPWIDTH:
     2212            return TOOLTIPS_GetMaxTipWidth (hwnd, wParam, lParam);
     2213
     2214        case TTM_GETTEXTA:
     2215            return TOOLTIPS_GetTextA (hwnd, wParam, lParam);
     2216
     2217        case TTM_GETTEXTW:
     2218            return TOOLTIPS_GetTextW (hwnd, wParam, lParam);
     2219
     2220        case TTM_GETTIPBKCOLOR:
     2221            return TOOLTIPS_GetTipBkColor (hwnd, wParam, lParam);
     2222
     2223        case TTM_GETTIPTEXTCOLOR:
     2224            return TOOLTIPS_GetTipTextColor (hwnd, wParam, lParam);
     2225
     2226        case TTM_GETTOOLCOUNT:
     2227            return TOOLTIPS_GetToolCount (hwnd, wParam, lParam);
     2228
     2229        case TTM_GETTOOLINFOA:
     2230            return TOOLTIPS_GetToolInfoA (hwnd, wParam, lParam);
     2231
     2232        case TTM_GETTOOLINFOW:
     2233            return TOOLTIPS_GetToolInfoW (hwnd, wParam, lParam);
     2234
     2235        case TTM_HITTESTA:
     2236            return TOOLTIPS_HitTestA (hwnd, wParam, lParam);
     2237
     2238        case TTM_HITTESTW:
     2239            return TOOLTIPS_HitTestW (hwnd, wParam, lParam);
     2240
     2241        case TTM_NEWTOOLRECTA:
     2242            return TOOLTIPS_NewToolRectA (hwnd, wParam, lParam);
     2243
     2244        case TTM_NEWTOOLRECTW:
     2245            return TOOLTIPS_NewToolRectW (hwnd, wParam, lParam);
     2246
     2247        case TTM_POP:
     2248            return TOOLTIPS_Pop (hwnd, wParam, lParam);
     2249
     2250        case TTM_RELAYEVENT:
     2251            return TOOLTIPS_RelayEvent (hwnd, wParam, lParam);
     2252
     2253        case TTM_SETDELAYTIME:
     2254            return TOOLTIPS_SetDelayTime (hwnd, wParam, lParam);
     2255
     2256        case TTM_SETMARGIN:
     2257            return TOOLTIPS_SetMargin (hwnd, wParam, lParam);
     2258
     2259        case TTM_SETMAXTIPWIDTH:
     2260            return TOOLTIPS_SetMaxTipWidth (hwnd, wParam, lParam);
     2261
     2262        case TTM_SETTIPBKCOLOR:
     2263            return TOOLTIPS_SetTipBkColor (hwnd, wParam, lParam);
     2264
     2265        case TTM_SETTIPTEXTCOLOR:
     2266            return TOOLTIPS_SetTipTextColor (hwnd, wParam, lParam);
     2267
     2268        case TTM_SETTOOLINFOA:
     2269            return TOOLTIPS_SetToolInfoA (hwnd, wParam, lParam);
     2270
     2271        case TTM_SETTOOLINFOW:
     2272            return TOOLTIPS_SetToolInfoW (hwnd, wParam, lParam);
     2273
     2274        case TTM_TRACKACTIVATE:
     2275            return TOOLTIPS_TrackActivate (hwnd, wParam, lParam);
     2276
     2277        case TTM_TRACKPOSITION:
     2278            return TOOLTIPS_TrackPosition (hwnd, wParam, lParam);
     2279
     2280        case TTM_UPDATE:
     2281            return TOOLTIPS_Update (hwnd, wParam, lParam);
     2282
     2283        case TTM_UPDATETIPTEXTA:
     2284            return TOOLTIPS_UpdateTipTextA (hwnd, wParam, lParam);
     2285
     2286        case TTM_UPDATETIPTEXTW:
     2287            return TOOLTIPS_UpdateTipTextW (hwnd, wParam, lParam);
     2288
     2289        case TTM_WINDOWFROMPOINT:
     2290            return TOOLTIPS_WindowFromPoint (hwnd, wParam, lParam);
     2291
     2292
     2293        case WM_CREATE:
     2294            return TOOLTIPS_Create (hwnd, wParam, lParam);
     2295
     2296        case WM_DESTROY:
     2297            return TOOLTIPS_Destroy (hwnd, wParam, lParam);
     2298
     2299        case WM_ERASEBKGND:
     2300            return TOOLTIPS_EraseBackground (hwnd, wParam, lParam);
     2301
     2302        case WM_GETFONT:
     2303            return TOOLTIPS_GetFont (hwnd, wParam, lParam);
    23032304
    23042305        case WM_GETTEXT:
    23052306            return TOOLTIPS_OnWMGetText (hwnd, wParam, lParam);
    2306        
     2307
    23072308        case WM_GETTEXTLENGTH:
    23082309            return TOOLTIPS_OnWMGetTextLength (hwnd, wParam, lParam);
    2309  
    2310 
    2311         case WM_LBUTTONDOWN:
    2312         case WM_LBUTTONUP:
    2313         case WM_MBUTTONDOWN:
    2314         case WM_MBUTTONUP:
    2315         case WM_RBUTTONDOWN:
    2316         case WM_RBUTTONUP:
    2317         case WM_MOUSEMOVE:
    2318             return TOOLTIPS_MouseMessage (hwnd, uMsg, wParam, lParam);
    2319 
    2320         case WM_NCCREATE:
    2321             return TOOLTIPS_NCCreate (hwnd, wParam, lParam);
    2322 
    2323         case WM_NCHITTEST:
    2324             return TOOLTIPS_NCHitTest (hwnd, wParam, lParam);
    2325 
    2326 /*      case WM_NOTIFYFORMAT: */
    2327 /*          return TOOLTIPS_NotifyFormat (hwnd, wParam, lParam); */
    2328 
    2329         case WM_PAINT:
    2330             return TOOLTIPS_Paint (hwnd, wParam, lParam);
    2331 
    2332         case WM_SETFONT:
    2333             return TOOLTIPS_SetFont (hwnd, wParam, lParam);
    2334 
    2335         case WM_TIMER:
    2336             return TOOLTIPS_Timer (hwnd, wParam, lParam);
    2337 
    2338         case WM_WININICHANGE:
    2339             return TOOLTIPS_WinIniChange (hwnd, wParam, lParam);
    2340 
    2341         default:
    2342             if (uMsg >= WM_USER)
    2343 //              ERR (tooltips, "unknown msg %04x wp=%08x lp=%08lx\n",
    2344 //                   uMsg, wParam, lParam);
    2345             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     2310
     2311
     2312        case WM_LBUTTONDOWN:
     2313        case WM_LBUTTONUP:
     2314        case WM_MBUTTONDOWN:
     2315        case WM_MBUTTONUP:
     2316        case WM_RBUTTONDOWN:
     2317        case WM_RBUTTONUP:
     2318        case WM_MOUSEMOVE:
     2319            return TOOLTIPS_MouseMessage (hwnd, uMsg, wParam, lParam);
     2320
     2321        case WM_NCCREATE:
     2322            return TOOLTIPS_NCCreate (hwnd, wParam, lParam);
     2323
     2324        case WM_NCHITTEST:
     2325            return TOOLTIPS_NCHitTest (hwnd, wParam, lParam);
     2326
     2327/*      case WM_NOTIFYFORMAT: */
     2328/*          return TOOLTIPS_NotifyFormat (hwnd, wParam, lParam); */
     2329
     2330        case WM_PAINT:
     2331            return TOOLTIPS_Paint (hwnd, wParam, lParam);
     2332
     2333        case WM_SETFONT:
     2334            return TOOLTIPS_SetFont (hwnd, wParam, lParam);
     2335
     2336        case WM_TIMER:
     2337            return TOOLTIPS_Timer (hwnd, wParam, lParam);
     2338
     2339        case WM_WININICHANGE:
     2340            return TOOLTIPS_WinIniChange (hwnd, wParam, lParam);
     2341
     2342        default:
     2343//            if (uMsg >= WM_USER)
     2344//              ERR (tooltips, "unknown msg %04x wp=%08x lp=%08lx\n",
     2345//                   uMsg, wParam, lParam);
     2346            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    23462347    }
    23472348    return 0;
     
    23642365    wndClass.hbrBackground = 0;
    23652366    wndClass.lpszClassName = TOOLTIPS_CLASSA;
    2366  
     2367
    23672368    RegisterClassA (&wndClass);
    23682369}
     
    23732374{
    23742375    if (GlobalFindAtomA (TOOLTIPS_CLASSA))
    2375         UnregisterClassA (TOOLTIPS_CLASSA, (HINSTANCE)NULL);
    2376 }
    2377 
     2376        UnregisterClassA (TOOLTIPS_CLASSA, (HINSTANCE)NULL);
     2377}
     2378
  • trunk/src/comctl32/trackbar.c

    r109 r110  
    1 /* $Id: trackbar.c,v 1.4 1999-06-16 15:29:27 cbratschi Exp $ */
     1/* $Id: trackbar.c,v 1.5 1999-06-16 20:25:44 cbratschi Exp $ */
    22/*
    33 * Trackbar control
     
    1515 *   - better tic handling.
    1616 *   - more notifications.
     17 *   - implement TRACKBAR_Draw with inUpdate
    1718 *
    1819 */
     
    345346}
    346347
    347 
    348 static VOID
    349 TRACKBAR_Refresh (HWND hwnd, HDC hdc)
     348//draw the trackbar
     349
     350static VOID TRACKBAR_Draw(HWND hwnd,HDC hdc,INT lastPos,BOOL inUpdate)
    350351{
    351352    TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
     
    356357
    357358    GetClientRect (hwnd, &rcClient);
    358     hBrush = CreateSolidBrush (infoPtr->clrBk);
    359     FillRect (hdc, &rcClient, hBrush);
    360     DeleteObject (hBrush);
     359    if (!inUpdate)
     360    {
     361      hBrush = CreateSolidBrush (infoPtr->clrBk);
     362      FillRect (hdc, &rcClient, hBrush);
     363      DeleteObject (hBrush);
     364    }
    361365
    362366    if (infoPtr->flags & TB_DRAGPOSVALID)  {
     
    478482}
    479483
     484//update display
     485
     486static VOID TRACKBAR_Update(HWND hwnd,INT lastPos)
     487{
     488   TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
     489   HDC hdc;
     490
     491   if (infoPtr->flags & TB_DRAGPOSVALID && lastPos == infoPtr->dragPos) return;
     492   if (!infoPtr->flags & TB_DRAGPOSVALID && lastPos == infoPtr->nPos) return;
     493   hdc = GetDC(hwnd);
     494   TRACKBAR_Draw(hwnd,hdc,lastPos,TRUE);
     495   ReleaseDC(hwnd,hdc);
     496}
     497
     498//redraw everything
     499
     500static VOID TRACKBAR_Refresh (HWND hwnd)
     501{
     502   HDC hdc;
     503
     504   hdc = GetDC (hwnd);
     505   TRACKBAR_Draw(hwnd,hdc,0,FALSE);
     506   ReleaseDC(hwnd,hdc);
     507}
    480508
    481509static VOID
     
    541569    infoPtr->flags |= TB_SELECTIONCHANGED;
    542570
    543     if ((BOOL)wParam)
    544         InvalidateRect (hwnd, NULL, FALSE);
     571    if ((BOOL)wParam) TRACKBAR_Refresh(hwnd);
    545572
    546573    return 0;
     
    559586    }
    560587
    561     if (wParam)
    562         InvalidateRect (hwnd, NULL, FALSE);
     588    if (wParam) TRACKBAR_Refresh(hwnd);
    563589
    564590    return 0;
     
    811837    TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
    812838
     839    INT lastPos = infoPtr->nPos;
    813840    infoPtr->nPos = (INT)LOWORD(lParam);
    814841
     
    820847    infoPtr->flags |= TB_THUMBPOSCHANGED;
    821848
    822     if (wParam)
    823         InvalidateRect (hwnd, NULL, FALSE);
     849    if (wParam) TRACKBAR_Update(hwnd,lastPos);
    824850
    825851    return 0;
     
    849875    TRACKBAR_RecalculateTics (infoPtr);
    850876
    851     if (wParam)
    852         InvalidateRect (hwnd, NULL, FALSE);
     877    if (wParam) TRACKBAR_Refresh(hwnd);
    853878
    854879    return 0;
     
    872897    TRACKBAR_RecalculateTics (infoPtr);
    873898
    874     if (wParam)
    875         InvalidateRect (hwnd, NULL, FALSE);
     899    if (wParam) TRACKBAR_Refresh(hwnd);
    876900
    877901    return 0;
     
    895919    TRACKBAR_RecalculateTics (infoPtr);
    896920
    897     if (wParam)
    898         InvalidateRect (hwnd, NULL, FALSE);
     921    if (wParam) TRACKBAR_Refresh(hwnd);
    899922
    900923    return 0;
     
    912935    TRACKBAR_RecalculateTics (infoPtr);
    913936
    914     InvalidateRect (hwnd, NULL, FALSE);
     937    TRACKBAR_Refresh(hwnd); //CB: necessary?
    915938
    916939    return 0;
     
    935958        infoPtr->nSelMax = infoPtr->nRangeMax;
    936959
    937     if (wParam)
    938         InvalidateRect (hwnd, NULL, FALSE);
     960    if (wParam) TRACKBAR_Refresh(hwnd);
    939961
    940962
     
    957979        infoPtr->nSelMax = infoPtr->nRangeMax;
    958980
    959     if (wParam)
    960         InvalidateRect (hwnd, NULL, FALSE);
     981    if (wParam) TRACKBAR_Refresh(hwnd);
    961982
    962983    return 0;
     
    978999        infoPtr->nSelMin = infoPtr->nRangeMin;
    9791000
    980     if (wParam)
    981         InvalidateRect (hwnd, NULL, FALSE);
     1001    if (wParam) TRACKBAR_Refresh(hwnd);
    9821002
    9831003    return 0;
     
    9951015    infoPtr->flags |= TB_THUMBSIZECHANGED;
    9961016
    997     InvalidateRect (hwnd, NULL, FALSE);
     1017    TRACKBAR_Refresh(hwnd);
    9981018
    9991019    return 0;
     
    10151035    infoPtr->tics[infoPtr->uNumTics-1]=nPos;
    10161036
    1017     InvalidateRect (hwnd, NULL, FALSE);
     1037    TRACKBAR_Refresh(hwnd);
    10181038
    10191039    return TRUE;
     
    11491169    infoPtr->flags &= ~TB_DRAG_MODE;
    11501170
    1151     InvalidateRect (hwnd, NULL, FALSE);
     1171    TRACKBAR_Refresh(hwnd); //CB: make changes here
    11521172
    11531173    return 0;
     
    12151235    if (prevPos!=infoPtr->nPos) {
    12161236        infoPtr->flags |= TB_THUMBPOSCHANGED;
    1217         InvalidateRect (hwnd, NULL, FALSE);
     1237        TRACKBAR_Update(hwnd,prevPos);
    12181238    }
    12191239
     
    12471267    }
    12481268
    1249     InvalidateRect (hwnd, NULL, FALSE);
     1269    //TRACKBAR_Refresh(hwnd); //CB: nothing changed
    12501270
    12511271    return 0;
     
    12591279
    12601280    if (infoPtr->flags & TB_DRAGPOSVALID) {
     1281        int lastPos = infoPtr->nPos;
    12611282        infoPtr->nPos=infoPtr->dragPos;
    1262         InvalidateRect (hwnd, NULL, FALSE);
     1283        TRACKBAR_Update(hwnd,lastPos);
    12631284    }
    12641285
     
    12771298
    12781299    hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
    1279     TRACKBAR_Refresh (hwnd, hdc);
     1300    TRACKBAR_Draw(hwnd,hdc,0,FALSE);
    12801301    if(!wParam)
    12811302        EndPaint (hwnd, &ps);
     
    12921313    infoPtr->bFocus = TRUE;
    12931314
    1294     InvalidateRect (hwnd, NULL, FALSE);
     1315    TRACKBAR_Refresh(hwnd); //CB: make changes here
    12951316
    12961317    return 0;
     
    13321353    DOUBLE dragPos;
    13331354    char buf[80];
     1355    INT lastDragPos;
    13341356
    13351357//    TRACE (trackbar, "%x\n",wParam);
     
    13441366
    13451367    SetCapture (hwnd);
     1368    lastDragPos = infoPtr->dragPos;
    13461369    dragPos = TRACKBAR_ConvertPlaceToPosition (infoPtr, clickPlace,
    13471370                                               dwStyle & TBS_VERT);
     
    13771400    }
    13781401
    1379     InvalidateRect (hwnd, NULL, FALSE);
     1402    TRACKBAR_Update(hwnd,lastDragPos);
    13801403    UpdateWindow (hwnd);
    13811404
     
    14381461    if (pos!=infoPtr->nPos) {
    14391462        infoPtr->flags |=TB_THUMBPOSCHANGED;
    1440         InvalidateRect (hwnd, NULL, FALSE);
     1463        TRACKBAR_Update(hwnd,pos);
    14411464    }
    14421465
  • trunk/src/comctl32/treeview.c

    r94 r110  
    1 /* $Id: treeview.c,v 1.3 1999-06-10 16:22:03 achimha Exp $ */
     1/* $Id: treeview.c,v 1.4 1999-06-16 20:25:44 cbratschi Exp $ */
    22/* Treeview control
    33 *
     
    66 * Copyright 1999 Sylvain St-Germain
    77 * Copyright 1999 Achim Hasenmueller
     8 * Copyright 1999 Christoph Bratschi
    89 *
    910 *
    1011 * TODO:
    1112 *   Using DPA to store the item ptr would be good.
    12  *   Node label edition is implemented but something appened in wine in the 
     13 *   Node label edition is implemented but something appened in wine in the
    1314 *   two last weeks of march 99 that broke it.
    14  *   refreshtreeview:   
    15                 -small array containing info about positions.
    16                 -better implementation of RefreshItem:
     15 *   refreshtreeview:
     16                -small array containing info about positions.
     17                -better implementation of RefreshItem:
    1718              1) draw lines between parents
    1819              2) draw items
    19                           3) draw lines from parent<->items.
    20                 -implement partial drawing?
     20                          3) draw lines from parent<->items.
     21                -implement partial drawing?
    2122 *  -drag&drop: TVM_CREATEDRAGIMAGE should create drag bitmap.
    2223 *  -scrollbars: horizontal scrollbar doesn't work.
     
    2627 *   FIXME: check fontsize. (uRealItemHeight)
    2728 *          test focusItem  (redraw in different color)
    28                         uHotItem
    29                         Edit: needs timer
    30                                   better implementation.
     29                        uHotItem
     30                        Edit: needs timer
     31                                  better implementation.
    3132 *   WM_HSCROLL is broken.
    3233 *   use separate routine to get item text/image.
    33  * 
     34 *
    3435 *   Separate drawing/calculation.
    3536 *
    3637 * FIXMEs  (for personal use)
    37     Expand:             -ctlmacro expands twice ->toggle.
    38    -DblClick:   ctlmacro.exe's NM_DBLCLK seems to go wrong (returns FALSE).
    39    -treehelper: stack corruption makes big window. 
    40              
     38    Expand:             -ctlmacro expands twice ->toggle.
     39   -DblClick:   ctlmacro.exe's NM_DBLCLK seems to go wrong (returns FALSE).
     40   -treehelper: stack corruption makes big window.
     41
    4142 */
    4243
     
    5455 * has no side effects in this file.
    5556 */
    56 #define tv_test_bit(nr,bf)      (((LPBYTE)bf)[nr>>3]&(1<<(nr&7)))
    57 #define tv_set_bit(nr,bf)       ((LPBYTE)bf)[nr>>3]|=(1<<(nr&7))
    58 #define tv_clear_bit(nr,bf)     ((LPBYTE)bf)[nr>>3]&=~(1<<(nr&7))
     57#define tv_test_bit(nr,bf)      (((LPBYTE)bf)[nr>>3]&(1<<(nr&7)))
     58#define tv_set_bit(nr,bf)       ((LPBYTE)bf)[nr>>3]|=(1<<(nr&7))
     59#define tv_clear_bit(nr,bf)     ((LPBYTE)bf)[nr>>3]&=~(1<<(nr&7))
    5960
    6061
     
    6566TREEVIEW_SendSimpleNotify (HWND hwnd, UINT code);
    6667static BOOL
    67 TREEVIEW_SendTreeviewNotify (HWND hwnd, UINT code, UINT action, 
    68                         HTREEITEM oldItem, HTREEITEM newItem);
     68TREEVIEW_SendTreeviewNotify (HWND hwnd, UINT code, UINT action,
     69                        HTREEITEM oldItem, HTREEITEM newItem);
    6970static BOOL
    70 TREEVIEW_SendTreeviewDnDNotify (HWND hwnd, UINT code, HTREEITEM dragItem, 
    71                         POINT pt);
     71TREEVIEW_SendTreeviewDnDNotify (HWND hwnd, UINT code, HTREEITEM dragItem,
     72                        POINT pt);
    7273static BOOL
    73 TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem, 
    74                         UINT code, UINT what);
     74TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem,
     75                        UINT code, UINT what);
    7576static BOOL
    7677TREEVIEW_SendCustomDrawNotify (HWND hwnd, DWORD dwDrawStage, HDC hdc,
    77                         RECT rc);
     78                        RECT rc);
    7879static BOOL
    7980TREEVIEW_SendCustomDrawItemNotify (HWND hwnd, HDC hdc,
     
    8586
    8687static LRESULT CALLBACK
    87 TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, 
    88                                                         LPARAM lParam);
     88TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam,
     89                                                        LPARAM lParam);
    8990
    9091LRESULT WINAPI
     
    9495
    9596
    96 /* helper functions. Work with the assumption that validity of operands 
     97/* helper functions. Work with the assumption that validity of operands
    9798   is checked beforehand, and that tree state is valid.  */
    9899
    99 /* FIXME: MS documentation says `GetNextVisibleItem' returns NULL 
     100/* FIXME: MS documentation says `GetNextVisibleItem' returns NULL
    100101   if not succesfull'. Probably only applies to derefencing infoPtr
    101102   (ie we are offered a valid treeview structure)
    102    and not whether there is a next `visible' child. 
     103   and not whether there is a next `visible' child.
    103104   FIXME: check other failures.
    104105 */
     
    111112  HTREEITEM  handle)
    112113{
    113   if ((!handle) || (handle>infoPtr->uMaxHandle)) 
     114  if ((!handle) || (handle>infoPtr->uMaxHandle))
    114115    return NULL;
    115116
    116   if (tv_test_bit ((INT)handle, infoPtr->freeList)) 
     117  if (tv_test_bit ((INT)handle, infoPtr->freeList))
    117118    return NULL;
    118119
     
    130131  TREEVIEW_ITEM *wineItem = tvItem;
    131132
    132   /* 
    133    * Get this item last sibling 
     133  /*
     134   * Get this item last sibling
    134135   */
    135   while (wineItem->sibling) 
    136           wineItem=& infoPtr->items [(INT)wineItem->sibling];
    137 
    138   /* 
     136  while (wineItem->sibling)
     137          wineItem=& infoPtr->items [(INT)wineItem->sibling];
     138
     139  /*
    139140   * If the last sibling has expanded children, restart.
    140141   */
    141142  if ( ( wineItem->cChildren > 0 ) && ( wineItem->state & TVIS_EXPANDED) )
    142143    return TREEVIEW_GetLastListItem(
    143              infoPtr, 
     144             infoPtr,
    144145             &(infoPtr->items[(INT)wineItem->firstChild]));
    145146
     
    148149
    149150/***************************************************************************
    150  * This method returns the previous physical item in the list not 
     151 * This method returns the previous physical item in the list not
    151152 * considering the tree hierarchy.
    152153 */
    153154static TREEVIEW_ITEM *TREEVIEW_GetPrevListItem(
    154   TREEVIEW_INFO *infoPtr, 
     155  TREEVIEW_INFO *infoPtr,
    155156  TREEVIEW_ITEM *tvItem)
    156157{
    157   if (tvItem->upsibling) 
     158  if (tvItem->upsibling)
    158159  {
    159     /* 
     160    /*
    160161     * This item has a upsibling, get the last item.  Since, GetLastListItem
    161162     * first looks at siblings, we must feed it with the first child.
    162163     */
    163164    TREEVIEW_ITEM *upItem = &infoPtr->items[(INT)tvItem->upsibling];
    164    
     165
    165166    if ( ( upItem->cChildren > 0 ) && ( upItem->state & TVIS_EXPANDED) )
    166       return TREEVIEW_GetLastListItem( 
    167                infoPtr, 
     167      return TREEVIEW_GetLastListItem(
     168               infoPtr,
    168169               &infoPtr->items[(INT)upItem->firstChild]);
    169170    else
     
    175176     * this item does not have a upsibling, get the parent
    176177     */
    177     if (tvItem->parent) 
     178    if (tvItem->parent)
    178179      return &infoPtr->items[(INT)tvItem->parent];
    179180  }
     
    184185
    185186/***************************************************************************
    186  * This method returns the next physical item in the treeview not 
     187 * This method returns the next physical item in the treeview not
    187188 * considering the tree hierarchy.
    188189 */
    189190static TREEVIEW_ITEM *TREEVIEW_GetNextListItem(
    190   TREEVIEW_INFO *infoPtr, 
     191  TREEVIEW_INFO *infoPtr,
    191192  TREEVIEW_ITEM *tvItem)
    192193{
    193194  TREEVIEW_ITEM *wineItem = NULL;
    194195
    195   /* 
     196  /*
    196197   * If this item has children and is expanded, return the first child
    197198   */
    198   if ((tvItem->firstChild) && (tvItem->state & TVIS_EXPANDED)) 
    199                 return (& infoPtr->items[(INT)tvItem->firstChild]);
     199  if ((tvItem->firstChild) && (tvItem->state & TVIS_EXPANDED))
     200                return (& infoPtr->items[(INT)tvItem->firstChild]);
    200201
    201202
     
    203204   * try to get the sibling
    204205   */
    205   if (tvItem->sibling) 
    206                 return (& infoPtr->items[(INT)tvItem->sibling]);
     206  if (tvItem->sibling)
     207                return (& infoPtr->items[(INT)tvItem->sibling]);
    207208
    208209  /*
     
    212213  while (wineItem->parent) {
    213214    wineItem=& infoPtr->items [(INT)wineItem->parent];
    214         if (wineItem->sibling)
     215        if (wineItem->sibling)
    215216      return (& infoPtr->items [(INT)wineItem->sibling]);
    216   } 
    217 
    218   return NULL; 
     217  }
     218
     219  return NULL;
    219220}
    220221
    221222/***************************************************************************
    222  * This method returns the nth item starting at the given item.  It returns 
     223 * This method returns the nth item starting at the given item.  It returns
    223224 * the last item (or first) we we run out of items.
    224225 *
     
    227228 */
    228229static TREEVIEW_ITEM *TREEVIEW_GetListItem(
    229   TREEVIEW_INFO *infoPtr, 
     230  TREEVIEW_INFO *infoPtr,
    230231  TREEVIEW_ITEM *tvItem,
    231232  LONG          count)
     
    241242    {
    242243      /* Keep a pointer to the previous in case we ask for more than we got */
    243       previousItem = wineItem; 
     244      previousItem = wineItem;
    244245      wineItem     = TREEVIEW_GetNextListItem(infoPtr, wineItem);
    245     } 
     246    }
    246247
    247248    if (wineItem == NULL)
     
    254255    {
    255256      /* Keep a pointer to the previous in case we ask for more than we got */
    256       previousItem = wineItem; 
     257      previousItem = wineItem;
    257258      wineItem = TREEVIEW_GetPrevListItem(infoPtr, wineItem);
    258259    }
     
    267268}
    268269
    269  
     270
    270271/***************************************************************************
    271  * This method 
     272 * This method
    272273 */
    273274static void TREEVIEW_RemoveAllChildren(
     
    277278 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    278279 TREEVIEW_ITEM *killItem;
    279  INT    kill;
    280  
     280 INT    kill;
     281
    281282 kill=(INT)parentItem->firstChild;
    282283 while (kill) {
    283         tv_set_bit ( kill, infoPtr->freeList);
    284         killItem=& infoPtr->items[kill];
    285         if (killItem->pszText!=LPSTR_TEXTCALLBACKA)
    286                 COMCTL32_Free (killItem->pszText);
    287         TREEVIEW_SendTreeviewNotify (hwnd, TVN_DELETEITEM, 0, (HTREEITEM)kill, 0);
    288         if (killItem->firstChild)
    289                         TREEVIEW_RemoveAllChildren (hwnd, killItem);
    290         kill=(INT)killItem->sibling;
     284        tv_set_bit ( kill, infoPtr->freeList);
     285        killItem=& infoPtr->items[kill];
     286        if (killItem->pszText!=LPSTR_TEXTCALLBACKA)
     287                COMCTL32_Free (killItem->pszText);
     288        TREEVIEW_SendTreeviewNotify (hwnd, TVN_DELETEITEM, 0, (HTREEITEM)kill, 0);
     289        if (killItem->firstChild)
     290                        TREEVIEW_RemoveAllChildren (hwnd, killItem);
     291        kill=(INT)killItem->sibling;
    291292 }
    292293
    293294 if (parentItem->cChildren>0) {
    294         infoPtr->uNumItems -= parentItem->cChildren;
    295         parentItem->firstChild = 0;
    296         parentItem->cChildren  = 0;
     295        infoPtr->uNumItems -= parentItem->cChildren;
     296        parentItem->firstChild = 0;
     297        parentItem->cChildren  = 0;
    297298 }
    298299
     
    312313 infoPtr->uNumItems--;
    313314 parentItem=NULL;
    314  if (wineItem->pszText!=LPSTR_TEXTCALLBACKA) 
    315         COMCTL32_Free (wineItem->pszText);
     315 if (wineItem->pszText!=LPSTR_TEXTCALLBACKA)
     316        COMCTL32_Free (wineItem->pszText);
    316317
    317318 TREEVIEW_SendTreeviewNotify (hwnd, TVN_DELETEITEM, 0, (HTREEITEM)iItem, 0);
    318319
    319  if (wineItem->firstChild) 
    320         TREEVIEW_RemoveAllChildren (hwnd,wineItem);
     320 if (wineItem->firstChild)
     321        TREEVIEW_RemoveAllChildren (hwnd,wineItem);
    321322
    322323 if (wineItem->parent) {
    323         parentItem=& infoPtr->items [(INT)wineItem->parent];
    324         switch (parentItem->cChildren) {
    325                 case I_CHILDRENCALLBACK:
    326 //                              FIXME (treeview,"we don't handle I_CHILDRENCALLBACK yet\n");
    327                                 break;
    328                 case 1:
    329                         parentItem->cChildren=0;
    330                         parentItem->firstChild=0;   
    331                         return;
    332                 default:
    333                         parentItem->cChildren--;
    334                         if ((INT)parentItem->firstChild==iItem)
    335                                 parentItem->firstChild=wineItem->sibling;
    336                 }
     324        parentItem=& infoPtr->items [(INT)wineItem->parent];
     325        switch (parentItem->cChildren) {
     326                case I_CHILDRENCALLBACK:
     327//                              FIXME (treeview,"we don't handle I_CHILDRENCALLBACK yet\n");
     328                                break;
     329                case 1:
     330                        parentItem->cChildren=0;
     331                        parentItem->firstChild=0;
     332                        return;
     333                default:
     334                        parentItem->cChildren--;
     335                        if ((INT)parentItem->firstChild==iItem)
     336                                parentItem->firstChild=wineItem->sibling;
     337                }
    337338 }
    338339
    339  if (iItem==(INT)infoPtr->TopRootItem) 
    340         infoPtr->TopRootItem=(HTREEITEM)wineItem->sibling;
     340 if (iItem==(INT)infoPtr->TopRootItem)
     341        infoPtr->TopRootItem=(HTREEITEM)wineItem->sibling;
    341342 if (wineItem->upsibling) {
    342         upsiblingItem=& infoPtr->items [(INT)wineItem->upsibling];
    343         upsiblingItem->sibling=wineItem->sibling;
     343        upsiblingItem=& infoPtr->items [(INT)wineItem->upsibling];
     344        upsiblingItem->sibling=wineItem->sibling;
    344345 }
    345346 if (wineItem->sibling) {
    346         siblingItem=& infoPtr->items [(INT)wineItem->sibling];
    347         siblingItem->upsibling=wineItem->upsibling;
     347        siblingItem=& infoPtr->items [(INT)wineItem->sibling];
     348        siblingItem->upsibling=wineItem->upsibling;
    348349 }
    349350}
     
    356357
    357358static void TREEVIEW_RemoveTree (HWND hwnd)
    358                                            
     359
    359360{
    360361 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     
    362363 int i;
    363364
    364  for (i=1; i<=(INT)infoPtr->uMaxHandle; i++) 
    365         if (!tv_test_bit (i, infoPtr->freeList)) {
    366                 killItem=& infoPtr->items [i]; 
    367                 if (killItem->pszText!=LPSTR_TEXTCALLBACKA)
    368                         COMCTL32_Free (killItem->pszText);
    369                 TREEVIEW_SendTreeviewNotify
    370                                         (hwnd, TVN_DELETEITEM, 0, killItem->hItem, 0);
    371                 }
     365 for (i=1; i<=(INT)infoPtr->uMaxHandle; i++)
     366        if (!tv_test_bit (i, infoPtr->freeList)) {
     367                killItem=& infoPtr->items [i];
     368                if (killItem->pszText!=LPSTR_TEXTCALLBACKA)
     369                        COMCTL32_Free (killItem->pszText);
     370                TREEVIEW_SendTreeviewNotify
     371                                        (hwnd, TVN_DELETEITEM, 0, killItem->hItem, 0);
     372                }
    372373
    373374 if (infoPtr->uNumPtrsAlloced) {
     
    377378        infoPtr->uNumPtrsAlloced=0;
    378379        infoPtr->uMaxHandle=0;
    379     }   
     380    }
    380381}
    381382
     
    394395  if (infoPtr==NULL) return 0;
    395396
    396   if ((INT)wParam == TVSIL_NORMAL) 
    397         return (LRESULT) infoPtr->himlNormal;
    398   if ((INT)wParam == TVSIL_STATE) 
    399         return (LRESULT) infoPtr->himlState;
     397  if ((INT)wParam == TVSIL_NORMAL)
     398        return (LRESULT) infoPtr->himlNormal;
     399  if ((INT)wParam == TVSIL_STATE)
     400        return (LRESULT) infoPtr->himlState;
    400401
    401402  return 0;
     
    410411//    TRACE (treeview,"\n");
    411412    switch ((INT)wParam) {
    412         case TVSIL_NORMAL:
    413             himlTemp = infoPtr->himlNormal;
    414             infoPtr->himlNormal = (HIMAGELIST)lParam;
    415             return (LRESULT)himlTemp;
    416 
    417         case TVSIL_STATE:
    418             himlTemp = infoPtr->himlState;
    419             infoPtr->himlState = (HIMAGELIST)lParam;
    420             return (LRESULT)himlTemp;
     413        case TVSIL_NORMAL:
     414            himlTemp = infoPtr->himlNormal;
     415            infoPtr->himlNormal = (HIMAGELIST)lParam;
     416            return (LRESULT)himlTemp;
     417
     418        case TVSIL_STATE:
     419            himlTemp = infoPtr->himlState;
     420            infoPtr->himlState = (HIMAGELIST)lParam;
     421            return (LRESULT)himlTemp;
    421422    }
    422423
     
    435436//  TRACE (treeview,"\n");
    436437  if (wParam==-1) {
    437         hdc=GetDC (hwnd);
    438         infoPtr->uItemHeight=-1;
    439         return prevHeight;
     438        hdc=GetDC (hwnd);
     439        infoPtr->uItemHeight=-1;
     440        return prevHeight;
    440441  }
    441442
     
    446447
    447448  if (!( GetWindowLongA( hwnd, GWL_STYLE) & TVS_NONEVENHEIGHT))
    448         infoPtr->uItemHeight = (INT) wParam & 0xfffffffe;
     449        infoPtr->uItemHeight = (INT) wParam & 0xfffffffe;
    449450  return prevHeight;
    450451}
     
    454455{
    455456  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    456  
     457
    457458//  TRACE (treeview,"\n");
    458459  return infoPtr->uItemHeight;
    459460}
    460  
     461
    461462static LRESULT
    462463TREEVIEW_SetTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    474475{
    475476  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    476        
     477
    477478//  TRACE (treeview,"\n");
    478479  return (LRESULT) infoPtr->clrText;
     
    494495{
    495496  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    496        
     497
    497498//  TRACE (treeview,"\n");
    498499  return (LRESULT) infoPtr->clrBk;
     
    500501
    501502
    502 /* cdmode: custom draw mode as received from app. in first NMCUSTOMDRAW 
     503/* cdmode: custom draw mode as received from app. in first NMCUSTOMDRAW
    503504           notification */
    504505
     
    516517  RECT  r;
    517518
    518  
    519   if (wineItem->state & TVIS_BOLD) 
    520         hOldFont = SelectObject (hdc, infoPtr->hBoldFont);
    521   else 
    522         hOldFont = SelectObject (hdc, infoPtr->hFont);
     519
     520  if (wineItem->state & TVIS_BOLD)
     521        hOldFont = SelectObject (hdc, infoPtr->hBoldFont);
     522  else
     523        hOldFont = SelectObject (hdc, infoPtr->hFont);
    523524
    524525  cditem=0;
    525526  if (infoPtr->cdmode & CDRF_NOTIFYITEMDRAW) {
    526                 drawmode=CDDS_ITEMPREPAINT;
    527 
    528                 if (infoPtr->cdmode & CDRF_NOTIFYSUBITEMDRAW)
     527                drawmode=CDDS_ITEMPREPAINT;
     528
     529                if (infoPtr->cdmode & CDRF_NOTIFYSUBITEMDRAW)
    529530      drawmode|=CDDS_SUBITEM;
    530531
    531                 cditem=TREEVIEW_SendCustomDrawItemNotify (hwnd, hdc, wineItem, drawmode);
    532 
    533 //              TRACE (treeview,"cditem:%d\n",cditem);
    534 
    535                 if (cditem & CDRF_SKIPDEFAULT)
    536                         return;
    537         }
    538 
    539   /* 
    540    * Set drawing starting points 
     532                cditem=TREEVIEW_SendCustomDrawItemNotify (hwnd, hdc, wineItem, drawmode);
     533
     534//              TRACE (treeview,"cditem:%d\n",cditem);
     535
     536                if (cditem & CDRF_SKIPDEFAULT)
     537                        return;
     538        }
     539
     540  /*
     541   * Set drawing starting points
    541542   */
    542543  r      = wineItem->rect;               /* this item rectangle */
     
    544545  xpos   = r.left + TREEVIEW_LEFT_MARGIN;/* horizontal starting point */
    545546
    546   /* 
    547    * Display the tree hierarchy 
     547  /*
     548   * Display the tree hierarchy
    548549   */
    549   if ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASLINES) 
     550  if ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASLINES)
    550551  {
    551     /* 
    552      * Write links to parent node 
     552    /*
     553     * Write links to parent node
    553554     * we draw the L starting from the child to the parent
    554555     *
     
    557558     * points[2] is attached to the parent or the up sibling
    558559     */
    559     if ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_LINESATROOT) 
     560    if ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_LINESATROOT)
    560561    {
    561562      TREEVIEW_ITEM *upNode    = NULL;
    562         BOOL  hasParentOrSibling = TRUE;
     563        BOOL  hasParentOrSibling = TRUE;
    563564      RECT  upRect             = {0,0,0,0};
    564565      HPEN  hOldPen, hnewPen;
    565         POINT points[3];
    566       /* 
     566        POINT points[3];
     567      /*
    567568       * determine the target location of the line at root, either be linked
    568569       * to the up sibling or to the parent node.
    569570       */
    570571      if (wineItem->upsibling)
    571         upNode  = TREEVIEW_ValidItem (infoPtr, wineItem->upsibling);
     572        upNode  = TREEVIEW_ValidItem (infoPtr, wineItem->upsibling);
    572573      else if (wineItem->parent)
    573         upNode  = TREEVIEW_ValidItem (infoPtr, wineItem->parent);
     574        upNode  = TREEVIEW_ValidItem (infoPtr, wineItem->parent);
    574575      else
    575576        hasParentOrSibling = FALSE;
     
    582583        points[2].x = points[1].x = upRect.left+8;
    583584        points[0].x = points[2].x + 10;
    584         points[2].y = upRect.bottom-3;     
     585        points[2].y = upRect.bottom-3;
    585586        points[1].y = points[0].y = center;
    586587      }
    587588      else
    588589      {
    589         points[2].x = points[1].x = 8 + (20*wineItem->iLevel); 
    590         points[2].y = ( upNode->cChildren == 0) ? 
     590        points[2].x = points[1].x = 8 + (20*wineItem->iLevel);
     591        points[2].y = ( upNode->cChildren == 0) ?
    591592                        upRect.top :        /* is linked to the "L" above */
    592                         ( wineItem->upsibling != NULL) ? 
     593                        ( wineItem->upsibling != NULL) ?
    593594                          upRect.bottom-3:  /* is linked to an icon       */
    594595                          upRect.bottom+1;  /* is linked to a +/- box     */
    595596        points[1].y = points[0].y = center;
    596         points[0].x = points[1].x + 10; 
     597        points[0].x = points[1].x + 10;
    597598      }
    598    
    599       /* 
     599
     600      /*
    600601       * Get a doted pen
    601        */ 
     602       */
    602603      hnewPen = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT) );
    603604      hOldPen = SelectObject( hdc, hnewPen );
    604  
     605
    605606      if (hasParentOrSibling)
    606         Polyline (hdc,points,3); 
     607        Polyline (hdc,points,3);
    607608      else
    608         Polyline (hdc,points,2); 
    609      
     609        Polyline (hdc,points,2);
     610
    610611      DeleteObject(hnewPen);
    611612      SelectObject(hdc, hOldPen);
     
    613614  }
    614615
    615   /* 
     616  /*
    616617   * Display the (+/-) signs
    617618   */
     
    619620    xpos+=(5*wineItem->iLevel);
    620621
    621   if (( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASBUTTONS) && 
     622  if (( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASBUTTONS) &&
    622623      ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASLINES))
    623624  {
    624           if ( (wineItem->cChildren) ||
    625                (wineItem->cChildren == I_CHILDRENCALLBACK))
     625          if ( (wineItem->cChildren) ||
     626               (wineItem->cChildren == I_CHILDRENCALLBACK))
    626627    {
    627628      /* Setup expand box coordinate to facilitate the LMBClick handling */
     
    631632      wineItem->expandBox.bottom = center+5;
    632633
    633                 Rectangle (
    634         hdc, 
    635         wineItem->expandBox.left, 
    636         wineItem->expandBox.top , 
    637         wineItem->expandBox.right, 
     634                Rectangle (
     635        hdc,
     636        wineItem->expandBox.left,
     637        wineItem->expandBox.top ,
     638        wineItem->expandBox.right,
    638639        wineItem->expandBox.bottom);
    639640
    640                 MoveToEx (hdc, xpos-2, center, NULL);
    641                 LineTo   (hdc, xpos+3, center);
    642  
    643                 if (!(wineItem->state & TVIS_EXPANDED)) {
    644                         MoveToEx (hdc, xpos,   center-2, NULL);
    645                         LineTo   (hdc, xpos,   center+3);
    646           }
     641                MoveToEx (hdc, xpos-2, center, NULL);
     642                LineTo   (hdc, xpos+3, center);
     643
     644                if (!(wineItem->state & TVIS_EXPANDED)) {
     645                        MoveToEx (hdc, xpos,   center-2, NULL);
     646                        LineTo   (hdc, xpos,   center+3);
     647          }
    647648    }
    648649  }
    649650
    650   /* 
     651  /*
    651652   * Display the image assiciated with this item
    652653   */
     
    656657    HIMAGELIST *himlp = NULL;
    657658
    658           if (infoPtr->himlNormal)
     659          if (infoPtr->himlNormal)
    659660      himlp=&infoPtr->himlNormal; /* get the image list */
    660661
    661         if ( (wineItem->state & TVIS_SELECTED) &&
    662          (wineItem->iSelectedImage)) { 
    663        
     662        if ( (wineItem->state & TVIS_SELECTED) &&
     663         (wineItem->iSelectedImage)) {
     664
    664665      /* State images are displayed to the left of the Normal image*/
    665       if (infoPtr->himlState) 
     666      if (infoPtr->himlState)
    666667        himlp=&infoPtr->himlState;
    667668
    668669      /* The item is curently selected */
    669                   if (wineItem->iSelectedImage == I_IMAGECALLBACK)
    670                         TREEVIEW_SendDispInfoNotify (
    671           hwnd, 
    672           wineItem, 
    673           TVN_GETDISPINFO, 
     670                  if (wineItem->iSelectedImage == I_IMAGECALLBACK)
     671                        TREEVIEW_SendDispInfoNotify (
     672          hwnd,
     673          wineItem,
     674          TVN_GETDISPINFO,
    674675          TVIF_SELECTEDIMAGE);
    675676
    676677      imageIndex = wineItem->iSelectedImage;
    677678
    678           } else {
     679          } else {
    679680      /* This item is not selected */
    680                   if (wineItem->iImage == I_IMAGECALLBACK)
    681                           TREEVIEW_SendDispInfoNotify (
    682           hwnd, 
    683           wineItem, 
    684           TVN_GETDISPINFO, 
     681                  if (wineItem->iImage == I_IMAGECALLBACK)
     682                          TREEVIEW_SendDispInfoNotify (
     683          hwnd,
     684          wineItem,
     685          TVN_GETDISPINFO,
    685686          TVIF_IMAGE);
    686687
    687688      imageIndex = wineItem->iImage;
    688         }
    689  
     689        }
     690
    690691    if (himlp)
    691     { 
     692    {
    692693      /* We found an image to display? Draw it. */
    693         ImageList_Draw (
    694         *himlp, 
     694        ImageList_Draw (
     695        *himlp,
    695696        wineItem->iImage,
    696         hdc, 
    697         xpos-2, 
    698         r.top+1, 
     697        hdc,
     698        xpos-2,
     699        r.top+1,
    699700        ILD_NORMAL);
    700701
    701           ImageList_GetIconSize (*himlp, &cx, &cy);
    702           xpos+=cx;
     702          ImageList_GetIconSize (*himlp, &cx, &cy);
     703          xpos+=cx;
    703704    }
    704705  }
    705706
    706   /* 
     707  /*
    707708   * Display the text assiciated with this item
    708709   */
    709710  r.left=xpos;
    710   if ((wineItem->mask & TVIF_TEXT) && (wineItem->pszText)) 
     711  if ((wineItem->mask & TVIF_TEXT) && (wineItem->pszText))
    711712  {
    712713    COLORREF oldBkColor = 0;
     
    717718    r.right -= 3;
    718719
    719     wineItem->text.left  = r.left; 
     720    wineItem->text.left  = r.left;
    720721    wineItem->text.right = r.right;
    721722    wineItem->text.top   = r.top;
     
    726727      oldBkColor   = SetBkColor  (hdc, GetSysColor( COLOR_HIGHLIGHT));
    727728      oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_HIGHLIGHTTEXT));
    728     } 
    729     else 
     729    }
     730    else
    730731    {
    731732      oldBkMode    = SetBkMode(hdc, TRANSPARENT);
     
    740741    /* Draw it */
    741742    DrawTextA (
    742       hdc, 
    743       wineItem->pszText, 
    744       lstrlenA(wineItem->pszText), 
    745       &wineItem->text, 
    746       uTextJustify | DT_VCENTER | DT_SINGLELINE ); 
     743      hdc,
     744      wineItem->pszText,
     745      lstrlenA(wineItem->pszText),
     746      &wineItem->text,
     747      uTextJustify | DT_VCENTER | DT_SINGLELINE );
    747748
    748749    /* Obtain the text coordinate */
    749750    DrawTextA (
    750       hdc, 
    751       wineItem->pszText, 
    752       lstrlenA(wineItem->pszText), 
    753       &wineItem->text, 
    754       uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT); 
     751      hdc,
     752      wineItem->pszText,
     753      lstrlenA(wineItem->pszText),
     754      &wineItem->text,
     755      uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT);
    755756
    756757    /* Restore the hdc state */
     
    763764
    764765    /* Draw the box arround the selected item */
    765     if (wineItem->state & TVIS_SELECTED ) 
     766    if (wineItem->state & TVIS_SELECTED )
    766767    {
    767768      HPEN  hnewPen     = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT) );
    768769      HPEN  hOldPen     = SelectObject( hdc, hnewPen );
    769770      POINT points[4];
    770      
     771
    771772      points[0].x = wineItem->text.left-1;
    772       points[0].y = wineItem->text.top+1; 
     773      points[0].y = wineItem->text.top+1;
    773774      points[1].x = wineItem->text.right;
    774       points[1].y = wineItem->text.top+1; 
     775      points[1].y = wineItem->text.top+1;
    775776      points[2].x = wineItem->text.right;
    776       points[2].y = wineItem->text.bottom; 
     777      points[2].y = wineItem->text.bottom;
    777778      points[3].x = wineItem->text.left-1;
    778779      points[3].y = wineItem->text.bottom;
    779780
    780       Polyline (hdc,points,4); 
     781      Polyline (hdc,points,4);
    781782
    782783      DeleteObject(hnewPen);
     
    786787
    787788  if (cditem & CDRF_NOTIFYPOSTPAINT)
    788                 TREEVIEW_SendCustomDrawItemNotify (hwnd, hdc, wineItem, CDDS_ITEMPOSTPAINT);
     789                TREEVIEW_SendCustomDrawItemNotify (hwnd, hdc, wineItem, CDDS_ITEMPOSTPAINT);
    789790
    790791  SelectObject (hdc, hOldFont);
     
    800801
    801802//  TRACE (treeview,"\n");
    802   /* 
     803  /*
    803804   * validate parameters
    804805   */
    805   if ( (infoPtr==NULL) || (lpRect == NULL) ) 
     806  if ( (infoPtr==NULL) || (lpRect == NULL) )
    806807    return FALSE;
    807808
    808   if (infoPtr->Timer & TV_REFRESH_TIMER_SET)         
    809                 TREEVIEW_Refresh (hwnd);        /* we want a rect for the current view */
    810  
    811   /* 
     809  if (infoPtr->Timer & TV_REFRESH_TIMER_SET)
     810                TREEVIEW_Refresh (hwnd);        /* we want a rect for the current view */
     811
     812  /*
    812813   * retrive the item ptr
    813    */ 
     814   */
    814815  iItem = (HTREEITEM *) lParam;
    815816  wineItem = TREEVIEW_ValidItem (infoPtr, *iItem);
    816   if ((!wineItem) || (!wineItem->visible)) 
     817  if ((!wineItem) || (!wineItem->visible))
    817818    return FALSE;
    818819
    819   /* 
    820    * If wParam is TRUE return the text size otherwise return 
    821    * the whole item size       
     820  /*
     821   * If wParam is TRUE return the text size otherwise return
     822   * the whole item size
    822823   */
    823824  if ((INT) wParam) {
    824         lpRect->left      = wineItem->text.left;
    825     lpRect->right         = wineItem->text.right;
    826     lpRect->bottom      = wineItem->text.bottom;
    827     lpRect->top     = wineItem->text.top;
     825        lpRect->left      = wineItem->text.left;
     826    lpRect->right         = wineItem->text.right;
     827    lpRect->bottom      = wineItem->text.bottom;
     828    lpRect->top     = wineItem->text.top;
    828829  } else {
    829     lpRect->left          = wineItem->rect.left;
    830     lpRect->right         = wineItem->rect.right;
     830    lpRect->left          = wineItem->rect.left;
     831    lpRect->right         = wineItem->rect.right;
    831832    lpRect->bottom  = wineItem->rect.bottom;
    832     lpRect->top     = wineItem->rect.top;
    833   }
    834 
    835 //  TRACE (treeview,"[L:%d R:%d T:%d B:%d]\n", 
     833    lpRect->top     = wineItem->rect.top;
     834  }
     835
     836//  TRACE (treeview,"[L:%d R:%d T:%d B:%d]\n",
    836837//      lpRect->left,lpRect->right,
    837 //                      lpRect->top,lpRect->bottom);
     838//                      lpRect->top,lpRect->bottom);
    838839
    839840  return TRUE;
     
    875876
    876877  if (tvItem->mask & TVIF_INTEGRAL) {
    877         wineItem->iIntegral=tvItem->iIntegral; 
     878        wineItem->iIntegral=tvItem->iIntegral;
    878879//        FIXME (treeview," TVIF_INTEGRAL not supported yet\n");
    879880  }
     
    892893
    893894  if (tvItem->mask & TVIF_TEXT) {
    894                 if (tvItem->pszText!=LPSTR_TEXTCALLBACKA) {
     895                if (tvItem->pszText!=LPSTR_TEXTCALLBACKA) {
    895896        len=lstrlenA (tvItem->pszText);
    896         if (len>wineItem->cchTextMax) 
    897                         wineItem->pszText= COMCTL32_ReAlloc (wineItem->pszText, len+1);
     897        if (len>wineItem->cchTextMax)
     898                        wineItem->pszText= COMCTL32_ReAlloc (wineItem->pszText, len+1);
    898899        lstrcpynA (wineItem->pszText, tvItem->pszText,len);
    899                 } else {
    900                         if (wineItem->cchTextMax) {
    901                                 COMCTL32_Free (wineItem->pszText);
    902                                 wineItem->cchTextMax=0;
    903                         }
    904                 wineItem->pszText=LPSTR_TEXTCALLBACKA;
    905                 }
     900                } else {
     901                        if (wineItem->cchTextMax) {
     902                                COMCTL32_Free (wineItem->pszText);
     903                                wineItem->cchTextMax=0;
     904                        }
     905                wineItem->pszText=LPSTR_TEXTCALLBACKA;
     906                }
    906907   }
    907908
     
    918919{
    919920    TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    920         TEXTMETRICA tm;
    921         HBRUSH hbrBk;
     921        TEXTMETRICA tm;
     922        HBRUSH hbrBk;
    922923    RECT rect;
    923         HDC hdc;
     924        HDC hdc;
    924925    INT iItem, indent, x, y, cx, height, itemHeight;
    925926    INT viewtop,viewbottom,viewleft,viewright;
     
    928929//    TRACE (treeview,"\n");
    929930
    930         hdc=GetDC (hwnd);
     931        hdc=GetDC (hwnd);
    931932
    932933    if (infoPtr->Timer & TV_REFRESH_TIMER_SET) {
    933                 KillTimer (hwnd, TV_REFRESH_TIMER);
    934                 infoPtr->Timer &= ~TV_REFRESH_TIMER_SET;
     934                KillTimer (hwnd, TV_REFRESH_TIMER);
     935                infoPtr->Timer &= ~TV_REFRESH_TIMER_SET;
    935936    }
    936937
    937    
     938
    938939    GetClientRect (hwnd, &rect);
    939940    if ((rect.left-rect.right ==0) || (rect.top-rect.bottom==0)) return;
    940941
    941     infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify 
    942                                                 (hwnd, CDDS_PREPAINT, hdc, rect);
    943 
    944         if (infoPtr->cdmode==CDRF_SKIPDEFAULT) {
    945                   ReleaseDC (hwnd, hdc);
    946                   return;
    947         }
    948 
    949         infoPtr->uVisibleHeight= rect.bottom-rect.top;
    950         infoPtr->uVisibleWidth= rect.right-rect.left;
     942    infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify
     943                                                (hwnd, CDDS_PREPAINT, hdc, rect);
     944
     945        if (infoPtr->cdmode==CDRF_SKIPDEFAULT) {
     946                  ReleaseDC (hwnd, hdc);
     947                  return;
     948        }
     949
     950        infoPtr->uVisibleHeight= rect.bottom-rect.top;
     951        infoPtr->uVisibleWidth= rect.right-rect.left;
    951952
    952953    viewtop=infoPtr->cy;
     
    958959
    959960    /* draw background */
    960    
     961
    961962    hbrBk = GetSysColorBrush (COLOR_WINDOW);
    962963    FillRect(hdc, &rect, hbrBk);
     
    971972
    972973    while (iItem) {
    973                 prevItem=wineItem;
     974                prevItem=wineItem;
    974975        wineItem= & infoPtr->items[iItem];
    975                 wineItem->iLevel=indent;
     976                wineItem->iLevel=indent;
    976977
    977978        ImageList_GetIconSize (infoPtr->himlNormal, &cx, &itemHeight);
    978979        if (infoPtr->uItemHeight>itemHeight)
    979                     itemHeight=infoPtr->uItemHeight;
    980 
    981             GetTextMetricsA (hdc, &tm);
    982             if ((tm.tmHeight + tm.tmExternalLeading) > itemHeight)
    983                      itemHeight=tm.tmHeight + tm.tmExternalLeading;
    984 
    985         infoPtr->uRealItemHeight=itemHeight;   
     980                    itemHeight=infoPtr->uItemHeight;
     981
     982            GetTextMetricsA (hdc, &tm);
     983            if ((tm.tmHeight + tm.tmExternalLeading) > itemHeight)
     984                     itemHeight=tm.tmHeight + tm.tmExternalLeading;
     985
     986        infoPtr->uRealItemHeight=itemHeight;
    986987
    987988
    988989/* FIXME: remove this in later stage  */
    989990/*
    990 //              if (wineItem->pszText!=LPSTR_TEXTCALLBACK32A)
    991 //              TRACE (treeview, "%d %d [%d %d %d %d] (%s)\n",y,x,
    992 //                      wineItem->rect.top, wineItem->rect.bottom,
    993 //                      wineItem->rect.left, wineItem->rect.right,
    994 //                      wineItem->pszText);
    995 //              else
    996 //              TRACE (treeview, "%d [%d %d %d %d] (CALLBACK)\n",
    997 //                              wineItem->hItem,
    998 //                              wineItem->rect.top, wineItem->rect.bottom,
    999 //                              wineItem->rect.left, wineItem->rect.right);
     991//              if (wineItem->pszText!=LPSTR_TEXTCALLBACK32A)
     992//              TRACE (treeview, "%d %d [%d %d %d %d] (%s)\n",y,x,
     993//                      wineItem->rect.top, wineItem->rect.bottom,
     994//                      wineItem->rect.left, wineItem->rect.right,
     995//                      wineItem->pszText);
     996//              else
     997//              TRACE (treeview, "%d [%d %d %d %d] (CALLBACK)\n",
     998//                              wineItem->hItem,
     999//                              wineItem->rect.top, wineItem->rect.bottom,
     1000//                              wineItem->rect.left, wineItem->rect.right);
    10001001*/
    10011002
    1002                 height=itemHeight * wineItem->iIntegral +1;
    1003                 if ((y >= viewtop) && (y <= viewbottom) &&
    1004                 (x >= viewleft  ) && (x <= viewright)) {
    1005                                 wineItem->visible = TRUE;
    1006                         wineItem->rect.top = y - infoPtr->cy + rect.top;
    1007                         wineItem->rect.bottom = wineItem->rect.top + height ;
    1008                         wineItem->rect.left = x - infoPtr->cx + rect.left;
    1009                         wineItem->rect.right = rect.right;
    1010                         if (!infoPtr->firstVisible)
    1011                                 infoPtr->firstVisible=wineItem->hItem;
    1012                 TREEVIEW_DrawItem (hwnd, hdc, wineItem);
    1013                 }
    1014                 else {
    1015                         wineItem->visible   = FALSE;
    1016                         wineItem->rect.left = wineItem->rect.top    = 0;
    1017                         wineItem->rect.right= wineItem->rect.bottom = 0;
    1018                         wineItem->text.left = wineItem->text.top    = 0;
    1019                         wineItem->text.right= wineItem->text.bottom = 0;
    1020                 }
    1021 
    1022                 /* look up next item */
    1023        
    1024                 if ((wineItem->firstChild) && (wineItem->state & TVIS_EXPANDED)) {
    1025                         iItem=(INT)wineItem->firstChild;
    1026                         indent++;
    1027                         x+=infoPtr->uIndent;
    1028                         if (x>infoPtr->uTotalWidth)     
    1029                                 infoPtr->uTotalWidth=x;
    1030                 }
    1031                 else {
    1032                         iItem=(INT)wineItem->sibling;
    1033                         while ((!iItem) && (indent>0)) {
    1034                                 indent--;
    1035                                 x-=infoPtr->uIndent;
    1036                                 prevItem=wineItem;
    1037                                 wineItem=&infoPtr->items[(INT)wineItem->parent];
    1038                                 iItem=(INT)wineItem->sibling;
    1039                         }
    1040                 }
     1003                height=itemHeight * wineItem->iIntegral +1;
     1004                if ((y >= viewtop) && (y <= viewbottom) &&
     1005                (x >= viewleft  ) && (x <= viewright)) {
     1006                                wineItem->visible = TRUE;
     1007                        wineItem->rect.top = y - infoPtr->cy + rect.top;
     1008                        wineItem->rect.bottom = wineItem->rect.top + height ;
     1009                        wineItem->rect.left = x - infoPtr->cx + rect.left;
     1010                        wineItem->rect.right = rect.right;
     1011                        if (!infoPtr->firstVisible)
     1012                                infoPtr->firstVisible=wineItem->hItem;
     1013                TREEVIEW_DrawItem (hwnd, hdc, wineItem);
     1014                }
     1015                else {
     1016                        wineItem->visible   = FALSE;
     1017                        wineItem->rect.left = wineItem->rect.top    = 0;
     1018                        wineItem->rect.right= wineItem->rect.bottom = 0;
     1019                        wineItem->text.left = wineItem->text.top    = 0;
     1020                        wineItem->text.right= wineItem->text.bottom = 0;
     1021                }
     1022
     1023                /* look up next item */
     1024
     1025                if ((wineItem->firstChild) && (wineItem->state & TVIS_EXPANDED)) {
     1026                        iItem=(INT)wineItem->firstChild;
     1027                        indent++;
     1028                        x+=infoPtr->uIndent;
     1029                        if (x>infoPtr->uTotalWidth)
     1030                                infoPtr->uTotalWidth=x;
     1031                }
     1032                else {
     1033                        iItem=(INT)wineItem->sibling;
     1034                        while ((!iItem) && (indent>0)) {
     1035                                indent--;
     1036                                x-=infoPtr->uIndent;
     1037                                prevItem=wineItem;
     1038                                wineItem=&infoPtr->items[(INT)wineItem->parent];
     1039                                iItem=(INT)wineItem->sibling;
     1040                        }
     1041                }
    10411042        y +=height;
    1042     }                           /* while */
     1043    }                           /* while */
    10431044
    10441045/* FIXME: infoPtr->uTotalWidth should also take item label into account */
     
    10471048    infoPtr->uTotalHeight=y;
    10481049    if (y >= (viewbottom-viewtop)) {
    1049                 if (!(infoPtr->uInternalStatus & TV_VSCROLL))
    1050                         ShowScrollBar (hwnd, SB_VERT, TRUE);
    1051                 infoPtr->uInternalStatus |=TV_VSCROLL;
    1052                 SetScrollRange (hwnd, SB_VERT, 0,
    1053                                         y - infoPtr->uVisibleHeight, FALSE);
    1054                 SetScrollPos (hwnd, SB_VERT, infoPtr->cy, TRUE);
    1055         }
     1050                if (!(infoPtr->uInternalStatus & TV_VSCROLL))
     1051                        ShowScrollBar (hwnd, SB_VERT, TRUE);
     1052                infoPtr->uInternalStatus |=TV_VSCROLL;
     1053                SetScrollRange (hwnd, SB_VERT, 0,
     1054                                        y - infoPtr->uVisibleHeight, FALSE);
     1055                SetScrollPos (hwnd, SB_VERT, infoPtr->cy, TRUE);
     1056        }
    10561057    else {
    1057                 if (infoPtr->uInternalStatus & TV_VSCROLL)
    1058                         ShowScrollBar (hwnd, SB_VERT, FALSE);
    1059                 infoPtr->uInternalStatus &= ~TV_VSCROLL;
    1060         }
    1061 
    1062 
    1063         if (infoPtr->cdmode & CDRF_NOTIFYPOSTPAINT)
    1064         infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify
    1065                                                                 (hwnd, CDDS_POSTPAINT, hdc, rect);
     1058                if (infoPtr->uInternalStatus & TV_VSCROLL)
     1059                        ShowScrollBar (hwnd, SB_VERT, FALSE);
     1060                infoPtr->uInternalStatus &= ~TV_VSCROLL;
     1061        }
     1062
     1063
     1064        if (infoPtr->cdmode & CDRF_NOTIFYPOSTPAINT)
     1065        infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify
     1066                                                                (hwnd, CDDS_POSTPAINT, hdc, rect);
    10661067
    10671068    ReleaseDC (hwnd, hdc);
     
    10701071
    10711072
    1072 static LRESULT 
     1073static LRESULT
    10731074TREEVIEW_HandleTimer (HWND hwnd, WPARAM wParam, LPARAM lParam)
    10741075{
     
    10791080
    10801081  switch (wParam) {
    1081         case TV_REFRESH_TIMER:
    1082                 KillTimer (hwnd, TV_REFRESH_TIMER);
    1083                 infoPtr->Timer &= ~TV_REFRESH_TIMER_SET;
     1082        case TV_REFRESH_TIMER:
     1083                KillTimer (hwnd, TV_REFRESH_TIMER);
     1084                infoPtr->Timer &= ~TV_REFRESH_TIMER_SET;
    10841085    InvalidateRect(hwnd, NULL, FALSE);
    1085                 return 0;
    1086         case TV_EDIT_TIMER:
    1087                 KillTimer (hwnd, TV_EDIT_TIMER);
    1088                 infoPtr->Timer &= ~TV_EDIT_TIMER_SET;
    1089                 return 0;
    1090         default:
    1091 //              ERR (treeview,"got unknown timer\n");
    1092                 break;
     1086                return 0;
     1087        case TV_EDIT_TIMER:
     1088                KillTimer (hwnd, TV_EDIT_TIMER);
     1089                infoPtr->Timer &= ~TV_EDIT_TIMER_SET;
     1090                return 0;
     1091        default:
     1092//              ERR (treeview,"got unknown timer\n");
     1093                break;
    10931094 }
    1094                
     1095
    10951096 return 1;
    10961097}
     
    11051106// TRACE (treeview,"\n");
    11061107 if (infoPtr->Timer & TV_REFRESH_TIMER_SET) {
    1107         KillTimer (hwnd, TV_REFRESH_TIMER);
     1108        KillTimer (hwnd, TV_REFRESH_TIMER);
    11081109 }
    11091110
     
    11291130
    11301131   if (tvItem->mask & TVIF_CHILDREN) {
    1131 //              if (TVIF_CHILDREN==I_CHILDRENCALLBACK)
    1132 //                      FIXME (treeview,"I_CHILDRENCALLBACK not supported\n");
     1132//              if (TVIF_CHILDREN==I_CHILDRENCALLBACK)
     1133//                      FIXME (treeview,"I_CHILDRENCALLBACK not supported\n");
    11331134        tvItem->cChildren=wineItem->cChildren;
    11341135   }
     
    11431144
    11441145   if (tvItem->mask & TVIF_INTEGRAL) {
    1145         tvItem->iIntegral=wineItem->iIntegral; 
    1146 //              FIXME (treeview," TVIF_INTEGRAL not supported yet\n");
     1146        tvItem->iIntegral=wineItem->iIntegral;
     1147//              FIXME (treeview," TVIF_INTEGRAL not supported yet\n");
    11471148   }
    11481149
     
    11601161
    11611162   if (tvItem->mask & TVIF_TEXT) {
    1162         if (wineItem->pszText == LPSTR_TEXTCALLBACKA) {
    1163             tvItem->pszText = LPSTR_TEXTCALLBACKA;  /* FIXME:send notification? */
    1164 //              ERR (treeview," GetItem called with LPSTR_TEXTCALLBACK\n");
    1165         }
    1166         else if (wineItem->pszText) {
    1167             lstrcpynA (tvItem->pszText, wineItem->pszText, tvItem->cchTextMax);
    1168         }
     1163        if (wineItem->pszText == LPSTR_TEXTCALLBACKA) {
     1164            tvItem->pszText = LPSTR_TEXTCALLBACKA;  /* FIXME:send notification? */
     1165//              ERR (treeview," GetItem called with LPSTR_TEXTCALLBACK\n");
     1166        }
     1167        else if (wineItem->pszText) {
     1168            lstrcpynA (tvItem->pszText, wineItem->pszText, tvItem->cchTextMax);
     1169        }
    11691170   }
    11701171
    1171 //  TRACE(treeview,"item %d<%p>, txt %p, img %p, action %x\n", 
     1172//  TRACE(treeview,"item %d<%p>, txt %p, img %p, action %x\n",
    11721173//    iItem,
    1173 //    tvItem, 
    1174 //    tvItem->pszText, 
    1175 //    & tvItem->iImage, 
     1174//    tvItem,
     1175//    tvItem->pszText,
     1176//    & tvItem->iImage,
    11761177//    tvItem->mask);
    11771178
     
    11971198  retval=0;
    11981199  switch (flag) {
    1199         case TVGN_ROOT: retval=(INT)infoPtr->TopRootItem;
    1200                                         break;
    1201         case TVGN_CARET:retval=(INT)infoPtr->selectedItem;
    1202                                         break;
    1203         case TVGN_FIRSTVISIBLE:
    1204                                 TREEVIEW_Refresh (hwnd);       
     1200        case TVGN_ROOT: retval=(INT)infoPtr->TopRootItem;
     1201                                        break;
     1202        case TVGN_CARET:retval=(INT)infoPtr->selectedItem;
     1203                                        break;
     1204        case TVGN_FIRSTVISIBLE:
     1205                                TREEVIEW_Refresh (hwnd);
    12051206/* FIXME:we should only recalculate, not redraw */
    1206                                         retval=(INT)infoPtr->firstVisible;
    1207                                         break;
    1208         case TVGN_DROPHILITE:
    1209                                         retval=(INT)infoPtr->dropItem;
    1210                                         break;
    1211         }
     1207                                        retval=(INT)infoPtr->firstVisible;
     1208                                        break;
     1209        case TVGN_DROPHILITE:
     1210                                        retval=(INT)infoPtr->dropItem;
     1211                                        break;
     1212        }
    12121213  if (retval) {
    1213 //              TRACE (treeview,"flags:%x, returns %u\n", flag, retval);
    1214                 return retval;
    1215   }
    1216  
     1214//              TRACE (treeview,"flags:%x, returns %u\n", flag, retval);
     1215                return retval;
     1216  }
     1217
    12171218  wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem);
    12181219  returnItem = NULL;
    12191220  if (!wineItem) return FALSE;
    12201221
    1221   switch (flag) {
    1222         case TVGN_NEXT: retval=(INT)wineItem->sibling;
    1223                                         break;
    1224         case TVGN_PREVIOUS:     
    1225                                         retval=(INT)wineItem->upsibling;
    1226                                         break;
    1227         case TVGN_PARENT:
    1228                                         retval=(INT)wineItem->parent;
    1229                                         break;
    1230         case TVGN_CHILD:
    1231                                         retval=(INT)wineItem->firstChild;
    1232                                         break;
    1233         case TVGN_LASTVISIBLE: 
    1234                                         returnItem=TREEVIEW_GetLastListItem (infoPtr,wineItem);
    1235                                         break;
    1236         case TVGN_NEXTVISIBLE: 
    1237                                         returnItem=TREEVIEW_GetNextListItem (infoPtr,wineItem);
    1238                                         break;
    1239         case TVGN_PREVIOUSVISIBLE:
    1240                                         returnItem=TREEVIEW_GetPrevListItem (infoPtr, wineItem);
    1241                                         break;
    1242         default:        //      FIXME (treeview,"Unknown msg %x,item %x\n", flag,iItem);
    1243                                         break;
    1244         }
     1222  switch (flag) {
     1223        case TVGN_NEXT: retval=(INT)wineItem->sibling;
     1224                                        break;
     1225        case TVGN_PREVIOUS:
     1226                                        retval=(INT)wineItem->upsibling;
     1227                                        break;
     1228        case TVGN_PARENT:
     1229                                        retval=(INT)wineItem->parent;
     1230                                        break;
     1231        case TVGN_CHILD:
     1232                                        retval=(INT)wineItem->firstChild;
     1233                                        break;
     1234        case TVGN_LASTVISIBLE:
     1235                                        returnItem=TREEVIEW_GetLastListItem (infoPtr,wineItem);
     1236                                        break;
     1237        case TVGN_NEXTVISIBLE:
     1238                                        returnItem=TREEVIEW_GetNextListItem (infoPtr,wineItem);
     1239                                        break;
     1240        case TVGN_PREVIOUSVISIBLE:
     1241                                        returnItem=TREEVIEW_GetPrevListItem (infoPtr, wineItem);
     1242                                        break;
     1243        default:        //      FIXME (treeview,"Unknown msg %x,item %x\n", flag,iItem);
     1244                                        break;
     1245        }
    12451246
    12461247  if (returnItem) {
    1247 //                TRACE (treeview,"flags:%x, item %d;returns %d\n", flag, iItem,
    1248 //                                                      (INT)returnItem->hItem);
    1249                   return (INT)returnItem->hItem;
     1248//                TRACE (treeview,"flags:%x, item %d;returns %d\n", flag, iItem,
     1249//                                                      (INT)returnItem->hItem);
     1250                  return (INT)returnItem->hItem;
    12501251  }
    12511252
     
    12651266
    12661267/***************************************************************************
    1267  * This method does the chaining of the insertion of a treeview item 
     1268 * This method does the chaining of the insertion of a treeview item
    12681269 * before an item.
    12691270 */
    12701271static void TREEVIEW_InsertBefore(
    12711272    TREEVIEW_INFO *infoPtr,
    1272     TREEVIEW_ITEM *newItem, 
     1273    TREEVIEW_ITEM *newItem,
    12731274    TREEVIEW_ITEM *sibling,
    12741275    TREEVIEW_ITEM *parent)
     
    12851286
    12861287  if (sibling != NULL) /* Insert before this sibling for this parent */
    1287   { 
     1288  {
    12881289    /* Store the new item sibling up sibling and sibling tem handle */
    12891290    siblingHandle   = sibling->hItem;
     
    12921293    if ( (INT)sibling->upsibling != 0 )
    12931294      upSibling = &infoPtr->items[(INT)sibling->upsibling];
    1294  
     1295
    12951296    /* Adjust the sibling pointer */
    12961297    sibling->upsibling = newItem->hItem;
    1297    
     1298
    12981299    /* Adjust the new item pointers */
    12991300    newItem->upsibling = upSiblingHandle;
    13001301    newItem->sibling   = siblingHandle;
    1301    
     1302
    13021303    /* Adjust the up sibling pointer */
    1303     if ( upSibling != NULL )       
     1304    if ( upSibling != NULL )
    13041305      upSibling->sibling = newItem->hItem;
    13051306    else
     
    13121313
    13131314/***************************************************************************
    1314  * This method does the chaining of the insertion of a treeview item 
     1315 * This method does the chaining of the insertion of a treeview item
    13151316 * after an item.
    13161317 */
    13171318static void TREEVIEW_InsertAfter(
    13181319    TREEVIEW_INFO *infoPtr,
    1319     TREEVIEW_ITEM *newItem, 
     1320    TREEVIEW_ITEM *newItem,
    13201321    TREEVIEW_ITEM *upSibling,
    13211322    TREEVIEW_ITEM *parent)
     
    13321333
    13331334  if (upSibling != NULL) /* Insert after this upsibling for this parent */
    1334   { 
     1335  {
    13351336    /* Store the new item up sibling and sibling item handle */
    13361337    upSiblingHandle = upSibling->hItem;
     
    13391340    if ( (INT)upSibling->sibling != 0 )
    13401341      sibling = &infoPtr->items[(INT)upSibling->sibling];
    1341  
     1342
    13421343    /* Adjust the up sibling pointer */
    13431344    upSibling->sibling = newItem->hItem;
    1344    
     1345
    13451346    /* Adjust the new item pointers */
    13461347    newItem->upsibling = upSiblingHandle;
    13471348    newItem->sibling   = siblingHandle;
    1348    
     1349
    13491350    /* Adjust the sibling pointer */
    1350     if ( sibling != NULL )       
    1351       sibling->upsibling = newItem->hItem; 
     1351    if ( sibling != NULL )
     1352      sibling->upsibling = newItem->hItem;
    13521353    /*
    1353     else 
    1354       newItem is the last of the level, nothing else to do 
     1354    else
     1355      newItem is the last of the level, nothing else to do
    13551356    */
    13561357  }
     
    13621363 * Forward the DPA local callback to the treeview owner callback
    13631364 */
    1364 static INT WINAPI TREEVIEW_CallBackCompare( 
    1365   LPVOID first, 
    1366   LPVOID second, 
     1365static INT WINAPI TREEVIEW_CallBackCompare(
     1366  LPVOID first,
     1367  LPVOID second,
    13671368  LPARAM tvInfoPtr)
    13681369{
     
    13801381 */
    13811382LRESULT WINAPI TREEVIEW_SortChildrenCB(
    1382   HWND   hwnd, 
    1383   WPARAM wParam, 
     1383  HWND   hwnd,
     1384  WPARAM wParam,
    13841385  LPARAM lParam)
    13851386{
     
    13901391  infoPtr->pCallBackSort = (LPTVSORTCB)lParam;
    13911392
    1392   /* Obtain the parent node to sort */ 
     1393  /* Obtain the parent node to sort */
    13931394  sortMe = &infoPtr->items[ (INT)infoPtr->pCallBackSort->hParent ];
    13941395
    13951396  /* Make sure there is something to sort */
    1396   if ( sortMe->cChildren > 1 ) 
     1397  if ( sortMe->cChildren > 1 )
    13971398  {
    13981399    /* pointer organization */
     
    14081409
    14091410    /* Build the list of item to sort */
    1410     do 
     1411    do
    14111412    {
    14121413      DPA_InsertPtr(
    14131414        sortList,              /* the list */
    14141415        sortMe->cChildren+1,   /* force the insertion to be an append */
    1415         itemPtr);              /* the ptr to store */   
     1416        itemPtr);              /* the ptr to store */
    14161417
    14171418      /* Get the next sibling */
     
    14221423    /* let DPA perform the sort activity */
    14231424    DPA_Sort(
    1424       sortList,                  /* what  */ 
     1425      sortList,                  /* what  */
    14251426      TREEVIEW_CallBackCompare,  /* how   */
    14261427      hwnd);                     /* owner */
    14271428
    1428     /* 
    1429      * Reorganized TREEVIEW_ITEM structures. 
     1429    /*
     1430     * Reorganized TREEVIEW_ITEM structures.
    14301431     * Note that we know we have at least two elements.
    14311432     */
    14321433
    14331434    /* Get the first item and get ready to start... */
    1434     item = DPA_GetPtr(sortList, count++);   
     1435    item = DPA_GetPtr(sortList, count++);
    14351436    while ( (nextItem = DPA_GetPtr(sortList, count++)) != NULL )
    14361437    {
     
    14501451
    14511452      /* get ready for the next one */
    1452       prevItem = item; 
     1453      prevItem = item;
    14531454      item     = nextItem;
    14541455    }
    14551456
    14561457    /* the last item is pointed to by item and never has a sibling */
    1457     ((TREEVIEW_ITEM*)item)->sibling = NULL; 
     1458    ((TREEVIEW_ITEM*)item)->sibling = NULL;
    14581459
    14591460    DPA_Destroy(sortList);
     
    14651466
    14661467
    1467 /* the method used below isn't the most memory-friendly, but it avoids 
    1468    a lot of memory reallocations */ 
     1468/* the method used below isn't the most memory-friendly, but it avoids
     1469   a lot of memory reallocations */
    14691470
    14701471/* BTW: we waste handle 0; 0 is not an allowed handle. */
     
    14761477  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    14771478  TVINSERTSTRUCTA  *ptdi;
    1478   TVITEMEXA     *tvItem;
     1479  TVITEMEXA     *tvItem;
    14791480  TREEVIEW_ITEM *wineItem, *parentItem, *prevsib, *sibItem;
    1480   INT           iItem,listItems,i,len;
    1481  
     1481  INT           iItem,listItems,i,len;
     1482
    14821483  /* Item to insert */
    14831484  ptdi = (LPTVINSERTSTRUCTA) lParam;
    14841485
    1485         /* check if memory is available */
     1486        /* check if memory is available */
    14861487
    14871488  if (infoPtr->uNumPtrsAlloced==0) {
     
    14891490        infoPtr->freeList= COMCTL32_Alloc ((1+(TVITEM_ALLOC>>5)) * sizeof (INT));
    14901491        infoPtr->uNumPtrsAlloced=TVITEM_ALLOC;
    1491         infoPtr->TopRootItem=(HTREEITEM)1;
     1492        infoPtr->TopRootItem=(HTREEITEM)1;
    14921493   }
    14931494
    1494   /* 
    1495    * Reallocate contiguous space for items 
     1495  /*
     1496   * Reallocate contiguous space for items
    14961497   */
    14971498  if (infoPtr->uNumItems == (infoPtr->uNumPtrsAlloced-1) ) {
    1498         TREEVIEW_ITEM *oldItems = infoPtr->items;
    1499         INT *oldfreeList = infoPtr->freeList;
    1500 
    1501         infoPtr->uNumPtrsAlloced*=2;
     1499        TREEVIEW_ITEM *oldItems = infoPtr->items;
     1500        INT *oldfreeList = infoPtr->freeList;
     1501
     1502        infoPtr->uNumPtrsAlloced*=2;
    15021503    infoPtr->items = COMCTL32_Alloc (infoPtr->uNumPtrsAlloced*sizeof (TREEVIEW_ITEM));
    15031504    infoPtr->freeList= COMCTL32_Alloc ((1+(infoPtr->uNumPtrsAlloced>>5))*sizeof (INT));
     
    15081509                    infoPtr->uNumPtrsAlloced>>6 * sizeof(INT));
    15091510
    1510     COMCTL32_Free (oldItems); 
    1511     COMCTL32_Free (oldfreeList); 
     1511    COMCTL32_Free (oldItems);
     1512    COMCTL32_Free (oldfreeList);
    15121513   }
    15131514
    1514   /* 
     1515  /*
    15151516   * Reset infoPtr structure with new stat according to current TV picture
    15161517   */
    15171518  iItem=0;
    15181519  infoPtr->uNumItems++;
    1519   if ((INT)infoPtr->uMaxHandle==(infoPtr->uNumItems-1))  { 
    1520         iItem=infoPtr->uNumItems;
    1521         infoPtr->uMaxHandle = (HTREEITEM)((INT)infoPtr->uMaxHandle + 1);
    1522   } else {                                      /* check freelist */
    1523         for (i=0; i<infoPtr->uNumPtrsAlloced>>5; i++) {
    1524                 if (infoPtr->freeList[i]) {
     1520  if ((INT)infoPtr->uMaxHandle==(infoPtr->uNumItems-1))  {
     1521        iItem=infoPtr->uNumItems;
     1522        infoPtr->uMaxHandle = (HTREEITEM)((INT)infoPtr->uMaxHandle + 1);
     1523  } else {                                      /* check freelist */
     1524        for (i=0; i<infoPtr->uNumPtrsAlloced>>5; i++) {
     1525                if (infoPtr->freeList[i]) {
    15251526// WHAT IS FFS? NOT IN VAC++ C LIBRARY!!!
    1526 //                      iItem=ffs (infoPtr->freeList[i])-1;
     1527//                      iItem=ffs (infoPtr->freeList[i])-1;
    15271528//
    1528                         tv_clear_bit(iItem,&infoPtr->freeList[i]);
    1529                         iItem+=i<<5;
    1530                         break;
    1531                 }
    1532     } 
    1533   }
    1534 
    1535 //  if (TRACE_ON(treeview)) { 
    1536 //    for (i=0; i<infoPtr->uNumPtrsAlloced>>5; i++) 
    1537 //          TRACE (treeview,"%8x\n",infoPtr->freeList[i]);
     1529                        tv_clear_bit(iItem,&infoPtr->freeList[i]);
     1530                        iItem+=i<<5;
     1531                        break;
     1532                }
     1533    }
     1534  }
     1535
     1536//  if (TRACE_ON(treeview)) {
     1537//    for (i=0; i<infoPtr->uNumPtrsAlloced>>5; i++)
     1538//          TRACE (treeview,"%8x\n",infoPtr->freeList[i]);
    15381539//  }
    15391540
    15401541//  if (!iItem) ERR (treeview, "Argh -- can't find free item.\n");
    15411542
    1542   /* 
    1543    * Find the parent item of the new item 
    1544    */ 
     1543  /*
     1544   * Find the parent item of the new item
     1545   */
    15451546  tvItem= & ptdi->DUMMYUNIONNAME.itemex;
    15461547  wineItem=& infoPtr->items[iItem];
     
    15481549  if ((ptdi->hParent==TVI_ROOT) || (ptdi->hParent==0)) {
    15491550    parentItem       = NULL;
    1550     wineItem->parent = 0; 
     1551    wineItem->parent = 0;
    15511552    sibItem          = &infoPtr->items [(INT)infoPtr->TopRootItem];
    15521553    listItems        = infoPtr->uNumItems;
    15531554  }
    15541555  else  {
    1555         parentItem = &infoPtr->items[(INT)ptdi->hParent];
    1556  
     1556        parentItem = &infoPtr->items[(INT)ptdi->hParent];
     1557
    15571558    /* Do the insertion here it if it's the only item of this parent */
    1558         if (!parentItem->firstChild)
    1559                 parentItem->firstChild=(HTREEITEM)iItem;
    1560  
    1561         wineItem->parent = ptdi->hParent;
    1562         sibItem          = &infoPtr->items [(INT)parentItem->firstChild];
    1563         parentItem->cChildren++;
    1564         listItems        = parentItem->cChildren;
    1565   }
    1566 
    1567  
    1568   /* NOTE: I am moving some setup of the wineItem object that was initialy 
    1569    *       done at the end of the function since some of the values are 
    1570    *       required by the Callback sorting 
     1559        if (!parentItem->firstChild)
     1560                parentItem->firstChild=(HTREEITEM)iItem;
     1561
     1562        wineItem->parent = ptdi->hParent;
     1563        sibItem          = &infoPtr->items [(INT)parentItem->firstChild];
     1564        parentItem->cChildren++;
     1565        listItems        = parentItem->cChildren;
     1566  }
     1567
     1568
     1569  /* NOTE: I am moving some setup of the wineItem object that was initialy
     1570   *       done at the end of the function since some of the values are
     1571   *       required by the Callback sorting
    15711572   */
    15721573
    1573   if (tvItem->mask & TVIF_TEXT) 
     1574  if (tvItem->mask & TVIF_TEXT)
    15741575  {
    15751576    /*
     
    15771578     * when the insertion are ordered
    15781579     */
    1579     if (tvItem->pszText!=LPSTR_TEXTCALLBACKA) 
     1580    if (tvItem->pszText!=LPSTR_TEXTCALLBACKA)
    15801581    {
    1581 //      TRACE (treeview,"(%p,%s)\n", &tvItem->pszText, tvItem->pszText); 
     1582//      TRACE (treeview,"(%p,%s)\n", &tvItem->pszText, tvItem->pszText);
    15821583      len = lstrlenA (tvItem->pszText)+1;
    15831584      wineItem->pszText= COMCTL32_Alloc (len+1);
     
    15851586      wineItem->cchTextMax=len;
    15861587    }
    1587     else 
     1588    else
    15881589    {
    15891590//      TRACE (treeview,"LPSTR_TEXTCALLBACK\n");
     
    15931594  }
    15941595
    1595   if (tvItem->mask & TVIF_PARAM) 
     1596  if (tvItem->mask & TVIF_PARAM)
    15961597    wineItem->lParam=tvItem->lParam;
    15971598
    15981599
    1599   wineItem->upsibling=0;  /* needed in case we're the first item in a list */ 
    1600   wineItem->sibling=0;     
     1600  wineItem->upsibling=0;  /* needed in case we're the first item in a list */
     1601  wineItem->sibling=0;
    16011602  wineItem->firstChild=0;
    16021603  wineItem->hItem=(HTREEITEM)iItem;
     
    16061607
    16071608     switch ((DWORD) ptdi->hInsertAfter) {
    1608                 case (DWORD) TVI_FIRST:
    1609                         if (wineItem->parent) {
    1610                                 wineItem->sibling=parentItem->firstChild;
    1611                                 parentItem->firstChild=(HTREEITEM)iItem;
    1612                         } else {
    1613                                 wineItem->sibling=infoPtr->TopRootItem;
    1614                                 infoPtr->TopRootItem=(HTREEITEM)iItem;
    1615                         }
    1616                         sibItem->upsibling=(HTREEITEM)iItem;
    1617                         break;
    1618 
    1619                 case (DWORD) TVI_SORT: 
    1620           if (sibItem==wineItem)
    1621         /* 
    1622          * This item is the first child of the level and it 
    1623          * has already been inserted 
    1624          */               
    1625         break; 
     1609                case (DWORD) TVI_FIRST:
     1610                        if (wineItem->parent) {
     1611                                wineItem->sibling=parentItem->firstChild;
     1612                                parentItem->firstChild=(HTREEITEM)iItem;
     1613                        } else {
     1614                                wineItem->sibling=infoPtr->TopRootItem;
     1615                                infoPtr->TopRootItem=(HTREEITEM)iItem;
     1616                        }
     1617                        sibItem->upsibling=(HTREEITEM)iItem;
     1618                        break;
     1619
     1620                case (DWORD) TVI_SORT:
     1621          if (sibItem==wineItem)
     1622        /*
     1623         * This item is the first child of the level and it
     1624         * has already been inserted
     1625         */
     1626        break;
    16261627      else
    16271628      {
    1628         TREEVIEW_ITEM *aChild        = 
     1629        TREEVIEW_ITEM *aChild        =
    16291630          &infoPtr->items[(INT)parentItem->firstChild];
    1630  
     1631
    16311632        TREEVIEW_ITEM *previousChild = NULL;
    16321633        BOOL bItemInserted           = FALSE;
    1633  
     1634
    16341635        /* Iterate the parent children to see where we fit in */
    16351636        while ( aChild != NULL )
     
    16481649                        ? NULL               /* if there is no more sibling */
    16491650                        : &infoPtr->items[(INT)aChild->sibling];
    1650  
     1651
    16511652            /* Look at the next item */
    16521653            continue;
     
    16541655          else if ( comp == 0 )
    16551656          {
    1656             /* 
    1657              * An item with this name is already existing, therefore, 
    1658              * we add after the one we found 
     1657            /*
     1658             * An item with this name is already existing, therefore,
     1659             * we add after the one we found
    16591660             */
    16601661            TREEVIEW_InsertAfter(infoPtr, wineItem, aChild, parentItem);
     
    16631664          }
    16641665        }
    1665      
    1666         /* 
     1666
     1667        /*
    16671668         * we reach the end of the child list and the item as not
    16681669         * yet been inserted, therefore, insert it after the last child.
     
    16701671        if ( (! bItemInserted ) && (aChild == NULL) )
    16711672          TREEVIEW_InsertAfter(infoPtr, wineItem, previousChild, parentItem);
    1672  
     1673
    16731674        break;
    16741675      }
    16751676
    16761677
    1677                 case (DWORD) TVI_LAST: 
    1678                         if (sibItem==wineItem) break;
    1679                         while (sibItem->sibling) {
    1680                                 prevsib=sibItem;
    1681                                 sibItem=&infoPtr->items [(INT)sibItem->sibling];
    1682                         }
    1683                         sibItem->sibling=(HTREEITEM)iItem;
    1684                         wineItem->upsibling=sibItem->hItem;
    1685                         break;
    1686                 default:
    1687                         while ((sibItem->sibling) && (sibItem->hItem!=ptdi->hInsertAfter))
    1688                                 {
    1689                                 prevsib=sibItem;
     1678                case (DWORD) TVI_LAST:
     1679                        if (sibItem==wineItem) break;
     1680                        while (sibItem->sibling) {
     1681                                prevsib=sibItem;
     1682                                sibItem=&infoPtr->items [(INT)sibItem->sibling];
     1683                        }
     1684                        sibItem->sibling=(HTREEITEM)iItem;
     1685                        wineItem->upsibling=sibItem->hItem;
     1686                        break;
     1687                default:
     1688                        while ((sibItem->sibling) && (sibItem->hItem!=ptdi->hInsertAfter))
     1689                                {
     1690                                prevsib=sibItem;
    16901691                sibItem=&infoPtr->items [(INT)sibItem->sibling];
    16911692              }
    1692                         if (sibItem->hItem!=ptdi->hInsertAfter) {
    1693 //                      ERR (treeview, "tried to insert item after nonexisting handle.\n");
    1694                         break;
    1695                         }
    1696                         prevsib=sibItem;
    1697                         if (sibItem->sibling) {
    1698                 sibItem=&infoPtr->items [(INT)sibItem->sibling];
    1699                                 sibItem->upsibling=(HTREEITEM)iItem;
    1700                                 wineItem->sibling=sibItem->hItem;
    1701                         }
    1702                         prevsib->sibling=(HTREEITEM)iItem;
    1703                         wineItem->upsibling=prevsib->hItem;
    1704                         break;
    1705         }
    1706    }   
     1693                        if (sibItem->hItem!=ptdi->hInsertAfter) {
     1694//                      ERR (treeview, "tried to insert item after nonexisting handle.\n");
     1695                        break;
     1696                        }
     1697                        prevsib=sibItem;
     1698                        if (sibItem->sibling) {
     1699                sibItem=&infoPtr->items [(INT)sibItem->sibling];
     1700                                sibItem->upsibling=(HTREEITEM)iItem;
     1701                                wineItem->sibling=sibItem->hItem;
     1702                        }
     1703                        prevsib->sibling=(HTREEITEM)iItem;
     1704                        wineItem->upsibling=prevsib->hItem;
     1705                        break;
     1706        }
     1707   }
    17071708
    17081709
    17091710/* Fill in info structure */
    17101711
    1711 //   TRACE (treeview,"new item %d; parent %d, mask %x\n", iItem, 
    1712 //                      (INT)wineItem->parent,tvItem->mask);
     1712//   TRACE (treeview,"new item %d; parent %d, mask %x\n", iItem,
     1713//                      (INT)wineItem->parent,tvItem->mask);
    17131714
    17141715   wineItem->mask=tvItem->mask;
    1715    wineItem->iIntegral=1; 
     1716   wineItem->iIntegral=1;
    17161717
    17171718   if (tvItem->mask & TVIF_CHILDREN) {
    1718         wineItem->cChildren=tvItem->cChildren;
    1719 //       if (tvItem->cChildren==I_CHILDRENCALLBACK)
    1720 //                      FIXME (treeview," I_CHILDRENCALLBACK not supported\n");
    1721         }
     1719        wineItem->cChildren=tvItem->cChildren;
     1720//       if (tvItem->cChildren==I_CHILDRENCALLBACK)
     1721//                      FIXME (treeview," I_CHILDRENCALLBACK not supported\n");
     1722        }
    17221723
    17231724  wineItem->expandBox.left   = 0; /* Initialize the expandBox */
     
    17261727  wineItem->expandBox.bottom = 0;
    17271728
    1728    if (tvItem->mask & TVIF_IMAGE) 
    1729         wineItem->iImage=tvItem->iImage;
    1730 
    1731                 /* If the application sets TVIF_INTEGRAL without
    1732                         supplying a TVITEMEX structure, it's toast */
    1733 
    1734    if (tvItem->mask & TVIF_INTEGRAL) 
    1735                 wineItem->iIntegral=tvItem->iIntegral;   
    1736 
    1737    if (tvItem->mask & TVIF_SELECTEDIMAGE) 
    1738         wineItem->iSelectedImage=tvItem->iSelectedImage;
     1729   if (tvItem->mask & TVIF_IMAGE)
     1730        wineItem->iImage=tvItem->iImage;
     1731
     1732                /* If the application sets TVIF_INTEGRAL without
     1733                        supplying a TVITEMEX structure, it's toast */
     1734
     1735   if (tvItem->mask & TVIF_INTEGRAL)
     1736                wineItem->iIntegral=tvItem->iIntegral;
     1737
     1738   if (tvItem->mask & TVIF_SELECTEDIMAGE)
     1739        wineItem->iSelectedImage=tvItem->iSelectedImage;
    17391740
    17401741   if (tvItem->mask & TVIF_STATE) {
    1741 //     TRACE(treeview, "Changing item state from %d to %d\n", 
    1742 //       wineItem->state, 
     1742//     TRACE(treeview, "Changing item state from %d to %d\n",
     1743//       wineItem->state,
    17431744//       tvItem->state);
    1744         wineItem->state=tvItem->state;
    1745         wineItem->stateMask=tvItem->stateMask;
     1745        wineItem->state=tvItem->state;
     1746        wineItem->stateMask=tvItem->stateMask;
    17461747   }
    17471748
     
    17671768
    17681769  if (lParam == (INT)TVI_ROOT) {
    1769         TREEVIEW_RemoveTree (hwnd);
     1770        TREEVIEW_RemoveTree (hwnd);
    17701771  } else {
    1771         iItem= (INT) lParam;
    1772         wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem);
    1773         if (!wineItem) return FALSE;
     1772        iItem= (INT) lParam;
     1773        wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem);
     1774        if (!wineItem) return FALSE;
    17741775//    TRACE (treeview,"%s\n",wineItem->pszText);
    1775         TREEVIEW_RemoveItem (hwnd, wineItem);
     1776        TREEVIEW_RemoveItem (hwnd, wineItem);
    17761777  }
    17771778
     
    17971798  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    17981799  INT newIndent;
    1799    
     1800
    18001801//  TRACE (treeview,"\n");
    18011802  newIndent=(INT) wParam;
    18021803  if (newIndent < MINIMUM_INDENT) newIndent=MINIMUM_INDENT;
    18031804  infoPtr->uIndent=newIndent;
    1804  
     1805
    18051806  return 0;
    18061807}
     
    18421843
    18431844LRESULT CALLBACK
    1844 TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, 
    1845                                                         LPARAM lParam)
    1846 {
    1847   switch (uMsg) 
     1845TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam,
     1846                                                        LPARAM lParam)
     1847{
     1848  switch (uMsg)
    18481849  {
    1849     case WM_ERASEBKGND: 
     1850    case WM_ERASEBKGND:
    18501851    {
    18511852      RECT rc;
     
    18791880{
    18801881//  TRACE (treeview, "%x %ld\n",wParam, lParam);
    1881  
    1882   switch (HIWORD(wParam)) 
     1882
     1883  switch (HIWORD(wParam))
    18831884  {
    1884                 case EN_UPDATE:
     1885                case EN_UPDATE:
    18851886    {
    1886       /* 
    1887        * Adjust the edit window size 
     1887      /*
     1888       * Adjust the edit window size
    18881889       */
    18891890      TREEVIEW_INFO *infoPtr  = TREEVIEW_GetInfoPtr(hwnd);
     
    18961897      {
    18971898        LONG newWidth = (iLength * tm.tmAveCharWidth) + 15;
    1898            
    1899                 SetWindowPos (
     1899
     1900                SetWindowPos (
    19001901          infoPtr->hwndEdit,
    1901           HWND_TOP, 
    1902           editItem->text.left - 2, 
     1902          HWND_TOP,
     1903          editItem->text.left - 2,
    19031904          editItem->text.top  - 1,
    19041905          newWidth,
     
    19121913
    19131914    case EN_KILLFOCUS:
    1914 /*      TREEVIEW_EndEditLabelNow(hwnd, (WPARAM)FALSE, 0); 
     1915/*      TREEVIEW_EndEditLabelNow(hwnd, (WPARAM)FALSE, 0);
    19151916*/
    19161917      break;
     
    19291930  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    19301931
    1931   if (infoPtr->bAutoSize) 
     1932  if (infoPtr->bAutoSize)
    19321933  {
    19331934    infoPtr->bAutoSize = FALSE;
     
    19361937  infoPtr->bAutoSize = TRUE;
    19371938
    1938   if (wParam == SIZE_RESTORED) 
     1939  if (wParam == SIZE_RESTORED)
    19391940  {
    19401941    infoPtr->uTotalWidth  = LOWORD (lParam);
    1941         infoPtr->uTotalHeight = HIWORD (lParam);
     1942        infoPtr->uTotalHeight = HIWORD (lParam);
    19421943  } else {
    1943 //      FIXME (treeview,"WM_SIZE flag %x %lx not handled\n", wParam, lParam);
     1944//      FIXME (treeview,"WM_SIZE flag %x %lx not handled\n", wParam, lParam);
    19441945  }
    19451946
     
    19561957
    19571958//  TRACE (treeview,"(%x %lx)\n",wParam,lParam);
    1958  
    1959   if (wParam & (GWL_STYLE)) 
    1960         SetWindowLongA( hwnd, GWL_STYLE, lpss->styleNew);
    1961   if (wParam & (GWL_EXSTYLE)) 
    1962         SetWindowLongA( hwnd, GWL_STYLE, lpss->styleNew);
     1959
     1960  if (wParam & (GWL_STYLE))
     1961        SetWindowLongA( hwnd, GWL_STYLE, lpss->styleNew);
     1962  if (wParam & (GWL_EXSTYLE))
     1963        SetWindowLongA( hwnd, GWL_STYLE, lpss->styleNew);
    19631964
    19641965  return 0;
     
    19691970{
    19701971    TREEVIEW_INFO *infoPtr;
    1971         LOGFONTA logFont;
     1972        LOGFONTA logFont;
    19721973    TEXTMETRICA tm;
    1973         HDC hdc;
    1974  
     1974        HDC hdc;
     1975
    19751976//    TRACE (treeview,"wnd %x\n",hwnd);
    19761977      /* allocate memory for info structure */
     
    19801981
    19811982    if (infoPtr == NULL) {
    1982 //              ERR (treeview, "could not allocate info memory!\n");
    1983                 return 0;
     1983//              ERR (treeview, "could not allocate info memory!\n");
     1984                return 0;
    19841985    }
    19851986
    19861987    if ((TREEVIEW_INFO*) GetWindowLongA( hwnd, 0) != infoPtr) {
    1987 //              ERR (treeview, "pointer assignment error!\n");
    1988                 return 0;
     1988//              ERR (treeview, "pointer assignment error!\n");
     1989                return 0;
    19891990    }
    19901991
    1991         hdc=GetDC (hwnd);
     1992        hdc=GetDC (hwnd);
    19921993
    19931994    /* set default settings */
     
    20012002    infoPtr->himlNormal = NULL;
    20022003    infoPtr->himlState = NULL;
    2003         infoPtr->uItemHeight = -1;
     2004        infoPtr->uItemHeight = -1;
    20042005    GetTextMetricsA (hdc, &tm);
    20052006    infoPtr->hFont = GetStockObject (DEFAULT_GUI_FONT);
    2006         GetObjectA (infoPtr->hFont, sizeof (LOGFONTA), &logFont);
    2007         logFont.lfWeight=FW_BOLD;
     2007        GetObjectA (infoPtr->hFont, sizeof (LOGFONTA), &logFont);
     2008        logFont.lfWeight=FW_BOLD;
    20082009    infoPtr->hBoldFont = CreateFontIndirectA (&logFont);
    2009    
     2010
    20102011    infoPtr->items = NULL;
    20112012    infoPtr->selectedItem=0;
    2012     infoPtr->clrText=-1;        /* use system color */
     2013    infoPtr->clrText=-1;        /* use system color */
    20132014    infoPtr->dropItem=0;
    20142015    infoPtr->pCallBackSort=NULL;
     
    20192020*/
    20202021
    2021         infoPtr->hwndToolTip=0;
     2022        infoPtr->hwndToolTip=0;
    20222023    if (!( GetWindowLongA( hwnd, GWL_STYLE) & TVS_NOTOOLTIPS)) {   /* Create tooltip control */
    2023                 TTTOOLINFOA ti;
    2024 
    2025                 infoPtr->hwndToolTip = 
    2026                         CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
     2024                TTTOOLINFOA ti;
     2025
     2026                infoPtr->hwndToolTip =
     2027                        CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    20272028                   CW_USEDEFAULT, CW_USEDEFAULT,
    20282029                   CW_USEDEFAULT, CW_USEDEFAULT,
     
    20422043        }
    20432044
    2044                 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     2045                ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    20452046        ti.cbSize   = sizeof(TTTOOLINFOA);
    20462047        ti.uFlags   = TTF_IDISHWND | TTF_TRACK | TTF_TRANSPARENT ;
     
    20532054    }
    20542055
    2055         infoPtr->hwndEdit = CreateWindowExA (
    2056                           WS_EX_LEFT, 
     2056        infoPtr->hwndEdit = CreateWindowExA (
     2057                          WS_EX_LEFT,
    20572058                          "EDIT",
    20582059                          0,
    2059                           WS_CHILD | WS_BORDER | ES_AUTOHSCROLL | 
     2060                          WS_CHILD | WS_BORDER | ES_AUTOHSCROLL |
    20602061                          ES_WANTRETURN | ES_LEFT,
    20612062                          0, 0, 0, 0,
    2062                           hwnd, 
     2063                          hwnd,
    20632064                          0,0,0); /* FIXME: (HMENU)IDTVEDIT,pcs->hInstance,0);*/
    20642065
    20652066  SendMessageA ( infoPtr->hwndEdit, WM_SETFONT, infoPtr->hFont, FALSE);
    2066         infoPtr->wpEditOrig = (WNDPROC)SetWindowLongA (
     2067        infoPtr->wpEditOrig = (WNDPROC)SetWindowLongA (
    20672068                                    infoPtr->hwndEdit,
    2068                                     GWL_WNDPROC, 
    2069                                                                 (LONG) TREEVIEW_Edit_SubclassProc);
     2069                                    GWL_WNDPROC,
     2070                                                                (LONG) TREEVIEW_Edit_SubclassProc);
    20702071
    20712072  ReleaseDC (hwnd, hdc);
     
    20752076
    20762077
    2077 static LRESULT 
    2078 TREEVIEW_Destroy (HWND hwnd) 
     2078static LRESULT
     2079TREEVIEW_Destroy (HWND hwnd)
    20792080{
    20802081   TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    2081      
     2082
    20822083//   TRACE (treeview,"\n");
    20832084   TREEVIEW_RemoveTree (hwnd);
    2084    if (infoPtr->Timer & TV_REFRESH_TIMER_SET) 
     2085   if (infoPtr->Timer & TV_REFRESH_TIMER_SET)
    20852086        KillTimer (hwnd, TV_REFRESH_TIMER);
    2086    if (infoPtr->hwndToolTip) 
    2087                 DestroyWindow (infoPtr->hwndToolTip);
     2087   if (infoPtr->hwndToolTip)
     2088                DestroyWindow (infoPtr->hwndToolTip);
    20882089
    20892090   COMCTL32_Free (infoPtr);
     
    21042105        EndPaint (hwnd, &ps);
    21052106//    TRACE (treeview,"done\n");
    2106      
     2107
    21072108    return DefWindowProcA (hwnd, WM_PAINT, wParam, lParam);
    21082109}
     
    21422143
    21432144
    2144  
     2145
    21452146/* Notifications */
    21462147
    2147  
     2148
    21482149
    21492150
     
    21662167
    21672168static BOOL
    2168 TREEVIEW_SendTreeviewNotify (HWND hwnd, UINT code, UINT action, 
    2169                         HTREEITEM oldItem, HTREEITEM newItem)
     2169TREEVIEW_SendTreeviewNotify (HWND hwnd, UINT code, UINT action,
     2170                        HTREEITEM oldItem, HTREEITEM newItem)
    21702171
    21712172{
     
    21752176
    21762177//  TRACE (treeview,"code:%x action:%x olditem:%x newitem:%x\n",
    2177 //                code,action,(INT)oldItem,(INT)newItem);
     2178//                code,action,(INT)oldItem,(INT)newItem);
    21782179  nmhdr.hdr.hwndFrom = hwnd;
    21792180  nmhdr.hdr.idFrom =  GetWindowLongA( hwnd, GWL_ID);
     
    21812182  nmhdr.action = action;
    21822183  if (oldItem) {
    2183         wineItem=& infoPtr->items[(INT)oldItem];
    2184         nmhdr.itemOld.mask              = wineItem->mask;
    2185         nmhdr.itemOld.hItem             = wineItem->hItem;
    2186         nmhdr.itemOld.state             = wineItem->state;
    2187         nmhdr.itemOld.stateMask = wineItem->stateMask;
    2188         nmhdr.itemOld.iImage    = wineItem->iImage;
    2189         nmhdr.itemOld.pszText   = wineItem->pszText;
    2190         nmhdr.itemOld.cchTextMax= wineItem->cchTextMax;
    2191         nmhdr.itemOld.iImage    = wineItem->iImage;
    2192         nmhdr.itemOld.iSelectedImage    = wineItem->iSelectedImage;
    2193         nmhdr.itemOld.cChildren = wineItem->cChildren;
    2194         nmhdr.itemOld.lParam    = wineItem->lParam;
     2184        wineItem=& infoPtr->items[(INT)oldItem];
     2185        nmhdr.itemOld.mask              = wineItem->mask;
     2186        nmhdr.itemOld.hItem             = wineItem->hItem;
     2187        nmhdr.itemOld.state             = wineItem->state;
     2188        nmhdr.itemOld.stateMask = wineItem->stateMask;
     2189        nmhdr.itemOld.iImage    = wineItem->iImage;
     2190        nmhdr.itemOld.pszText   = wineItem->pszText;
     2191        nmhdr.itemOld.cchTextMax= wineItem->cchTextMax;
     2192        nmhdr.itemOld.iImage    = wineItem->iImage;
     2193        nmhdr.itemOld.iSelectedImage    = wineItem->iSelectedImage;
     2194        nmhdr.itemOld.cChildren = wineItem->cChildren;
     2195        nmhdr.itemOld.lParam    = wineItem->lParam;
    21952196  }
    21962197
    21972198  if (newItem) {
    2198         wineItem=& infoPtr->items[(INT)newItem];
    2199         nmhdr.itemNew.mask              = wineItem->mask;
    2200         nmhdr.itemNew.hItem             = wineItem->hItem;
    2201         nmhdr.itemNew.state             = wineItem->state;
    2202         nmhdr.itemNew.stateMask = wineItem->stateMask;
    2203         nmhdr.itemNew.iImage    = wineItem->iImage;
    2204         nmhdr.itemNew.pszText   = wineItem->pszText;
    2205         nmhdr.itemNew.cchTextMax= wineItem->cchTextMax;
    2206         nmhdr.itemNew.iImage    = wineItem->iImage;
    2207         nmhdr.itemNew.iSelectedImage    = wineItem->iSelectedImage;
    2208         nmhdr.itemNew.cChildren = wineItem->cChildren;
    2209         nmhdr.itemNew.lParam    = wineItem->lParam;
     2199        wineItem=& infoPtr->items[(INT)newItem];
     2200        nmhdr.itemNew.mask              = wineItem->mask;
     2201        nmhdr.itemNew.hItem             = wineItem->hItem;
     2202        nmhdr.itemNew.state             = wineItem->state;
     2203        nmhdr.itemNew.stateMask = wineItem->stateMask;
     2204        nmhdr.itemNew.iImage    = wineItem->iImage;
     2205        nmhdr.itemNew.pszText   = wineItem->pszText;
     2206        nmhdr.itemNew.cchTextMax= wineItem->cchTextMax;
     2207        nmhdr.itemNew.iImage    = wineItem->iImage;
     2208        nmhdr.itemNew.iSelectedImage    = wineItem->iSelectedImage;
     2209        nmhdr.itemNew.cChildren = wineItem->cChildren;
     2210        nmhdr.itemNew.lParam    = wineItem->lParam;
    22102211  }
    22112212
     
    22192220
    22202221static BOOL
    2221 TREEVIEW_SendTreeviewDnDNotify (HWND hwnd, UINT code, HTREEITEM dragItem, 
    2222                                                                 POINT pt)
     2222TREEVIEW_SendTreeviewDnDNotify (HWND hwnd, UINT code, HTREEITEM dragItem,
     2223                                                                POINT pt)
    22232224{
    22242225  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     
    22332234  nmhdr.action = 0;
    22342235  wineItem=& infoPtr->items[(INT)dragItem];
    2235   nmhdr.itemNew.mask    = wineItem->mask;
    2236   nmhdr.itemNew.hItem   = wineItem->hItem;
    2237   nmhdr.itemNew.state   = wineItem->state;
    2238   nmhdr.itemNew.lParam  = wineItem->lParam;
     2236  nmhdr.itemNew.mask    = wineItem->mask;
     2237  nmhdr.itemNew.hItem   = wineItem->hItem;
     2238  nmhdr.itemNew.state   = wineItem->state;
     2239  nmhdr.itemNew.lParam  = wineItem->lParam;
    22392240
    22402241  nmhdr.ptDrag.x = pt.x;
     
    22492250
    22502251static BOOL
    2251 TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem, 
    2252                                                                 UINT code, UINT what)
     2252TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem,
     2253                                                                UINT code, UINT what)
    22532254{
    22542255  NMTVDISPINFOA tvdi;
     
    22612262//    (INT)wineItem->state);
    22622263
    2263   tvdi.hdr.hwndFrom     = hwnd;
    2264   tvdi.hdr.idFrom       =  GetWindowLongA( hwnd, GWL_ID);
    2265   tvdi.hdr.code         = code;
    2266   tvdi.item.mask        = what;
    2267   tvdi.item.hItem       = wineItem->hItem;
    2268   tvdi.item.state       = wineItem->state;
    2269   tvdi.item.lParam      = wineItem->lParam;
     2264  tvdi.hdr.hwndFrom     = hwnd;
     2265  tvdi.hdr.idFrom       =  GetWindowLongA( hwnd, GWL_ID);
     2266  tvdi.hdr.code         = code;
     2267  tvdi.item.mask        = what;
     2268  tvdi.item.hItem       = wineItem->hItem;
     2269  tvdi.item.state       = wineItem->state;
     2270  tvdi.item.lParam      = wineItem->lParam;
    22702271  tvdi.item.pszText = COMCTL32_Alloc (128*sizeof(char));
    22712272  buf = tvdi.item.pszText;
    22722273
    22732274  retval=(BOOL)SendMessageA (
    2274                   GetParent(hwnd), 
     2275                  GetParent(hwnd),
    22752276                  WM_NOTIFY,
    2276                   (WPARAM)tvdi.hdr.idFrom, 
     2277                  (WPARAM)tvdi.hdr.idFrom,
    22772278                  (LPARAM)&tvdi);
    22782279
    22792280  if (what & TVIF_TEXT) {
    2280                 wineItem->pszText        = tvdi.item.pszText;
    2281                 if (buf==tvdi.item.pszText) {
    2282                         wineItem->cchTextMax = 128;
    2283                 } else {
    2284 //                      TRACE (treeview,"user-supplied buffer\n");
    2285                         COMCTL32_Free (buf);
    2286                         wineItem->cchTextMax = 0;
    2287                 }
    2288         }
    2289   if (what & TVIF_SELECTEDIMAGE) 
    2290                 wineItem->iSelectedImage = tvdi.item.iSelectedImage;
    2291   if (what & TVIF_IMAGE) 
    2292                 wineItem->iImage         = tvdi.item.iImage;
    2293   if (what & TVIF_CHILDREN) 
    2294                 wineItem->cChildren      = tvdi.item.cChildren;
     2281                wineItem->pszText        = tvdi.item.pszText;
     2282                if (buf==tvdi.item.pszText) {
     2283                        wineItem->cchTextMax = 128;
     2284                } else {
     2285//                      TRACE (treeview,"user-supplied buffer\n");
     2286                        COMCTL32_Free (buf);
     2287                        wineItem->cchTextMax = 0;
     2288                }
     2289        }
     2290  if (what & TVIF_SELECTEDIMAGE)
     2291                wineItem->iSelectedImage = tvdi.item.iSelectedImage;
     2292  if (what & TVIF_IMAGE)
     2293                wineItem->iImage         = tvdi.item.iImage;
     2294  if (what & TVIF_CHILDREN)
     2295                wineItem->cChildren      = tvdi.item.cChildren;
    22952296
    22962297 return retval;
     
    23012302static BOOL
    23022303TREEVIEW_SendCustomDrawNotify (HWND hwnd, DWORD dwDrawStage, HDC hdc,
    2303                         RECT rc)
     2304                        RECT rc)
    23042305{
    23052306  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     
    23142315  nmcd->hdr.code   = NM_CUSTOMDRAW;
    23152316  nmcd->dwDrawStage= dwDrawStage;
    2316   nmcd->hdc                = hdc;
     2317  nmcd->hdc                = hdc;
    23172318  nmcd->rc.left    = rc.left;
    23182319  nmcd->rc.right   = rc.right;
     
    23372338static BOOL
    23382339TREEVIEW_SendCustomDrawItemNotify (HWND hwnd, HDC hdc,
    2339                         TREEVIEW_ITEM *wineItem, UINT uItemDrawState)
     2340                        TREEVIEW_ITEM *wineItem, UINT uItemDrawState)
    23402341{
    23412342 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     
    23442345 DWORD dwDrawStage,dwItemSpec;
    23452346 UINT uItemState;
    2346  
     2347
    23472348 dwDrawStage=CDDS_ITEM | uItemDrawState;
    23482349 dwItemSpec=(DWORD)wineItem->hItem;
    23492350 uItemState=0;
    23502351 if (wineItem->hItem==infoPtr->selectedItem) uItemState|=CDIS_SELECTED;
    2351  if (wineItem->hItem==infoPtr->focusItem)        uItemState|=CDIS_FOCUS;
     2352 if (wineItem->hItem==infoPtr->focusItem)        uItemState|=CDIS_FOCUS;
    23522353 if (wineItem->hItem==infoPtr->hotItem)      uItemState|=CDIS_HOT;
    23532354
     
    23572358 nmcd->hdr.code   = NM_CUSTOMDRAW;
    23582359 nmcd->dwDrawStage= dwDrawStage;
    2359  nmcd->hdc                = hdc;
     2360 nmcd->hdc                = hdc;
    23602361 nmcd->rc.left    = wineItem->rect.left;
    23612362 nmcd->rc.right   = wineItem->rect.right;
     
    23712372
    23722373// TRACE (treeview,"drawstage:%lx hdc:%x item:%lx, itemstate:%x\n",
    2373 //                dwDrawStage, hdc, dwItemSpec, uItemState);
     2374//                dwDrawStage, hdc, dwItemSpec, uItemState);
    23742375
    23752376 return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY,
     
    23802381
    23812382/* Note:If the specified item is the child of a collapsed parent item,
    2382    the parent's list of child items is (recursively) expanded to reveal the 
    2383    specified item. This is mentioned for TREEVIEW_SelectItem; don't 
     2383   the parent's list of child items is (recursively) expanded to reveal the
     2384   specified item. This is mentioned for TREEVIEW_SelectItem; don't
    23842385   know if it also applies here.
    23852386*/
     
    23922393  UINT flag;
    23932394  INT expand;
    2394  
     2395
    23952396  flag = (UINT) wParam;
    23962397  expand = (INT) lParam;
     
    23982399  wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)expand);
    23992400
    2400   if (!wineItem) 
     2401  if (!wineItem)
    24012402    return 0;
    2402   if (!wineItem->cChildren) 
     2403  if (!wineItem->cChildren)
    24032404    return 0;
    24042405
    2405 //  TRACE (treeview,"For (%s) flags:%x item:%d state:%d\n", 
     2406//  TRACE (treeview,"For (%s) flags:%x item:%d state:%d\n",
    24062407//    wineItem->pszText,
    2407 //    flag, 
     2408//    flag,
    24082409//    expand,
    24092410//    wineItem->state);
     
    24162417  if (flag == TVE_TOGGLE) {    /* FIXME: check exact behaviour here */
    24172418   flag &= ~TVE_TOGGLE;    /* ie: bitwise ops or 'case' ops */
    2418    if (wineItem->state & TVIS_EXPANDED) 
     2419   if (wineItem->state & TVIS_EXPANDED)
    24192420     flag |= TVE_COLLAPSE;
    24202421   else
     
    24222423  }
    24232424
    2424   switch (flag) 
     2425  switch (flag)
    24252426  {
    2426     case TVE_COLLAPSERESET: 
     2427    case TVE_COLLAPSERESET:
    24272428//      TRACE(treeview, "  case TVE_COLLAPSERESET\n");
    2428       if (!wineItem->state & TVIS_EXPANDED) 
     2429      if (!wineItem->state & TVIS_EXPANDED)
    24292430        return 0;
    24302431
     
    24332434       break;
    24342435
    2435     case TVE_COLLAPSE: 
     2436    case TVE_COLLAPSE:
    24362437//      TRACE(treeview, "  case TVE_COLLAPSE\n");
    2437       if (!wineItem->state & TVIS_EXPANDED) 
     2438      if (!wineItem->state & TVIS_EXPANDED)
    24382439        return 0;
    24392440
     
    24412442      break;
    24422443
    2443     case TVE_EXPAND: 
     2444    case TVE_EXPAND:
    24442445//      TRACE(treeview, "  case TVE_EXPAND\n");
    2445       if (wineItem->state & TVIS_EXPANDED) 
     2446      if (wineItem->state & TVIS_EXPANDED)
    24462447        return 0;
    24472448
    24482449//      TRACE(treeview, "  is not expanded...\n");
    2449      
    2450       if (!(wineItem->state & TVIS_EXPANDEDONCE)) 
    2451       { 
     2450
     2451      if (!(wineItem->state & TVIS_EXPANDEDONCE))
     2452      {
    24522453//        TRACE(treeview, "  and has never been expanded...\n");
    24532454        wineItem->state |= TVIS_EXPANDED;
     
    24552456        /* this item has never been expanded */
    24562457        if (TREEVIEW_SendTreeviewNotify (
    2457               hwnd, 
    2458               TVN_ITEMEXPANDING, 
    2459               TVE_EXPAND, 
    2460               0, 
     2458              hwnd,
     2459              TVN_ITEMEXPANDING,
     2460              TVE_EXPAND,
     2461              0,
    24612462              (HTREEITEM)expand))
    24622463        {
    24632464//          TRACE(treeview, "  TVN_ITEMEXPANDING returned TRUE, exiting...\n");
    2464           return FALSE;   
     2465          return FALSE;
    24652466        }
    24662467
    24672468        /* FIXME
    24682469         * Since the TVN_ITEMEXPANDING message may has caused the parent to
    2469          * insert new items which in turn may have cause items placeholder 
    2470          * reallocation, I reassign the current item pointer so we have 
    2471          * something valid to work with... 
    2472          * However, this should not be necessary, 
     2470         * insert new items which in turn may have cause items placeholder
     2471         * reallocation, I reassign the current item pointer so we have
     2472         * something valid to work with...
     2473         * However, this should not be necessary,
    24732474         * investigation required in TREEVIEW_InsertItemA
    24742475         */
    24752476        wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)expand);
    2476         if (! wineItem) 
    2477         { 
    2478 //          ERR(treeview, 
     2477        if (! wineItem)
     2478        {
     2479//          ERR(treeview,
    24792480//            "Catastropic situation, cannot retreive item #%d\n",
    24802481//            expand);
     
    24862487
    24872488        TREEVIEW_SendTreeviewNotify (
    2488           hwnd, 
    2489           TVN_ITEMEXPANDED, 
    2490           TVE_EXPAND, 
    2491           0, 
     2489          hwnd,
     2490          TVN_ITEMEXPANDED,
     2491          TVE_EXPAND,
     2492          0,
    24922493          (HTREEITEM)expand);
    24932494
     
    25102511  }
    25112512
    2512 //  TRACE(treeview, "Exiting, Item %d state is now %d...\n", 
    2513 //    expand, 
     2513//  TRACE(treeview, "Exiting, Item %d state is now %d...\n",
     2514//    expand,
    25142515//    wineItem->state);
    2515  
     2516
    25162517  TREEVIEW_QueueRefresh (hwnd);
    25172518  return TRUE;
     
    25352536 while ((wineItem!=NULL) && (pt.y > wineItem->rect.bottom))
    25362537       wineItem=TREEVIEW_GetNextListItem (infoPtr,wineItem);
    2537        
    2538  if (!wineItem) 
    2539         return NULL;
     2538
     2539 if (!wineItem)
     2540        return NULL;
    25402541
    25412542 return wineItem;
     
    25682569
    25692570  wineItem=TREEVIEW_HitTestPoint (hwnd, lpht->pt);
    2570   if (!wineItem) { 
     2571  if (!wineItem) {
    25712572    lpht->flags=TVHT_NOWHERE;
    25722573    return 0;
     
    25742575
    25752576  /* FIXME: implement other flags
    2576    * Assign the appropriate flags depending on the click location 
    2577    * Intitialize flags before to "|=" it... 
     2577   * Assign the appropriate flags depending on the click location
     2578   * Intitialize flags before to "|=" it...
    25782579   */
    25792580  lpht->flags=0;
    25802581
    2581   if (x < wineItem->expandBox.left) 
     2582  if (x < wineItem->expandBox.left)
    25822583  {
    25832584    lpht->flags |= TVHT_ONITEMINDENT;
    2584   } 
    2585   else if ( ( x >= wineItem->expandBox.left) && 
     2585  }
     2586  else if ( ( x >= wineItem->expandBox.left) &&
    25862587            ( x <= wineItem->expandBox.right))
    25872588  {
    25882589    lpht->flags |= TVHT_ONITEMBUTTON;
    25892590  }
    2590   else if (x < wineItem->rect.right) 
     2591  else if (x < wineItem->rect.right)
    25912592  {
    2592     lpht->flags |= TVHT_ONITEMLABEL;   
    2593   } 
     2593    lpht->flags |= TVHT_ONITEMLABEL;
     2594  }
    25942595  else
    25952596  {
    25962597    lpht->flags|=TVHT_ONITEMRIGHT;
    25972598  }
    2598  
     2599
    25992600  lpht->hItem=wineItem->hItem;
    26002601
     
    26122613  if ( ! (BOOL)wParam ) /* wParam is set to true to cancel the edition */
    26132614  {
    2614                 if ( TREEVIEW_SendDispInfoNotify(  /* return true to cancel edition */
    2615            hwnd, 
     2615                if ( TREEVIEW_SendDispInfoNotify(  /* return true to cancel edition */
     2616           hwnd,
    26162617           editedItem,
    2617            TVN_ENDLABELEDIT, 
     2618           TVN_ENDLABELEDIT,
    26182619           0))
    26192620    {
    26202621      bRevert = TRUE;
    2621       bReturn = FALSE; 
     2622      bReturn = FALSE;
    26222623    }
    26232624  }
     
    26292630    bReturn      = FALSE;
    26302631
    2631     if (iLength == 0) 
     2632    if (iLength == 0)
    26322633    {
    26332634//      ERR( treeview, "Problem retreiving new item label.");
     
    26352636    else if (iLength >= 1023)
    26362637    {
    2637 //      ERR( treeview, 
     2638//      ERR( treeview,
    26382639//        "Insuficient space to retrieve new item label, new label ignored.");
    26392640    }
     
    26462647      {
    26472648        LPSTR tmpLabel = COMCTL32_Alloc( iLength+1 );
    2648  
     2649
    26492650//        if ( tmpLabel == NULL )
    2650 //          ERR( treeview, 
     2651//          ERR( treeview,
    26512652//            "OutOfMemory, cannot allocate space for label");
    26522653//        else
     
    26602661    }
    26612662
    2662                 ShowWindow(infoPtr->hwndEdit, SW_HIDE);
    2663                 EnableWindow(infoPtr->hwndEdit, FALSE);
     2663                ShowWindow(infoPtr->hwndEdit, SW_HIDE);
     2664                EnableWindow(infoPtr->hwndEdit, FALSE);
    26642665    infoPtr->editItem = 0;
    26652666  }
     
    26842685  if (!wineItem) return 0;
    26852686//  TRACE (treeview,"item %d \n",(INT)wineItem->hItem);
    2686  
     2687
    26872688  if (TREEVIEW_SendSimpleNotify (hwnd, NM_DBLCLK)!=TRUE) {     /* FIXME!*/
    2688         TREEVIEW_Expand (hwnd, (WPARAM) TVE_TOGGLE, (LPARAM) wineItem->hItem);
     2689        TREEVIEW_Expand (hwnd, (WPARAM) TVE_TOGGLE, (LPARAM) wineItem->hItem);
    26892690 }
    26902691 return TRUE;
     
    27132714    infoPtr->uInternalStatus|=TV_LDRAG;
    27142715  }
    2715  
     2716
    27162717  return 0;
    27172718}
     
    27242725  TREEVIEW_ITEM *editItem;
    27252726  TVHITTESTINFO ht;
    2726  
     2727
    27272728  ht.pt.x = (INT)LOWORD(lParam);
    27282729  ht.pt.y = (INT)HIWORD(lParam);
    2729  
     2730
    27302731//  TRACE (treeview,"\n");
    27312732
     
    27362737  /* Get the item */
    27372738  iItem = TREEVIEW_HitTest (hwnd, (LPARAM) &ht);
    2738   if (!iItem) 
     2739  if (!iItem)
    27392740    return 0;
    27402741
    27412742  editItem = TREEVIEW_ValidItem(infoPtr, (HTREEITEM)iItem);
    2742  
     2743
    27432744  infoPtr->uInternalStatus &= ~(TV_LDRAG | TV_LDRAGGING);
    27442745
    2745   /* 
    2746    * If the style allow editing and the node is already selected 
     2746  /*
     2747   * If the style allow editing and the node is already selected
    27472748   * and the click occured on the item label...
    27482749   */
    2749   if ( ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_EDITLABELS ) && 
     2750  if ( ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_EDITLABELS ) &&
    27502751       ( editItem->state & TVIS_SELECTED ) &&
    27512752       ( ht.flags & TVHT_ONITEMLABEL ))
     
    27532754    if ( infoPtr->editItem == 0 ) /* If we are not curently editing */
    27542755    {
    2755                 if ( TREEVIEW_SendDispInfoNotify(  /* Return true to cancel edition */
    2756               hwnd, 
    2757               editItem, 
    2758               TVN_BEGINLABELEDIT, 
     2756                if ( TREEVIEW_SendDispInfoNotify(  /* Return true to cancel edition */
     2757              hwnd,
     2758              editItem,
     2759              TVN_BEGINLABELEDIT,
    27592760              0))
    27602761      {
    2761         return 0; 
     2762        return 0;
    27622763      }
    2763  
    2764 //              TRACE(treeview,"Edit started for %s.\n", editItem->pszText);
    2765                 infoPtr->editItem = editItem->hItem;
    2766  
    2767                 SetWindowPos (
    2768         infoPtr->hwndEdit, 
    2769         HWND_TOP, 
    2770         editItem->text.left - 2, 
     2764
     2765//              TRACE(treeview,"Edit started for %s.\n", editItem->pszText);
     2766                infoPtr->editItem = editItem->hItem;
     2767
     2768                SetWindowPos (
     2769        infoPtr->hwndEdit,
     2770        HWND_TOP,
     2771        editItem->text.left - 2,
    27712772        editItem->text.top  - 1,
    27722773        editItem->text.right  - editItem->text.left + 20 ,
    27732774        editItem->text.bottom - editItem->text.top  + 3,
    27742775        SWP_DRAWFRAME );
    2775  
    2776                 SetWindowTextA( infoPtr->hwndEdit, editItem->pszText );
     2776
     2777                SetWindowTextA( infoPtr->hwndEdit, editItem->pszText );
    27772778      SendMessageA  ( infoPtr->hwndEdit, EM_SETSEL, 0, -1 );
    2778                 SetFocus      ( infoPtr->hwndEdit);
    2779       ShowWindow    ( infoPtr->hwndEdit, SW_SHOW); 
     2779                SetFocus      ( infoPtr->hwndEdit);
     2780      ShowWindow    ( infoPtr->hwndEdit, SW_SHOW);
    27802781    }
    27812782  }
     
    27872788  {
    27882789    TREEVIEW_DoSelectItem (
    2789       hwnd, 
    2790       TVGN_CARET, 
    2791       (HTREEITEM)iItem, 
     2790      hwnd,
     2791      TVGN_CARET,
     2792      (HTREEITEM)iItem,
    27922793      TVC_BYMOUSE);
    27932794  }
     
    28352836
    28362837 if (infoPtr->uInternalStatus & TV_LDRAG) {
    2837         TREEVIEW_SendTreeviewDnDNotify (hwnd, TVN_BEGINDRAG, hotItem->hItem, pt);
    2838         infoPtr->uInternalStatus &= ~TV_LDRAG;
    2839         infoPtr->uInternalStatus |= TV_LDRAGGING;
    2840         infoPtr->dropItem=hotItem->hItem;
    2841         return 0;
     2838        TREEVIEW_SendTreeviewDnDNotify (hwnd, TVN_BEGINDRAG, hotItem->hItem, pt);
     2839        infoPtr->uInternalStatus &= ~TV_LDRAG;
     2840        infoPtr->uInternalStatus |= TV_LDRAGGING;
     2841        infoPtr->dropItem=hotItem->hItem;
     2842        return 0;
    28422843 }
    28432844
    28442845 if (infoPtr->uInternalStatus & TV_RDRAG) {
    2845         TREEVIEW_SendTreeviewDnDNotify (hwnd, TVN_BEGINRDRAG, hotItem->hItem, pt);
    2846         infoPtr->uInternalStatus &= ~TV_RDRAG;
    2847         infoPtr->uInternalStatus |= TV_RDRAGGING;
    2848         infoPtr->dropItem=hotItem->hItem;
    2849         return 0;
     2846        TREEVIEW_SendTreeviewDnDNotify (hwnd, TVN_BEGINRDRAG, hotItem->hItem, pt);
     2847        infoPtr->uInternalStatus &= ~TV_RDRAG;
     2848        infoPtr->uInternalStatus |= TV_RDRAGGING;
     2849        infoPtr->dropItem=hotItem->hItem;
     2850        return 0;
    28502851 }
    2851  
     2852
    28522853 return 0;
    28532854}
     
    28672868 HFONT hOldFont;
    28682869 char    *itemtxt;
    2869  
     2870
    28702871// TRACE (treeview,"\n");
    28712872 if (!(infoPtr->himlNormal))  return 0;
    28722873 dragItem=TREEVIEW_ValidItem (infoPtr, (HTREEITEM) lParam);
    2873  
     2874
    28742875 if (!dragItem) return 0;
    28752876 itemtxt=dragItem->pszText;
     
    28772878 hwtop=GetDesktopWindow ();
    28782879 htopdc= GetDC (hwtop);
    2879  hdc=CreateCompatibleDC (htopdc); 
    2880  
     2880 hdc=CreateCompatibleDC (htopdc);
     2881
    28812882 hOldFont=SelectObject (hdc, infoPtr->hFont);
    28822883 GetTextExtentPoint32A (hdc, itemtxt, lstrlenA (itemtxt), &size);
     
    29242925  wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)newSelect);
    29252926
    2926 //  TRACE (treeview,"Entering item %d, flag %x, cause %x, state %d\n", 
    2927 //    (INT)newSelect, 
    2928 //    action, 
     2927//  TRACE (treeview,"Entering item %d, flag %x, cause %x, state %d\n",
     2928//    (INT)newSelect,
     2929//    action,
    29292930//    cause,
    29302931//    wineItem->state);
     
    29322933  if ( (wineItem) && (wineItem->parent))
    29332934  {
    2934     /* 
    2935      * If the item has a collapse parent expand the parent so he 
    2936      * can expose the item 
     2935    /*
     2936     * If the item has a collapse parent expand the parent so he
     2937     * can expose the item
    29372938     */
    29382939    TREEVIEW_ITEM *parentItem = TREEVIEW_ValidItem (infoPtr, wineItem->parent);
    2939     if ( !(parentItem->state & TVIS_EXPANDED)) 
     2940    if ( !(parentItem->state & TVIS_EXPANDED))
    29402941      TREEVIEW_Expand (hwnd, TVE_EXPAND, (LPARAM) wineItem->parent);
    29412942  }
    29422943
    2943   switch (action) 
     2944  switch (action)
    29442945  {
    2945     case TVGN_CARET: 
     2946    case TVGN_CARET:
    29462947      prevSelect=(INT)infoPtr->selectedItem;
    29472948
    2948       if ((HTREEITEM)prevSelect==newSelect) 
     2949      if ((HTREEITEM)prevSelect==newSelect)
    29492950        return FALSE;
    29502951
    29512952      prevItem= TREEVIEW_ValidItem (infoPtr, (HTREEITEM)prevSelect);
    29522953
    2953       if (newSelect) 
     2954      if (newSelect)
    29542955        if (TREEVIEW_SendTreeviewNotify(
    2955               hwnd, 
    2956               TVN_SELCHANGING, 
    2957               cause, 
    2958               (HTREEITEM)prevSelect, 
    2959               (HTREEITEM)newSelect)) 
     2956              hwnd,
     2957              TVN_SELCHANGING,
     2958              cause,
     2959              (HTREEITEM)prevSelect,
     2960              (HTREEITEM)newSelect))
    29602961          return FALSE;       /* FIXME: OK? */
    2961    
    2962       if (prevItem) 
     2962
     2963      if (prevItem)
    29632964        prevItem->state &= ~TVIS_SELECTED;
    2964       if (wineItem) 
     2965      if (wineItem)
    29652966        wineItem->state |=  TVIS_SELECTED;
    29662967
     
    29682969
    29692970      TREEVIEW_SendTreeviewNotify(
    2970         hwnd, 
    2971         TVN_SELCHANGED, 
     2971        hwnd,
     2972        TVN_SELCHANGED,
    29722973        cause,
    29732974        (HTREEITEM)prevSelect,
     
    29762977      break;
    29772978
    2978     case TVGN_DROPHILITE: 
     2979    case TVGN_DROPHILITE:
    29792980      prevItem= TREEVIEW_ValidItem (infoPtr, infoPtr->dropItem);
    29802981
    2981       if (prevItem) 
     2982      if (prevItem)
    29822983        prevItem->state &= ~TVIS_DROPHILITED;
    29832984
    29842985      infoPtr->dropItem=(HTREEITEM)newSelect;
    29852986
    2986       if (wineItem) 
     2987      if (wineItem)
    29872988        wineItem->state |=TVIS_DROPHILITED;
    29882989
     
    29932994      break;
    29942995 }
    2995  
     2996
    29962997 TREEVIEW_QueueRefresh (hwnd);
    29972998
     
    30103011
    30113012
    3012    
     3013
    30133014static LRESULT
    30143015TREEVIEW_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    30333034
    30343035// TRACE (treeview,"%x %lx\n",wParam, lParam);
    3035  
     3036
    30363037 infoPtr->hFont = (HFONT)wParam;
    30373038
     
    30463047 GetTextMetricsA (hdc, &tm);
    30473048 height= tm.tmHeight + tm.tmExternalLeading;
    3048  if (height>infoPtr->uRealItemHeight) 
    3049         infoPtr->uRealItemHeight=height;
     3049 if (height>infoPtr->uRealItemHeight)
     3050        infoPtr->uRealItemHeight=height;
    30503051 SelectObject (hdc, hOldFont);
    30513052 ReleaseDC (0, hdc);
    30523053
    3053  if (lParam)   
    3054         TREEVIEW_QueueRefresh (hwnd);
    3055  
     3054 if (lParam)
     3055        TREEVIEW_QueueRefresh (hwnd);
     3056
    30563057 return 0;
    30573058}
     
    30703071
    30713072  switch (LOWORD (wParam)) {
    3072         case SB_LINEUP:
    3073                         if (!infoPtr->cy) return FALSE;
    3074                         infoPtr->cy -= infoPtr->uRealItemHeight;
    3075                         if (infoPtr->cy < 0) infoPtr->cy=0;
    3076                         break;
    3077         case SB_LINEDOWN:
    3078                         maxHeight=infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
    3079                         if (infoPtr->cy == maxHeight) return FALSE;
    3080                         infoPtr->cy += infoPtr->uRealItemHeight;
    3081                         if (infoPtr->cy > maxHeight)
    3082                                 infoPtr->cy = maxHeight;
    3083                         break;
    3084         case SB_PAGEUP:
    3085                         if (!infoPtr->cy) return FALSE;
    3086                         infoPtr->cy -= infoPtr->uVisibleHeight;
    3087                         if (infoPtr->cy < 0) infoPtr->cy=0;
    3088                         break;
    3089         case SB_PAGEDOWN:
    3090                         maxHeight=infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
    3091                         if (infoPtr->cy == maxHeight) return FALSE;
    3092                         infoPtr->cy += infoPtr->uVisibleHeight;
     3073        case SB_LINEUP:
     3074                        if (!infoPtr->cy) return FALSE;
     3075                        infoPtr->cy -= infoPtr->uRealItemHeight;
     3076                        if (infoPtr->cy < 0) infoPtr->cy=0;
     3077                        break;
     3078        case SB_LINEDOWN:
     3079                        maxHeight=infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
     3080                        if (infoPtr->cy == maxHeight) return FALSE;
     3081                        infoPtr->cy += infoPtr->uRealItemHeight;
     3082                        if (infoPtr->cy > maxHeight)
     3083                                infoPtr->cy = maxHeight;
     3084                        break;
     3085        case SB_PAGEUP:
     3086                        if (!infoPtr->cy) return FALSE;
     3087                        infoPtr->cy -= infoPtr->uVisibleHeight;
     3088                        if (infoPtr->cy < 0) infoPtr->cy=0;
     3089                        break;
     3090        case SB_PAGEDOWN:
     3091                        maxHeight=infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
     3092                        if (infoPtr->cy == maxHeight) return FALSE;
     3093                        infoPtr->cy += infoPtr->uVisibleHeight;
    30933094            if (infoPtr->cy > maxHeight)
    30943095                infoPtr->cy = maxHeight;
    3095                         break;
    3096         case SB_THUMBTRACK:
    3097                         infoPtr->cy = HIWORD (wParam);
    3098                         break;
    3099                        
    3100   }
    3101  
     3096                        break;
     3097        case SB_THUMBTRACK:
     3098                        infoPtr->cy = HIWORD (wParam);
     3099                        break;
     3100
     3101  }
     3102
    31023103  TREEVIEW_QueueRefresh (hwnd);
    31033104  return TRUE;
     
    31053106
    31063107static LRESULT
    3107 TREEVIEW_HScroll (HWND hwnd, WPARAM wParam, LPARAM lParam) 
     3108TREEVIEW_HScroll (HWND hwnd, WPARAM wParam, LPARAM lParam)
    31083109{
    31093110  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     
    31113112
    31123113//  TRACE (treeview,"wp %lx, lp %x\n", lParam, wParam);
    3113        
     3114
    31143115  if (!infoPtr->uInternalStatus & TV_HSCROLL) return FALSE;
    31153116
    31163117  switch (LOWORD (wParam)) {
    3117         case SB_LINEUP:
    3118                         if (!infoPtr->cx) return FALSE;
    3119                         infoPtr->cx -= infoPtr->uRealItemHeight;
    3120                         if (infoPtr->cx < 0) infoPtr->cx=0;
    3121                         break;
    3122         case SB_LINEDOWN:
    3123                         maxWidth=infoPtr->uTotalWidth-infoPtr->uVisibleWidth;
    3124                         if (infoPtr->cx == maxWidth) return FALSE;
    3125                         infoPtr->cx += infoPtr->uRealItemHeight; /*FIXME */
    3126                         if (infoPtr->cx > maxWidth)
    3127                                 infoPtr->cx = maxWidth;
    3128                         break;
    3129         case SB_PAGEUP:
    3130                         if (!infoPtr->cx) return FALSE;
    3131                         infoPtr->cx -= infoPtr->uVisibleWidth;
    3132                         if (infoPtr->cx < 0) infoPtr->cx=0;
    3133                         break;
    3134         case SB_PAGEDOWN:
    3135                         maxWidth=infoPtr->uTotalWidth-infoPtr->uVisibleWidth;
    3136                         if (infoPtr->cx == maxWidth) return FALSE;
    3137                         infoPtr->cx += infoPtr->uVisibleWidth;
     3118        case SB_LINEUP:
     3119                        if (!infoPtr->cx) return FALSE;
     3120                        infoPtr->cx -= infoPtr->uRealItemHeight;
     3121                        if (infoPtr->cx < 0) infoPtr->cx=0;
     3122                        break;
     3123        case SB_LINEDOWN:
     3124                        maxWidth=infoPtr->uTotalWidth-infoPtr->uVisibleWidth;
     3125                        if (infoPtr->cx == maxWidth) return FALSE;
     3126                        infoPtr->cx += infoPtr->uRealItemHeight; /*FIXME */
     3127                        if (infoPtr->cx > maxWidth)
     3128                                infoPtr->cx = maxWidth;
     3129                        break;
     3130        case SB_PAGEUP:
     3131                        if (!infoPtr->cx) return FALSE;
     3132                        infoPtr->cx -= infoPtr->uVisibleWidth;
     3133                        if (infoPtr->cx < 0) infoPtr->cx=0;
     3134                        break;
     3135        case SB_PAGEDOWN:
     3136                        maxWidth=infoPtr->uTotalWidth-infoPtr->uVisibleWidth;
     3137                        if (infoPtr->cx == maxWidth) return FALSE;
     3138                        infoPtr->cx += infoPtr->uVisibleWidth;
    31383139            if (infoPtr->cx > maxWidth)
    31393140                infoPtr->cx = maxWidth;
    3140                         break;
    3141         case SB_THUMBTRACK:
    3142                         infoPtr->cx = HIWORD (wParam);
    3143                         break;
    3144                        
    3145   }
    3146  
     3141                        break;
     3142        case SB_THUMBTRACK:
     3143                        infoPtr->cx = HIWORD (wParam);
     3144                        break;
     3145
     3146  }
     3147
    31473148  TREEVIEW_QueueRefresh (hwnd);
    31483149  return TRUE;
     
    31593160 INT           prevSelect      = (INT)infoPtr->selectedItem;
    31603161
    3161  TREEVIEW_ITEM *prevItem       = 
    3162     (prevSelect != 0 ) ? 
     3162 TREEVIEW_ITEM *prevItem       =
     3163    (prevSelect != 0 ) ?
    31633164      TREEVIEW_ValidItem (infoPtr, (HTREEITEM)prevSelect) :
    31643165      NULL;
     
    31683169// TRACE (treeview,"%x %lx\n",wParam, lParam);
    31693170
    3170  if (prevSelect == 0) 
     3171 if (prevSelect == 0)
    31713172   return FALSE;
    31723173
    31733174 switch (wParam) {
    3174         case VK_UP:
    3175                 newItem=TREEVIEW_GetPrevListItem (infoPtr, prevItem);
    3176 
    3177                 if (!newItem)
    3178                         newItem=& infoPtr->items[(INT)infoPtr->TopRootItem];
     3175        case VK_UP:
     3176                newItem=TREEVIEW_GetPrevListItem (infoPtr, prevItem);
     3177
     3178                if (!newItem)
     3179                        newItem=& infoPtr->items[(INT)infoPtr->TopRootItem];
    31793180
    31803181    hNewSelection = newItem->hItem;
     
    31833184      scrollNeeds = SB_LINEUP;
    31843185
    3185                 break;
    3186 
    3187         case VK_DOWN:
    3188                 newItem=TREEVIEW_GetNextListItem (infoPtr, prevItem);
    3189 
    3190                 if (!newItem)
     3186                break;
     3187
     3188        case VK_DOWN:
     3189                newItem=TREEVIEW_GetNextListItem (infoPtr, prevItem);
     3190
     3191                if (!newItem)
    31913192      newItem=prevItem;
    31923193
     
    31963197      scrollNeeds = SB_LINEDOWN;
    31973198
    3198                 break;
    3199 
    3200         case VK_HOME:
    3201                 newItem       = &infoPtr->items[(INT)infoPtr->TopRootItem];
     3199                break;
     3200
     3201        case VK_HOME:
     3202                newItem       = &infoPtr->items[(INT)infoPtr->TopRootItem];
    32023203    hNewSelection = newItem->hItem;
    32033204    cyChangeNeeds = 0;
    3204                 break;
    3205 
    3206         case VK_END:
    3207                 newItem       = &infoPtr->items[(INT)infoPtr->TopRootItem];
    3208                 newItem       = TREEVIEW_GetLastListItem (infoPtr, newItem);
     3205                break;
     3206
     3207        case VK_END:
     3208                newItem       = &infoPtr->items[(INT)infoPtr->TopRootItem];
     3209                newItem       = TREEVIEW_GetLastListItem (infoPtr, newItem);
    32093210    hNewSelection = newItem->hItem;
    32103211
     
    32123213      cyChangeNeeds = infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
    32133214
    3214                 break;
    3215 
    3216         case VK_LEFT:
     3215                break;
     3216
     3217        case VK_LEFT:
    32173218    if ( (prevItem->cChildren > 0) && (prevItem->state & TVIS_EXPANDED) )
    32183219    {
    32193220      TREEVIEW_Expand(hwnd, TVE_COLLAPSE, prevSelect );
    32203221    }
    3221     else if ((INT)prevItem->parent) 
     3222    else if ((INT)prevItem->parent)
    32223223    {
    32233224      newItem = (& infoPtr->items[(INT)prevItem->parent]);
    3224       if (! newItem->visible) 
     3225      if (! newItem->visible)
    32253226        /* FIXME find a way to make this item the first visible... */
    3226         newItem = NULL; 
     3227        newItem = NULL;
    32273228
    32283229      hNewSelection = newItem->hItem;
     
    32313232    break;
    32323233
    3233         case VK_RIGHT:
    3234     if ( ( prevItem->cChildren > 0)  || 
     3234        case VK_RIGHT:
     3235    if ( ( prevItem->cChildren > 0)  ||
    32353236         ( prevItem->cChildren == I_CHILDRENCALLBACK))
    32363237    {
     
    32573258
    32583259  case VK_PRIOR:
    3259    
    3260                 newItem=TREEVIEW_GetListItem(
    3261               infoPtr, 
     3260
     3261                newItem=TREEVIEW_GetListItem(
     3262              infoPtr,
    32623263              prevItem,
    32633264              -1*(TREEVIEW_GetVisibleCount(hwnd,0,0)-3));
    3264                 if (!newItem)
     3265                if (!newItem)
    32653266      newItem=prevItem;
    3266  
     3267
    32673268    hNewSelection = newItem->hItem;
    32683269
     
    32703271      scrollNeeds = SB_PAGEUP;
    32713272
    3272                 break;
     3273                break;
    32733274
    32743275  case VK_NEXT:
    3275                 newItem=TREEVIEW_GetListItem(
    3276               infoPtr, 
     3276                newItem=TREEVIEW_GetListItem(
     3277              infoPtr,
    32773278              prevItem,
    32783279              TREEVIEW_GetVisibleCount(hwnd,0,0)-3);
    32793280
    3280                 if (!newItem)
     3281                if (!newItem)
    32813282      newItem=prevItem;
    32823283
     
    32863287      scrollNeeds = SB_PAGEDOWN;
    32873288
    3288                 break;
    3289 
    3290         case VK_BACK:
    3291 
    3292         case VK_RETURN:
     3289                break;
     3290
     3291        case VK_BACK:
     3292
     3293        case VK_RETURN:
    32933294
    32943295  default:
    3295 //              FIXME (treeview, "%x not implemented\n", wParam);
    3296                 break;
     3296//              FIXME (treeview, "%x not implemented\n", wParam);
     3297                break;
    32973298 }
    32983299
    3299   if (hNewSelection) 
     3300  if (hNewSelection)
    33003301  {
    3301 /* 
     3302/*
    33023303    This works but does not send notification...
    33033304
     
    33083309*/
    33093310
    3310     if ( TREEVIEW_DoSelectItem( 
    3311            hwnd, 
    3312            TVGN_CARET, 
    3313            (HTREEITEM)hNewSelection, 
     3311    if ( TREEVIEW_DoSelectItem(
     3312           hwnd,
     3313           TVGN_CARET,
     3314           (HTREEITEM)hNewSelection,
    33143315           TVC_BYKEYBOARD))
    33153316    {
     
    33173318      if (scrollNeeds != -1)
    33183319        TREEVIEW_VScroll(hwnd, scrollNeeds, 0);
    3319  
     3320
    33203321      if (cyChangeNeeds != -1)
    33213322        infoPtr->cy = cyChangeNeeds;
    33223323
    3323       /* FIXME: Something happen in the load the in the two weeks before 
    3324          april 1st 1999 which makes this SetFocus mandatory otherwise, the focus 
     3324      /* FIXME: Something happen in the load the in the two weeks before
     3325         april 1st 1999 which makes this SetFocus mandatory otherwise, the focus
    33253326         is lost... However the SetFocus should not be required...*/
    3326                
     3327
    33273328      SetFocus(hwnd);
    33283329    }
     
    33373338{
    33383339    switch (uMsg) {
    3339         case TVM_INSERTITEMA:
     3340        case TVM_INSERTITEMA:
    33403341          return TREEVIEW_InsertItemA (hwnd, wParam, lParam);
    33413342
    3342         case TVM_INSERTITEMW:
    3343 //                      FIXME (treeview, "Unimplemented msg TVM_INSERTITEM32W\n");
    3344                 return 0;
    3345 
    3346         case TVM_DELETEITEM:
    3347                 return TREEVIEW_DeleteItem (hwnd, wParam, lParam);
    3348 
    3349         case TVM_EXPAND:
    3350                 return TREEVIEW_Expand (hwnd, wParam, lParam);
    3351 
    3352         case TVM_GETITEMRECT:
    3353                 return TREEVIEW_GetItemRect (hwnd, wParam, lParam);
    3354 
    3355         case TVM_GETCOUNT:
    3356                 return TREEVIEW_GetCount (hwnd, wParam, lParam);
    3357 
    3358         case TVM_GETINDENT:
    3359                 return TREEVIEW_GetIndent (hwnd);
    3360 
    3361         case TVM_SETINDENT:
    3362                 return TREEVIEW_SetIndent (hwnd, wParam);
    3363 
    3364         case TVM_GETIMAGELIST:
    3365                 return TREEVIEW_GetImageList (hwnd, wParam, lParam);
    3366 
    3367                 case TVM_SETIMAGELIST:
    3368                 return TREEVIEW_SetImageList (hwnd, wParam, lParam);
    3369 
    3370         case TVM_GETNEXTITEM:
    3371                 return TREEVIEW_GetNextItem (hwnd, wParam, lParam);
    3372 
    3373         case TVM_SELECTITEM:
    3374                 return TREEVIEW_SelectItem (hwnd, wParam, lParam);
    3375 
    3376         case TVM_GETITEMA:
    3377                 return TREEVIEW_GetItemA (hwnd, wParam, lParam);
    3378 
    3379         case TVM_GETITEMW:
    3380 //                      FIXME (treeview, "Unimplemented msg TVM_GETITEM32W\n");
    3381                 return 0;
    3382 
    3383         case TVM_SETITEMA:
    3384                 return TREEVIEW_SetItemA (hwnd, wParam, lParam);
    3385 
    3386         case TVM_SETITEMW:
    3387 //                      FIXME (treeview, "Unimplemented msg TVM_SETITEMW\n");
    3388                 return 0;
    3389 
    3390         case TVM_EDITLABELA:
    3391 //                      FIXME (treeview, "Unimplemented msg TVM_EDITLABEL32A \n");
    3392                 return 0;
    3393 
    3394         case TVM_EDITLABELW:
    3395 //                      FIXME (treeview, "Unimplemented msg TVM_EDITLABEL32W \n");
    3396                 return 0;
    3397 
    3398         case TVM_GETEDITCONTROL:
    3399                 return TREEVIEW_GetEditControl (hwnd);
    3400 
    3401         case TVM_GETVISIBLECOUNT:
    3402                 return TREEVIEW_GetVisibleCount (hwnd, wParam, lParam);
    3403 
    3404         case TVM_HITTEST:
    3405                 return TREEVIEW_HitTest (hwnd, lParam);
    3406 
    3407         case TVM_CREATEDRAGIMAGE:
    3408                 return TREEVIEW_CreateDragImage (hwnd, wParam, lParam);
    3409  
    3410         case TVM_SORTCHILDREN:
    3411 //                      FIXME (treeview, "Unimplemented msg TVM_SORTCHILDREN\n");
    3412                 return 0;
    3413  
    3414         case TVM_ENSUREVISIBLE:
    3415 //                      FIXME (treeview, "Unimplemented msg TVM_ENSUREVISIBLE\n");
    3416                 return 0;
    3417  
    3418         case TVM_SORTCHILDRENCB:
    3419                 return TREEVIEW_SortChildrenCB(hwnd, wParam, lParam);
    3420  
    3421         case TVM_ENDEDITLABELNOW:
    3422                 return TREEVIEW_EndEditLabelNow (hwnd, wParam, lParam);
    3423  
    3424         case TVM_GETISEARCHSTRINGA:
    3425 //                      FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRING32A\n");
    3426                 return 0;
    3427  
    3428         case TVM_GETISEARCHSTRINGW:
    3429 //                      FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRING32W\n");
    3430                 return 0;
    3431  
    3432         case TVM_GETTOOLTIPS:
    3433                 return TREEVIEW_GetToolTips (hwnd);
    3434 
    3435         case TVM_SETTOOLTIPS:
    3436                 return TREEVIEW_SetToolTips (hwnd, wParam);
    3437  
    3438         case TVM_SETINSERTMARK:
    3439 //                      FIXME (treeview, "Unimplemented msg TVM_SETINSERTMARK\n");
    3440                 return 0;
    3441  
    3442         case TVM_SETITEMHEIGHT:
    3443                 return TREEVIEW_SetItemHeight (hwnd, wParam);
    3444  
    3445         case TVM_GETITEMHEIGHT:
    3446                 return TREEVIEW_GetItemHeight (hwnd);
    3447  
    3448         case TVM_SETBKCOLOR:
    3449                 return TREEVIEW_SetBkColor (hwnd, wParam, lParam);
    3450        
    3451         case TVM_SETTEXTCOLOR:
    3452                 return TREEVIEW_SetTextColor (hwnd, wParam, lParam);
    3453  
    3454         case TVM_GETBKCOLOR:
    3455                 return TREEVIEW_GetBkColor (hwnd);
    3456  
    3457         case TVM_GETTEXTCOLOR:
    3458                 return TREEVIEW_GetTextColor (hwnd);
    3459  
    3460         case TVM_SETSCROLLTIME:
    3461 //                      FIXME (treeview, "Unimplemented msg TVM_SETSCROLLTIME\n");
    3462                 return 0;
    3463  
    3464         case TVM_GETSCROLLTIME:
    3465 //                      FIXME (treeview, "Unimplemented msg TVM_GETSCROLLTIME\n");
    3466                 return 0;
    3467  
    3468         case TVM_SETINSERTMARKCOLOR:
    3469 //                      FIXME (treeview, "Unimplemented msg TVM_SETINSERTMARKCOLOR\n");
    3470                 return 0;
    3471  
    3472         case TVM_SETUNICODEFORMAT:
    3473 //                      FIXME (treeview, "Unimplemented msg TVM_SETUNICODEFORMAT\n");
    3474                 return 0;
    3475  
    3476         case TVM_GETUNICODEFORMAT:
    3477 //                      FIXME (treeview, "Unimplemented msg TVM_GETUNICODEFORMAT\n");
    3478                 return 0;
    3479  
    3480                 case WM_COMMAND:
    3481                         return TREEVIEW_Command (hwnd, wParam, lParam);
    3482  
    3483                 case WM_CREATE:
    3484                         return TREEVIEW_Create (hwnd, wParam, lParam);
    3485  
    3486                 case WM_DESTROY:
    3487                         return TREEVIEW_Destroy (hwnd);
    3488  
    3489 /*              case WM_ENABLE: */
    3490  
    3491                 case WM_ERASEBKGND:
    3492                         return TREEVIEW_EraseBackground (hwnd, wParam, lParam);
    3493  
    3494                 case WM_GETDLGCODE:
    3495                 return DLGC_WANTARROWS | DLGC_WANTCHARS;
    3496  
    3497                 case WM_PAINT:
    3498                 return TREEVIEW_Paint (hwnd, wParam, lParam);
    3499  
    3500                 case WM_GETFONT:
    3501                 return TREEVIEW_GetFont (hwnd, wParam, lParam);
    3502 
    3503                 case WM_SETFONT:
    3504                 return TREEVIEW_SetFont (hwnd, wParam, lParam);
    3505  
    3506                 case WM_KEYDOWN:
    3507                         return TREEVIEW_KeyDown (hwnd, wParam, lParam);
    3508  
    3509  
    3510                 case WM_SETFOCUS:
    3511                         return TREEVIEW_SetFocus (hwnd, wParam, lParam);
    3512 
    3513                 case WM_KILLFOCUS:
    3514                         return TREEVIEW_KillFocus (hwnd, wParam, lParam);
    3515  
    3516  
    3517                 case WM_LBUTTONDOWN:
    3518                         return TREEVIEW_LButtonDown (hwnd, wParam, lParam);
    3519 
    3520                 case WM_LBUTTONUP:
    3521                         return TREEVIEW_LButtonUp (hwnd, wParam, lParam);
    3522  
    3523                 case WM_LBUTTONDBLCLK:
    3524                         return TREEVIEW_LButtonDoubleClick (hwnd, wParam, lParam);
    3525  
    3526                 case WM_RBUTTONDOWN:
    3527                         return TREEVIEW_RButtonDown (hwnd, wParam, lParam);
    3528 
    3529                 case WM_RBUTTONUP:
    3530                         return TREEVIEW_RButtonUp (hwnd, wParam, lParam);
    3531 
    3532                 case WM_MOUSEMOVE:
    3533                         return TREEVIEW_MouseMove (hwnd, wParam, lParam);
    3534  
    3535  
    3536 /*              case WM_SYSCOLORCHANGE: */
    3537                 case WM_STYLECHANGED:
    3538                         return TREEVIEW_StyleChanged (hwnd, wParam, lParam);
    3539 
    3540 /*              case WM_SETREDRAW: */
    3541  
    3542                 case WM_TIMER:
    3543                         return TREEVIEW_HandleTimer (hwnd, wParam, lParam);
    3544  
    3545                 case WM_SIZE:
    3546                         return TREEVIEW_Size (hwnd, wParam,lParam);
    3547 
    3548                 case WM_HSCROLL:
    3549                         return TREEVIEW_HScroll (hwnd, wParam, lParam);
    3550                 case WM_VSCROLL:
    3551                         return TREEVIEW_VScroll (hwnd, wParam, lParam);
    3552  
    3553                 case WM_DRAWITEM:
    3554 //                      printf ("drawItem\n");
    3555                         return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    3556  
    3557                 default:
    3558                 if (uMsg >= WM_USER)
    3559 //              FIXME (treeview, "Unknown msg %04x wp=%08x lp=%08lx\n",
    3560 //                   uMsg, wParam, lParam);
    3561             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     3343        case TVM_INSERTITEMW:
     3344//                      FIXME (treeview, "Unimplemented msg TVM_INSERTITEM32W\n");
     3345                return 0;
     3346
     3347        case TVM_DELETEITEM:
     3348                return TREEVIEW_DeleteItem (hwnd, wParam, lParam);
     3349
     3350        case TVM_EXPAND:
     3351                return TREEVIEW_Expand (hwnd, wParam, lParam);
     3352
     3353        case TVM_GETITEMRECT:
     3354                return TREEVIEW_GetItemRect (hwnd, wParam, lParam);
     3355
     3356        case TVM_GETCOUNT:
     3357                return TREEVIEW_GetCount (hwnd, wParam, lParam);
     3358
     3359        case TVM_GETINDENT:
     3360                return TREEVIEW_GetIndent (hwnd);
     3361
     3362        case TVM_SETINDENT:
     3363                return TREEVIEW_SetIndent (hwnd, wParam);
     3364
     3365        case TVM_GETIMAGELIST:
     3366                return TREEVIEW_GetImageList (hwnd, wParam, lParam);
     3367
     3368                case TVM_SETIMAGELIST:
     3369                return TREEVIEW_SetImageList (hwnd, wParam, lParam);
     3370
     3371        case TVM_GETNEXTITEM:
     3372                return TREEVIEW_GetNextItem (hwnd, wParam, lParam);
     3373
     3374        case TVM_SELECTITEM:
     3375                return TREEVIEW_SelectItem (hwnd, wParam, lParam);
     3376
     3377        case TVM_GETITEMA:
     3378                return TREEVIEW_GetItemA (hwnd, wParam, lParam);
     3379
     3380        case TVM_GETITEMW:
     3381//                      FIXME (treeview, "Unimplemented msg TVM_GETITEM32W\n");
     3382                return 0;
     3383
     3384        case TVM_SETITEMA:
     3385                return TREEVIEW_SetItemA (hwnd, wParam, lParam);
     3386
     3387        case TVM_SETITEMW:
     3388//                      FIXME (treeview, "Unimplemented msg TVM_SETITEMW\n");
     3389                return 0;
     3390
     3391        case TVM_EDITLABELA:
     3392//                      FIXME (treeview, "Unimplemented msg TVM_EDITLABEL32A \n");
     3393                return 0;
     3394
     3395        case TVM_EDITLABELW:
     3396//                      FIXME (treeview, "Unimplemented msg TVM_EDITLABEL32W \n");
     3397                return 0;
     3398
     3399        case TVM_GETEDITCONTROL:
     3400                return TREEVIEW_GetEditControl (hwnd);
     3401
     3402        case TVM_GETVISIBLECOUNT:
     3403                return TREEVIEW_GetVisibleCount (hwnd, wParam, lParam);
     3404
     3405        case TVM_HITTEST:
     3406                return TREEVIEW_HitTest (hwnd, lParam);
     3407
     3408        case TVM_CREATEDRAGIMAGE:
     3409                return TREEVIEW_CreateDragImage (hwnd, wParam, lParam);
     3410
     3411        case TVM_SORTCHILDREN:
     3412//                      FIXME (treeview, "Unimplemented msg TVM_SORTCHILDREN\n");
     3413                return 0;
     3414
     3415        case TVM_ENSUREVISIBLE:
     3416//                      FIXME (treeview, "Unimplemented msg TVM_ENSUREVISIBLE\n");
     3417                return 0;
     3418
     3419        case TVM_SORTCHILDRENCB:
     3420                return TREEVIEW_SortChildrenCB(hwnd, wParam, lParam);
     3421
     3422        case TVM_ENDEDITLABELNOW:
     3423                return TREEVIEW_EndEditLabelNow (hwnd, wParam, lParam);
     3424
     3425        case TVM_GETISEARCHSTRINGA:
     3426//                      FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRING32A\n");
     3427                return 0;
     3428
     3429        case TVM_GETISEARCHSTRINGW:
     3430//                      FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRING32W\n");
     3431                return 0;
     3432
     3433        case TVM_GETTOOLTIPS:
     3434                return TREEVIEW_GetToolTips (hwnd);
     3435
     3436        case TVM_SETTOOLTIPS:
     3437                return TREEVIEW_SetToolTips (hwnd, wParam);
     3438
     3439        case TVM_SETINSERTMARK:
     3440//                      FIXME (treeview, "Unimplemented msg TVM_SETINSERTMARK\n");
     3441                return 0;
     3442
     3443        case TVM_SETITEMHEIGHT:
     3444                return TREEVIEW_SetItemHeight (hwnd, wParam);
     3445
     3446        case TVM_GETITEMHEIGHT:
     3447                return TREEVIEW_GetItemHeight (hwnd);
     3448
     3449        case TVM_SETBKCOLOR:
     3450                return TREEVIEW_SetBkColor (hwnd, wParam, lParam);
     3451
     3452        case TVM_SETTEXTCOLOR:
     3453                return TREEVIEW_SetTextColor (hwnd, wParam, lParam);
     3454
     3455        case TVM_GETBKCOLOR:
     3456                return TREEVIEW_GetBkColor (hwnd);
     3457
     3458        case TVM_GETTEXTCOLOR:
     3459                return TREEVIEW_GetTextColor (hwnd);
     3460
     3461        case TVM_SETSCROLLTIME:
     3462//                      FIXME (treeview, "Unimplemented msg TVM_SETSCROLLTIME\n");
     3463                return 0;
     3464
     3465        case TVM_GETSCROLLTIME:
     3466//                      FIXME (treeview, "Unimplemented msg TVM_GETSCROLLTIME\n");
     3467                return 0;
     3468
     3469        case TVM_SETINSERTMARKCOLOR:
     3470//                      FIXME (treeview, "Unimplemented msg TVM_SETINSERTMARKCOLOR\n");
     3471                return 0;
     3472
     3473        case TVM_SETUNICODEFORMAT:
     3474//                      FIXME (treeview, "Unimplemented msg TVM_SETUNICODEFORMAT\n");
     3475                return 0;
     3476
     3477        case TVM_GETUNICODEFORMAT:
     3478//                      FIXME (treeview, "Unimplemented msg TVM_GETUNICODEFORMAT\n");
     3479                return 0;
     3480
     3481                case WM_COMMAND:
     3482                        return TREEVIEW_Command (hwnd, wParam, lParam);
     3483
     3484                case WM_CREATE:
     3485                        return TREEVIEW_Create (hwnd, wParam, lParam);
     3486
     3487                case WM_DESTROY:
     3488                        return TREEVIEW_Destroy (hwnd);
     3489
     3490/*              case WM_ENABLE: */
     3491
     3492                case WM_ERASEBKGND:
     3493                        return TREEVIEW_EraseBackground (hwnd, wParam, lParam);
     3494
     3495                case WM_GETDLGCODE:
     3496                return DLGC_WANTARROWS | DLGC_WANTCHARS;
     3497
     3498                case WM_PAINT:
     3499                return TREEVIEW_Paint (hwnd, wParam, lParam);
     3500
     3501                case WM_GETFONT:
     3502                return TREEVIEW_GetFont (hwnd, wParam, lParam);
     3503
     3504                case WM_SETFONT:
     3505                return TREEVIEW_SetFont (hwnd, wParam, lParam);
     3506
     3507                case WM_KEYDOWN:
     3508                        return TREEVIEW_KeyDown (hwnd, wParam, lParam);
     3509
     3510
     3511                case WM_SETFOCUS:
     3512                        return TREEVIEW_SetFocus (hwnd, wParam, lParam);
     3513
     3514                case WM_KILLFOCUS:
     3515                        return TREEVIEW_KillFocus (hwnd, wParam, lParam);
     3516
     3517
     3518                case WM_LBUTTONDOWN:
     3519                        return TREEVIEW_LButtonDown (hwnd, wParam, lParam);
     3520
     3521                case WM_LBUTTONUP:
     3522                        return TREEVIEW_LButtonUp (hwnd, wParam, lParam);
     3523
     3524                case WM_LBUTTONDBLCLK:
     3525                        return TREEVIEW_LButtonDoubleClick (hwnd, wParam, lParam);
     3526
     3527                case WM_RBUTTONDOWN:
     3528                        return TREEVIEW_RButtonDown (hwnd, wParam, lParam);
     3529
     3530                case WM_RBUTTONUP:
     3531                        return TREEVIEW_RButtonUp (hwnd, wParam, lParam);
     3532
     3533                case WM_MOUSEMOVE:
     3534                        return TREEVIEW_MouseMove (hwnd, wParam, lParam);
     3535
     3536
     3537/*              case WM_SYSCOLORCHANGE: */
     3538                case WM_STYLECHANGED:
     3539                        return TREEVIEW_StyleChanged (hwnd, wParam, lParam);
     3540
     3541/*              case WM_SETREDRAW: */
     3542
     3543                case WM_TIMER:
     3544                        return TREEVIEW_HandleTimer (hwnd, wParam, lParam);
     3545
     3546                case WM_SIZE:
     3547                        return TREEVIEW_Size (hwnd, wParam,lParam);
     3548
     3549                case WM_HSCROLL:
     3550                        return TREEVIEW_HScroll (hwnd, wParam, lParam);
     3551                case WM_VSCROLL:
     3552                        return TREEVIEW_VScroll (hwnd, wParam, lParam);
     3553
     3554                case WM_DRAWITEM:
     3555//                      printf ("drawItem\n");
     3556                        return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     3557
     3558                default:
     3559//                if (uMsg >= WM_USER)
     3560//              FIXME (treeview, "Unknown msg %04x wp=%08x lp=%08lx\n",
     3561//                   uMsg, wParam, lParam);
     3562            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    35623563      }
    35633564    return 0;
     
    35823583    wndClass.hbrBackground = 0;
    35833584    wndClass.lpszClassName = WC_TREEVIEWA;
    3584  
     3585
    35853586    RegisterClassA (&wndClass);
    35863587}
     
    35913592{
    35923593    if (GlobalFindAtomA (WC_TREEVIEWA))
    3593         UnregisterClassA (WC_TREEVIEWA, (HINSTANCE)NULL);
    3594 }
    3595 
     3594        UnregisterClassA (WC_TREEVIEWA, (HINSTANCE)NULL);
     3595}
     3596
  • trunk/src/comctl32/updown.c

    r94 r110  
    1 /* $Id: updown.c,v 1.3 1999-06-10 16:22:04 achimha Exp $ */
    2 /*             
     1/* $Id: updown.c,v 1.4 1999-06-16 20:25:45 cbratschi Exp $ */
     2/*
    33 * Updown control
    44 *
    55 * Copyright 1997 Dimitrie O. Paun
    66 * Copyright 1999 Achim Hasenmueller
     7 * Copyright 1999 Christoph Bratschi
    78 *
    89 * TODO:
     
    6768//#define UNKNOWN_PARAM(msg, wParam, lParam) WARN(updown, \
    6869//        "UpDown Ctrl: Unknown parameter(s) for message " #msg     \
    69 //      "(%04x): wp=%04x lp=%08lx\n", msg, wParam, lParam);
     70//      "(%04x): wp=%04x lp=%08lx\n", msg, wParam, lParam);
    7071#define UNKNOWN_PARAM(msg, wParam, lParam)
    7172
     
    101102    {
    102103      delta += (delta < 0 ? -1 : 1) *
    103         (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1) *
    104         (infoPtr->MinVal - infoPtr->MaxVal) +
    105         (delta < 0 ? 1 : -1);
     104        (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1) *
     105        (infoPtr->MinVal - infoPtr->MaxVal) +
     106        (delta < 0 ? 1 : -1);
    106107    }
    107108    else
     
    119120 * incr     - TRUE  get the "increment" rect (up or right)
    120121 *            FALSE get the "decrement" rect (down or left)
    121  *         
     122 *
    122123 */
    123124static void UPDOWN_GetArrowRect (HWND hwnd, RECT *rect, BOOL incr)
     
    130131    len = rect->right - rect->left; /* compute the width */
    131132    if (incr)
    132       rect->left = len/2+1; 
     133      rect->left = len/2+1;
    133134    else
    134135      rect->right = len/2;
     
    169170  char sep[2];
    170171
    171   if(GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, 
    172                       sep, sizeof(sep)) != 1)
     172  if(GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND,
     173                      sep, sizeof(sep)) != 1)
    173174    return ',';
    174175
     
    204205      return FALSE;
    205206
    206     sep = UPDOWN_GetThousandSep(); 
     207    sep = UPDOWN_GetThousandSep();
    207208
    208209    /* now get rid of the separators */
    209210    for(src = dst = txt; *src; src++)
    210211      if(*src != sep)
    211         *dst++ = *src;
     212        *dst++ = *src;
    212213    *dst = 0;
    213214
    214215    /* try to convert the number and validate it */
    215216    newVal = strtol(txt, &src, infoPtr->Base);
    216     if(*src || !UPDOWN_InBounds (hwnd, newVal)) 
     217    if(*src || !UPDOWN_InBounds (hwnd, newVal))
    217218      return FALSE;
    218219
    219 //    TRACE(updown, "new value(%d) read from buddy (old=%d)\n", 
    220 //              newVal, infoPtr->CurVal);
    221   }
    222  
     220//    TRACE(updown, "new value(%d) read from buddy (old=%d)\n",
     221//              newVal, infoPtr->CurVal);
     222  }
     223
    223224  infoPtr->CurVal = newVal;
    224225  return TRUE;
     
    239240  int len;
    240241
    241   if (!IsWindow(infoPtr->Buddy)) 
     242  if (!IsWindow(infoPtr->Buddy))
    242243    return FALSE;
    243244
    244245//  TRACE(updown, "set new value(%d) to buddy.\n",
    245 //             infoPtr->CurVal);
     246//             infoPtr->CurVal);
    246247
    247248  /*if the buddy is a list window, we must set curr index */
     
    252253    len = sprintf(txt1, (infoPtr->Base==16) ? "%X" : "%d", infoPtr->CurVal);
    253254
    254     sep = UPDOWN_GetThousandSep(); 
     255    sep = UPDOWN_GetThousandSep();
    255256
    256257    /* Do thousands seperation if necessary */
     
    258259      char txt2[20], *src = txt1, *dst = txt2;
    259260      if(len%3 > 0){
    260         lstrcpynA (dst, src, len%3 + 1);      /* need to include the null */
    261         dst += len%3;
    262         src += len%3;
     261        lstrcpynA (dst, src, len%3 + 1);      /* need to include the null */
     262        dst += len%3;
     263        src += len%3;
    263264      }
    264265      for(len=0; *src; len++){
    265         if(len%3==0)
    266           *dst++ = sep;
    267         *dst++ = *src++;
     266        if(len%3==0)
     267          *dst++ = sep;
     268        *dst++ = *src++;
    268269      }
    269270      *dst = 0;           /* null terminate it */
     
    274275
    275276  return TRUE;
    276 } 
     277}
    277278
    278279/***********************************************************************
     
    287288  BOOL prssed;
    288289  RECT rect;
    289  
     290
    290291  /* Draw the incr button */
    291292  UPDOWN_GetArrowRect (hwnd, &rect, TRUE);
    292293  prssed = (infoPtr->Flags & FLAG_INCR) && (infoPtr->Flags & FLAG_MOUSEIN);
    293   DrawFrameControl(hdc, &rect, DFC_SCROLL, 
    294         (dwStyle & UDS_HORZ ? DFCS_SCROLLLEFT : DFCS_SCROLLUP) |
    295         (prssed ? DFCS_PUSHED : 0) |
    296         (dwStyle&WS_DISABLED ? DFCS_INACTIVE : 0) );
     294  DrawFrameControl(hdc, &rect, DFC_SCROLL,
     295        (dwStyle & UDS_HORZ ? DFCS_SCROLLLEFT : DFCS_SCROLLUP) |
     296        (prssed ? DFCS_PUSHED : 0) |
     297        (dwStyle&WS_DISABLED ? DFCS_INACTIVE : 0) );
    297298
    298299  /* Draw the space between the buttons */
    299300  rect.top = rect.bottom; rect.bottom++;
    300301  DrawEdge(hdc, &rect, 0, BF_MIDDLE);
    301                    
     302
    302303  /* Draw the decr button */
    303304  UPDOWN_GetArrowRect(hwnd, &rect, FALSE);
    304305  prssed = (infoPtr->Flags & FLAG_DECR) && (infoPtr->Flags & FLAG_MOUSEIN);
    305   DrawFrameControl(hdc, &rect, DFC_SCROLL, 
    306         (dwStyle & UDS_HORZ ? DFCS_SCROLLRIGHT : DFCS_SCROLLDOWN) |
    307         (prssed ? DFCS_PUSHED : 0) |
    308         (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
     306  DrawFrameControl(hdc, &rect, DFC_SCROLL,
     307        (dwStyle & UDS_HORZ ? DFCS_SCROLLRIGHT : DFCS_SCROLLDOWN) |
     308        (prssed ? DFCS_PUSHED : 0) |
     309        (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
    309310}
    310311
     
    318319{
    319320    HDC hdc;
    320  
     321
    321322    hdc = GetDC (hwnd);
    322323    UPDOWN_Draw (hwnd, hdc);
     
    335336    PAINTSTRUCT ps;
    336337    HDC hdc;
    337  
     338
    338339    hdc = BeginPaint (hwnd, &ps);
    339340    UPDOWN_Draw (hwnd, hdc);
     
    345346 * Tests if 'hwndBud' is a valid window handle. If not, returns FALSE.
    346347 * Else, sets it as a new Buddy.
    347  * Then, it should subclass the buddy 
     348 * Then, it should subclass the buddy
    348349 * If window has the UDS_ARROWKEYS, it subcalsses the buddy window to
    349350 * process the UP/DOWN arrow keys.
     
    353354static BOOL UPDOWN_SetBuddy (HWND hwnd, HWND hwndBud)
    354355{
    355   UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd); 
     356  UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
    356357  DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    357358  RECT budRect; /* new coord for the buddy */
    358359  int x;          /* new x position and width for the up-down */
    359          
     360
    360361  *infoPtr->szBuddyClass = '\0';
    361362
     
    380381  GetWindowRect(infoPtr->Buddy, &budRect);
    381382  MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Buddy),
    382                   (POINT *)(&budRect.left), 2);
     383                  (POINT *)(&budRect.left), 2);
    383384
    384385  /* now do the positioning */
     
    394395  /* first adjust the buddy to accomodate the up/down */
    395396  SetWindowPos(infoPtr->Buddy, 0, budRect.left, budRect.top,
    396                budRect.right  - budRect.left, budRect.bottom - budRect.top,
    397                SWP_NOACTIVATE|SWP_NOZORDER);
     397               budRect.right  - budRect.left, budRect.bottom - budRect.top,
     398               SWP_NOACTIVATE|SWP_NOZORDER);
    398399
    399400  /* now position the up/down */
     
    402403
    403404  SetWindowPos (hwnd, 0, x, budRect.top-DEFAULT_ADDTOP,DEFAULT_WIDTH,
    404                 (budRect.bottom-budRect.top)+DEFAULT_ADDTOP+DEFAULT_ADDBOT,
    405                 SWP_NOACTIVATE|SWP_NOZORDER);
     405                (budRect.bottom-budRect.top)+DEFAULT_ADDTOP+DEFAULT_ADDBOT,
     406                SWP_NOACTIVATE|SWP_NOZORDER);
    406407
    407408  return TRUE;
    408 }         
     409}
    409410
    410411/***********************************************************************
    411412 *           UPDOWN_DoAction
    412413 *
    413  * This function increments/decrements the CurVal by the 
     414 * This function increments/decrements the CurVal by the
    414415 * 'delta' amount according to the 'incr' flag
    415416 * It notifies the parent as required.
     
    419420static void UPDOWN_DoAction (HWND hwnd, int delta, BOOL incr)
    420421{
    421   UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd); 
     422  UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
    422423  DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    423424  int old_val = infoPtr->CurVal;
     
    440441  ni.hdr.hwndFrom = hwnd;
    441442  ni.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    442   ni.hdr.code = UDN_DELTAPOS; 
     443  ni.hdr.code = UDN_DELTAPOS;
    443444  if (SendMessageA(GetParent (hwnd), WM_NOTIFY,
    444                    (WPARAM)ni.hdr.idFrom, (LPARAM)&ni))
     445                   (WPARAM)ni.hdr.idFrom, (LPARAM)&ni))
    445446    return; /* we are not allowed to change */
    446  
     447
    447448  /* Now adjust value with (maybe new) delta */
    448449  if (!UPDOWN_OffsetVal (hwnd, ni.iDelta))
     
    450451
    451452  /* Now take care about our buddy */
    452   if(!IsWindow(infoPtr->Buddy)) 
     453  if(!IsWindow(infoPtr->Buddy))
    453454    return; /* Nothing else to do */
    454455
     
    461462            we do not have the UDS_SETBUDDYINT style set? */
    462463
    463   SendMessageA (GetParent (hwnd), 
    464                 dwStyle & UDS_HORZ ? WM_HSCROLL : WM_VSCROLL,
    465                 MAKELONG(incr ? SB_LINEUP : SB_LINEDOWN, infoPtr->CurVal),
    466                 hwnd);
     464  SendMessageA (GetParent (hwnd),
     465                dwStyle & UDS_HORZ ? WM_HSCROLL : WM_VSCROLL,
     466                MAKELONG(incr ? SB_LINEUP : SB_LINEDOWN, infoPtr->CurVal),
     467                hwnd);
    467468}
    468469
     
    487488 * Deletes any timers, releases the mouse and does  redraw if necessary.
    488489 * If the control is not in "capture" mode, it does nothing.
    489  * If the control was not in cancel mode, it returns FALSE. 
     490 * If the control was not in cancel mode, it returns FALSE.
    490491 * If the control was in cancel mode, it returns TRUE.
    491492 */
     
    493494{
    494495  UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
    495  
     496
    496497  /* if not in 'capture' mode, do nothing */
    497498  if(!(infoPtr->Flags & FLAG_CLICKED))
     
    500501  KillTimer (hwnd, TIMERID1); /* kill all possible timers */
    501502  KillTimer (hwnd, TIMERID2);
    502  
     503
    503504  if (GetCapture() == hwnd)    /* let the mouse go         */
    504     ReleaseCapture();          /* if we still have it      */ 
    505  
     505    ReleaseCapture();          /* if we still have it      */
     506
    506507  infoPtr->Flags = 0;          /* get rid of any flags     */
    507508  UPDOWN_Refresh (hwnd);       /* redraw the control just in case */
    508  
     509
    509510  return TRUE;
    510511}
     
    515516 * Handle a mouse event for the updown.
    516517 * 'pt' is the location of the mouse event in client or
    517  * windows coordinates. 
     518 * windows coordinates.
    518519 */
    519520static void UPDOWN_HandleMouseEvent (HWND hwnd, UINT msg, POINT pt)
     
    529530      /* If we are already in the 'clicked' mode, then nothing to do */
    530531      if(infoPtr->Flags & FLAG_CLICKED)
    531         return;
     532        return;
    532533
    533534      /* If the buddy is an edit, will set focus to it */
    534535      if (!lstrcmpA (infoPtr->szBuddyClass, "Edit"))
    535         SetFocus(infoPtr->Buddy);
     536        SetFocus(infoPtr->Buddy);
    536537
    537538      /* Now see which one is the 'active' arrow */
     
    540541      /* Update the CurVal if necessary */
    541542      if (dwStyle & UDS_SETBUDDYINT)
    542         UPDOWN_GetBuddyInt (hwnd);
    543        
     543        UPDOWN_GetBuddyInt (hwnd);
     544
    544545      /* Before we proceed, see if we can spin... */
    545546      if(!(dwStyle & UDS_WRAP))
    546         if(( temp && infoPtr->CurVal==infoPtr->MaxVal) ||
    547            (!temp && infoPtr->CurVal==infoPtr->MinVal))
    548           return;
     547        if(( temp && infoPtr->CurVal==infoPtr->MaxVal) ||
     548           (!temp && infoPtr->CurVal==infoPtr->MinVal))
     549          return;
    549550
    550551      /* Set up the correct flags */
    551       infoPtr->Flags  = 0; 
     552      infoPtr->Flags  = 0;
    552553      infoPtr->Flags |= temp ? FLAG_INCR : FLAG_DECR;
    553554      infoPtr->Flags |= FLAG_MOUSEIN;
    554      
     555
    555556      /* repaint the control */
    556557      UPDOWN_Refresh (hwnd);
     
    563564
    564565      /* and startup the first timer */
    565       SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 
     566      SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0);
    566567      break;
    567568
     
    569570      /* If we are not in the 'clicked' mode, then nothing to do */
    570571      if(!(infoPtr->Flags & FLAG_CLICKED))
    571         return;
     572        return;
    572573
    573574      /* save the flags to see if any got modified */
     
    576577      /* Now get the 'active' arrow rectangle */
    577578      if (infoPtr->Flags & FLAG_INCR)
    578         UPDOWN_GetArrowRect (hwnd, &rect, TRUE);
     579        UPDOWN_GetArrowRect (hwnd, &rect, TRUE);
    579580      else
    580         UPDOWN_GetArrowRect (hwnd, &rect, FALSE);
     581        UPDOWN_GetArrowRect (hwnd, &rect, FALSE);
    581582
    582583      /* Update the flags if we are in/out */
    583584      if(PtInRect(&rect, pt))
    584         infoPtr->Flags |=  FLAG_MOUSEIN;
     585        infoPtr->Flags |=  FLAG_MOUSEIN;
    585586      else{
    586         infoPtr->Flags &= ~FLAG_MOUSEIN;
    587         if(accelIndex != -1) /* if we have accel info */
    588           accelIndex = 0;    /* reset it              */
     587        infoPtr->Flags &= ~FLAG_MOUSEIN;
     588        if(accelIndex != -1) /* if we have accel info */
     589          accelIndex = 0;    /* reset it              */
    589590      }
    590591      /* If state changed, redraw the control */
    591592      if(temp != infoPtr->Flags)
    592         UPDOWN_Refresh (hwnd);
     593        UPDOWN_Refresh (hwnd);
    593594      break;
    594595
    595596      default:
    596 //      ERR(updown, "Impossible case!\n");
     597//      ERR(updown, "Impossible case!\n");
    597598        break;
    598599    }
     
    604605 */
    605606LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam,
    606                                 LPARAM lParam)
     607                                LPARAM lParam)
    607608{
    608609  UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
     
    622623
    623624      /* initialize the info struct */
    624       infoPtr->AccelCount=0; infoPtr->AccelVect=0; 
     625      infoPtr->AccelCount=0; infoPtr->AccelVect=0;
    625626      infoPtr->CurVal=0; infoPtr->MinVal=0; infoPtr->MaxVal=100; /*FIXME*/
    626627      infoPtr->Base  = 10; /* Default to base 10  */
     
    630631      /* Do we pick the buddy win ourselves? */
    631632      if (dwStyle & UDS_AUTOBUDDY)
    632         UPDOWN_SetBuddy (hwnd, GetWindow (hwnd, GW_HWNDPREV));
    633        
     633        UPDOWN_SetBuddy (hwnd, GetWindow (hwnd, GW_HWNDPREV));
     634
    634635//      TRACE(updown, "UpDown Ctrl creation, hwnd=%04x\n", hwnd);
    635636      break;
    636    
     637
    637638    case WM_DESTROY:
    638639      if(infoPtr->AccelVect)
    639         COMCTL32_Free (infoPtr->AccelVect);
     640        COMCTL32_Free (infoPtr->AccelVect);
    640641
    641642      COMCTL32_Free (infoPtr);
     
    643644//      TRACE(updown, "UpDown Ctrl destruction, hwnd=%04x\n", hwnd);
    644645      break;
    645        
     646
    646647    case WM_ENABLE:
    647648      if (dwStyle & WS_DISABLED)
    648         UPDOWN_CancelMode (hwnd);
     649        UPDOWN_CancelMode (hwnd);
    649650      UPDOWN_Paint (hwnd);
    650651      break;
     
    653654      /* if initial timer, kill it and start the repeat timer */
    654655      if(wParam == TIMERID1){
    655         KillTimer(hwnd, TIMERID1);
    656         /* if no accel info given, used default timer */
    657         if(infoPtr->AccelCount==0 || infoPtr->AccelVect==0){
    658           accelIndex = -1;
    659           temp = REPEAT_DELAY;
    660         }
    661         else{
    662           accelIndex = 0; /* otherwise, use it */
    663           temp = infoPtr->AccelVect[accelIndex].nSec * 1000 + 1;
    664         }
    665         SetTimer(hwnd, TIMERID2, temp, 0);
     656        KillTimer(hwnd, TIMERID1);
     657        /* if no accel info given, used default timer */
     658        if(infoPtr->AccelCount==0 || infoPtr->AccelVect==0){
     659          accelIndex = -1;
     660          temp = REPEAT_DELAY;
     661        }
     662        else{
     663          accelIndex = 0; /* otherwise, use it */
     664          temp = infoPtr->AccelVect[accelIndex].nSec * 1000 + 1;
     665        }
     666        SetTimer(hwnd, TIMERID2, temp, 0);
    666667      }
    667668
    668669      /* now, if the mouse is above us, do the thing...*/
    669670      if(infoPtr->Flags & FLAG_MOUSEIN){
    670         temp = accelIndex==-1 ? 1 : infoPtr->AccelVect[accelIndex].nInc;
    671         UPDOWN_DoAction(hwnd, temp, infoPtr->Flags & FLAG_INCR);
    672        
    673         if(accelIndex!=-1 && accelIndex < infoPtr->AccelCount-1){
    674           KillTimer(hwnd, TIMERID2);
    675           accelIndex++; /* move to the next accel info */
    676           temp = infoPtr->AccelVect[accelIndex].nSec * 1000 + 1;
    677           /* make sure we have at least 1ms intervals */
    678           SetTimer(hwnd, TIMERID2, temp, 0);       
    679         }
     671        temp = accelIndex==-1 ? 1 : infoPtr->AccelVect[accelIndex].nInc;
     672        UPDOWN_DoAction(hwnd, temp, infoPtr->Flags & FLAG_INCR);
     673
     674        if(accelIndex!=-1 && accelIndex < infoPtr->AccelCount-1){
     675          KillTimer(hwnd, TIMERID2);
     676          accelIndex++; /* move to the next accel info */
     677          temp = infoPtr->AccelVect[accelIndex].nSec * 1000 + 1;
     678          /* make sure we have at least 1ms intervals */
     679          SetTimer(hwnd, TIMERID2, temp, 0);
     680        }
    680681      }
    681682      break;
     
    687688    case WM_LBUTTONUP:
    688689      if(!UPDOWN_CancelMode(hwnd))
    689         break;
     690        break;
    690691      /*If we released the mouse and our buddy is an edit */
    691692      /* we must select all text in it.                   */
    692693      if (!lstrcmpA (infoPtr->szBuddyClass, "Edit"))
    693           SendMessageA(infoPtr->Buddy, EM_SETSEL, 0, MAKELONG(0, -1));
    694       break;
    695      
     694          SendMessageA(infoPtr->Buddy, EM_SETSEL, 0, MAKELONG(0, -1));
     695      break;
     696
    696697    case WM_LBUTTONDOWN:
    697698    case WM_MOUSEMOVE:
    698699      if(UPDOWN_IsEnabled(hwnd)){
    699         POINT pt;
    700         CONV_POINT16TO32( (POINT16 *)&lParam, &pt );
    701         UPDOWN_HandleMouseEvent (hwnd, message, pt );
     700        POINT pt;
     701        CONV_POINT16TO32( (POINT16 *)&lParam, &pt );
     702        UPDOWN_HandleMouseEvent (hwnd, message, pt );
    702703      }
    703704    break;
     
    705706    case WM_KEYDOWN:
    706707      if((dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(hwnd)){
    707         switch(wParam){
    708         case VK_UP: 
    709         case VK_DOWN:
    710           UPDOWN_GetBuddyInt (hwnd);
    711           UPDOWN_DoAction (hwnd, 1, wParam==VK_UP);
    712           break;
    713         }
    714       }
    715       break;
    716      
     708        switch(wParam){
     709        case VK_UP:
     710        case VK_DOWN:
     711          UPDOWN_GetBuddyInt (hwnd);
     712          UPDOWN_DoAction (hwnd, 1, wParam==VK_UP);
     713          break;
     714        }
     715      }
     716      break;
     717
    717718    case WM_PAINT:
    718719      UPDOWN_Paint (hwnd);
    719720      break;
    720    
     721
    721722    case UDM_GETACCEL:
    722723      if (wParam==0 && lParam==0)    /*if both zero, */
    723         return infoPtr->AccelCount;  /*just return the accel count*/
     724        return infoPtr->AccelCount;  /*just return the accel count*/
    724725      if (wParam || lParam){
    725         UNKNOWN_PARAM(UDM_GETACCEL, wParam, lParam);
    726         return 0;
     726        UNKNOWN_PARAM(UDM_GETACCEL, wParam, lParam);
     727        return 0;
    727728      }
    728729      temp = MIN(infoPtr->AccelCount, wParam);
     
    733734//      TRACE(updown, "UpDown Ctrl new accel info, hwnd=%04x\n", hwnd);
    734735      if(infoPtr->AccelVect){
    735         COMCTL32_Free (infoPtr->AccelVect);
    736         infoPtr->AccelCount = 0;
    737         infoPtr->AccelVect  = 0;
     736        COMCTL32_Free (infoPtr->AccelVect);
     737        infoPtr->AccelCount = 0;
     738        infoPtr->AccelVect  = 0;
    738739      }
    739740      if(wParam==0)
    740         return TRUE;
     741        return TRUE;
    741742      infoPtr->AccelVect = COMCTL32_Alloc (wParam*sizeof(UDACCEL));
    742743      if(infoPtr->AccelVect==0)
    743         return FALSE;
     744        return FALSE;
    744745      memcpy(infoPtr->AccelVect, (void*)lParam, wParam*sizeof(UDACCEL));
    745746      return TRUE;
     
    747748    case UDM_GETBASE:
    748749      if (wParam || lParam)
    749         UNKNOWN_PARAM(UDM_GETBASE, wParam, lParam);
     750        UNKNOWN_PARAM(UDM_GETBASE, wParam, lParam);
    750751      return infoPtr->Base;
    751752
    752753    case UDM_SETBASE:
    753 //      TRACE(updown, "UpDown Ctrl new base(%d), hwnd=%04x\n", 
    754 //                   wParam, hwnd);
     754//      TRACE(updown, "UpDown Ctrl new base(%d), hwnd=%04x\n",
     755//                   wParam, hwnd);
    755756      if ( !(wParam==10 || wParam==16) || lParam)
    756         UNKNOWN_PARAM(UDM_SETBASE, wParam, lParam);
     757        UNKNOWN_PARAM(UDM_SETBASE, wParam, lParam);
    757758      if (wParam==10 || wParam==16){
    758         temp = infoPtr->Base;
    759         infoPtr->Base = wParam;
    760         return temp;       /* return the prev base */
     759        temp = infoPtr->Base;
     760        infoPtr->Base = wParam;
     761        return temp;       /* return the prev base */
    761762      }
    762763      break;
     
    764765    case UDM_GETBUDDY:
    765766      if (wParam || lParam)
    766         UNKNOWN_PARAM(UDM_GETBUDDY, wParam, lParam);
     767        UNKNOWN_PARAM(UDM_GETBUDDY, wParam, lParam);
    767768      return infoPtr->Buddy;
    768769
    769770    case UDM_SETBUDDY:
    770771      if (lParam)
    771         UNKNOWN_PARAM(UDM_SETBUDDY, wParam, lParam);
     772        UNKNOWN_PARAM(UDM_SETBUDDY, wParam, lParam);
    772773      temp = infoPtr->Buddy;
    773774      infoPtr->Buddy = wParam;
    774775      UPDOWN_SetBuddy (hwnd, wParam);
    775 //      TRACE(updown, "UpDown Ctrl new buddy(%04x), hwnd=%04x\n", 
    776 //                   infoPtr->Buddy, hwnd);
     776//      TRACE(updown, "UpDown Ctrl new buddy(%04x), hwnd=%04x\n",
     777//                   infoPtr->Buddy, hwnd);
    777778      return temp;
    778779
    779780    case UDM_GETPOS:
    780781      if (wParam || lParam)
    781         UNKNOWN_PARAM(UDM_GETPOS, wParam, lParam);
     782        UNKNOWN_PARAM(UDM_GETPOS, wParam, lParam);
    782783      temp = UPDOWN_GetBuddyInt (hwnd);
    783784      return MAKELONG(infoPtr->CurVal, temp ? 0 : 1);
     
    785786    case UDM_SETPOS:
    786787      if (wParam || HIWORD(lParam))
    787         UNKNOWN_PARAM(UDM_GETPOS, wParam, lParam);
     788        UNKNOWN_PARAM(UDM_GETPOS, wParam, lParam);
    788789      temp = SLOWORD(lParam);
    789790//      TRACE(updown, "UpDown Ctrl new value(%d), hwnd=%04x\n",
    790 //                   temp, hwnd);
     791//                   temp, hwnd);
    791792      if(!UPDOWN_InBounds(hwnd, temp)){
    792         if(temp < infoPtr->MinVal) 
    793           temp = infoPtr->MinVal;
    794         if(temp > infoPtr->MaxVal)
    795           temp = infoPtr->MaxVal;
     793        if(temp < infoPtr->MinVal)
     794          temp = infoPtr->MinVal;
     795        if(temp > infoPtr->MaxVal)
     796          temp = infoPtr->MaxVal;
    796797      }
    797798      wParam = infoPtr->CurVal; /* save prev value   */
    798799      infoPtr->CurVal = temp;   /* set the new value */
    799800      if(dwStyle & UDS_SETBUDDYINT)
    800         UPDOWN_SetBuddyInt (hwnd);
     801        UPDOWN_SetBuddyInt (hwnd);
    801802      return wParam;            /* return prev value */
    802      
     803
    803804    case UDM_GETRANGE:
    804805      if (wParam || lParam)
    805         UNKNOWN_PARAM(UDM_GETRANGE, wParam, lParam);
     806        UNKNOWN_PARAM(UDM_GETRANGE, wParam, lParam);
    806807      return MAKELONG(infoPtr->MaxVal, infoPtr->MinVal);
    807808
    808809    case UDM_SETRANGE:
    809810      if (wParam)
    810         UNKNOWN_PARAM(UDM_SETRANGE, wParam, lParam); /* we must have:     */
     811        UNKNOWN_PARAM(UDM_SETRANGE, wParam, lParam); /* we must have:     */
    811812      infoPtr->MaxVal = SLOWORD(lParam); /* UD_MINVAL <= Max <= UD_MAXVAL */
    812813      infoPtr->MinVal = SHIWORD(lParam); /* UD_MINVAL <= Min <= UD_MAXVAL */
    813814                                         /* |Max-Min| <= UD_MAXVAL        */
    814 //      TRACE(updown, "UpDown Ctrl new range(%d to %d), hwnd=%04x\n", 
    815 //                   infoPtr->MinVal, infoPtr->MaxVal, hwnd);
    816       break;                             
     815//      TRACE(updown, "UpDown Ctrl new range(%d to %d), hwnd=%04x\n",
     816//                   infoPtr->MinVal, infoPtr->MaxVal, hwnd);
     817      break;
    817818
    818819    case UDM_GETRANGE32:
    819820      if (wParam)
    820         *(LPINT)wParam = infoPtr->MinVal;
     821        *(LPINT)wParam = infoPtr->MinVal;
    821822      if (lParam)
    822         *(LPINT)lParam = infoPtr->MaxVal;
     823        *(LPINT)lParam = infoPtr->MaxVal;
    823824      break;
    824825
     
    827828      infoPtr->MaxVal = (INT)lParam;
    828829      if (infoPtr->MaxVal <= infoPtr->MinVal)
    829         infoPtr->MaxVal = infoPtr->MinVal + 1;
    830 //      TRACE(updown, "UpDown Ctrl new range(%d to %d), hwnd=%04x\n", 
    831 //                   infoPtr->MinVal, infoPtr->MaxVal, hwnd);
    832       break;
    833 
    834     default: 
    835       if (message >= WM_USER)
    836 //      ERR (updown, "unknown msg %04x wp=%04x lp=%08lx\n",
    837 //           message, wParam, lParam);
    838       return DefWindowProcA (hwnd, message, wParam, lParam); 
    839     } 
     830        infoPtr->MaxVal = infoPtr->MinVal + 1;
     831//      TRACE(updown, "UpDown Ctrl new range(%d to %d), hwnd=%04x\n",
     832//                   infoPtr->MinVal, infoPtr->MaxVal, hwnd);
     833      break;
     834
     835    default:
     836//      if (message >= WM_USER)
     837//      ERR (updown, "unknown msg %04x wp=%04x lp=%08lx\n",
     838//           message, wParam, lParam);
     839      return DefWindowProcA (hwnd, message, wParam, lParam);
     840    }
    840841
    841842    return 0;
     
    844845
    845846/***********************************************************************
    846  *              UPDOWN_Register [Internal]
     847 *              UPDOWN_Register [Internal]
    847848 *
    848849 * Registers the updown window class.
     
    864865    wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
    865866    wndClass.lpszClassName = UPDOWN_CLASSA;
    866  
     867
    867868    RegisterClassA( &wndClass );
    868869}
     
    870871
    871872/***********************************************************************
    872  *              UPDOWN_Unregister       [Internal]
     873 *              UPDOWN_Unregister       [Internal]
    873874 *
    874875 * Unregisters the updown window class.
     
    879880{
    880881    if (GlobalFindAtomA (UPDOWN_CLASSA))
    881         UnregisterClassA (UPDOWN_CLASSA, (HINSTANCE)NULL);
    882 }
    883 
     882        UnregisterClassA (UPDOWN_CLASSA, (HINSTANCE)NULL);
     883}
     884
  • trunk/src/kernel32/winmod.cpp

    r99 r110  
    1 /* $Id: winmod.cpp,v 1.3 1999-06-10 19:09:05 phaller Exp $ */
     1/* $Id: winmod.cpp,v 1.4 1999-06-16 20:25:45 cbratschi Exp $ */
    22
    33/*
     
    6767    curnid = (NameId *)((char *)curnid + sizeof(NameId) + strlen(curnid->name));
    6868  }
     69
    6970  //try upper case search
    7071  //SvL: Copy it, since string might be located in readonly object
    71   upname = (char *)malloc(strlen(lpszName)+1);
     72
     73  upname = (char *)malloc(strlen(lpszName)+1); //CB: Trap with MFC Toolbar/UpDown samples
    7274  strcpy(upname, lpszName);
    7375  UpCase(upname);
Note: See TracChangeset for help on using the changeset viewer.