Ignore:
Timestamp:
Aug 6, 2000, 10:31:01 PM (25 years ago)
Author:
sandervl
Message:

put back old toolbar+tooltips code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/tooltips.cpp

    r3962 r3963  
    1 /* $Id: tooltips.cpp,v 1.9 2000-08-06 14:40:18 sandervl Exp $ */
     1/* $Id: tooltips.cpp,v 1.10 2000-08-06 20:28:29 sandervl Exp $ */
    22/*
    33 * Tool tip control
     
    88 *
    99 * TODO:
    10  *   - Unicode support (started).
    1110 *   - Custom draw support.
    1211 *
     
    1615 *     curtool.exe, deltool.exe, enumtools.exe, getinfo.exe, getiptxt.exe,
    1716 *     hittest.exe, needtext.exe, newrect.exe, updtext.exe and winfrpt.exe.
    18  *
    19  *   Timer logic.
    20  *
    21  * One important point to remember is that tools don't necessarily get
    22  * a WM_MOUSEMOVE once the cursor leaves the tool, an example is when
    23  * a tool sets TTF_IDISHWND (i.e. an entire window is a tool) because
    24  * here WM_MOUSEMOVEs only get sent when the cursor is inside the
    25  * client area.  Therefore the only reliable way to know that the
    26  * cursor has left a tool is to keep a timer running and check the
    27  * position every time it expires.  This is the role of timer
    28  * ID_TIMERLEAVE.
    29  *
    30  *
    31  * On entering a tool (detected in a relayed WM_MOUSEMOVE) we start
    32  * ID_TIMERSHOW, if this times out and we're still in the tool we show
    33  * the tip.  On showing a tip we start both ID_TIMERPOP and
    34  * ID_TIMERLEAVE.  On hiding a tooltip we kill ID_TIMERPOP.
    35  * ID_TIMERPOP is restarted on every relayed WM_MOUSEMOVE.  If
    36  * ID_TIMERPOP expires the tool is hidden and ID_TIMERPOP is killed.
    37  * ID_TIMERLEAVE remains running - this is important as we need to
    38  * determine when the cursor leaves the tool.
    39  *
    40  * When ID_TIMERLEAVE expires or on a relayed WM_MOUSEMOVE if we're
    41  * still in the tool do nothing (apart from restart ID_TIMERPOP if
    42  * this is a WM_MOUSEMOVE) (ID_TIMERLEAVE remains running).  If we've
    43  * left the tool and entered another one then hide the tip and start
    44  * ID_TIMERSHOW with time ReshowTime and kill ID_TIMERLEAVE.  If we're
    45  * outside all tools hide the tip and kill ID_TIMERLEAVE.  On Relayed
    46  * mouse button messages hide the tip but leave ID_TIMERLEAVE running,
    47  * this again will let us keep track of when the cursor leaves the
    48  * tool.
    49  *
    50  *
    51  * infoPtr->nTool is the tool the mouse was on on the last relayed MM
    52  * or timer expiry or -1 if the mouse was not on a tool.
    53  *
    54  * infoPtr->nCurrentTool is the tool for which the tip is currently
    55  * displaying text for or -1 if the tip is not shown.  Actually this
    56  * will only ever be infoPtr-nTool or -1, so it could be changed to a
    57  * BOOL.
    58  *
    5917 */
    6018
    6119/*
    62  - (WINE 20000801 level)
     20 - Corel WINE 20000513 level
     21 - (WINE 20000130 level)
    6322*/
    6423
    6524#include <string.h>
    6625
    67 #include "winnls.h"
    6826#include "winbase.h"
    6927#include "commctrl.h"
     
    7634#define ID_TIMERLEAVE  3    /* tool leave timer */
    7735
    78 #ifdef __WIN32OS2__
    79   #define FIXME
    80   #define TRACE
    81   #define WARN
    82   #define ERR
    83   #define debugstr_w
    84 #endif
    8536
    8637extern LPSTR COMCTL32_aSubclass; /* global subclassing atom */
     
    9445TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
    9546
    96 static VOID
    97 TOOLTIPS_Refresh (HWND hwnd, HDC hdc)
     47
     48static VOID TOOLTIPS_Draw (HWND hwnd, HDC hdc)
    9849{
    9950    TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
     
    10455    UINT uFlags = DT_EXTERNALLEADING;
    10556
     57    if (infoPtr->nMaxTipWidth > -1) uFlags |= DT_WORDBREAK;
     58    if (GetWindowLongA(hwnd,GWL_STYLE) & TTS_NOPREFIX) uFlags |= DT_NOPREFIX;
     59    GetClientRect(hwnd,&rc);
     60
     61    /* fill the background */
     62    hBrush = CreateSolidBrush(infoPtr->clrBk);
     63    FillRect(hdc,&rc,hBrush);
     64    DeleteObject(hBrush);
     65
     66    /* calculate text rectangle */
     67    rc.left   += (2+infoPtr->rcMargin.left);
     68    rc.top    += (2+infoPtr->rcMargin.top);
     69    rc.right  -= (2+infoPtr->rcMargin.right);
     70    rc.bottom -= (2+infoPtr->rcMargin.bottom);
     71
     72    /* draw text */
     73    oldBkMode = SetBkMode(hdc,TRANSPARENT);
     74    SetTextColor(hdc,infoPtr->clrText);
     75    hOldFont = SelectObject(hdc,infoPtr->hFont);
     76    DrawTextW(hdc,infoPtr->szTipText,-1,&rc,uFlags);
     77    SelectObject(hdc,hOldFont);
     78    if (oldBkMode != TRANSPARENT) SetBkMode(hdc,oldBkMode);
     79}
     80
     81static VOID TOOLTIPS_GetCallbackText(HWND hwnd,TOOLTIPS_INFO *infoPtr,TTTOOL_INFO *toolPtr)
     82{
     83  if (isUnicodeNotify(&infoPtr->header))
     84  {
     85    NMTTDISPINFOW ttnmdi;
     86
     87    /* fill NMHDR struct */
     88    ZeroMemory (&ttnmdi,sizeof(NMTTDISPINFOW));
     89    ttnmdi.hdr.hwndFrom = hwnd;
     90    ttnmdi.hdr.idFrom = toolPtr->uId;
     91    ttnmdi.hdr.code = TTN_GETDISPINFOW;
     92    ttnmdi.lpszText = (WCHAR*)&ttnmdi.szText;
     93    ttnmdi.uFlags = toolPtr->uFlags;
     94    ttnmdi.lParam = toolPtr->lParam;
     95    SendMessageA(toolPtr->hwnd,WM_NOTIFY,(WPARAM)toolPtr->uId,(LPARAM)&ttnmdi);
     96
     97    if ((ttnmdi.hinst) && (HIWORD((UINT)ttnmdi.lpszText) == 0))
     98    {
     99      LoadStringW(ttnmdi.hinst,(UINT)ttnmdi.lpszText,infoPtr->szTipText,INFOTIPSIZE);
     100      if (ttnmdi.uFlags & TTF_DI_SETITEM)
     101      {
     102        toolPtr->hinst = ttnmdi.hinst;
     103        toolPtr->lpszText = (LPWSTR)ttnmdi.lpszText;
     104      }
     105    } else
     106    {
     107      if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKW)
     108      {
     109        if (!HIWORD(ttnmdi.lpszText) && (ttnmdi.lpszText != NULL))
     110        {
     111          //error
     112          infoPtr->szTipText[0] = '\0';
     113          return;
     114        }
     115        lstrcpynW(infoPtr->szTipText,ttnmdi.lpszText,INFOTIPSIZE);
     116        if (ttnmdi.uFlags & TTF_DI_SETITEM)
     117        {
     118          INT len = lstrlenW(ttnmdi.lpszText);
     119          toolPtr->hinst = 0;
     120          toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
     121          lstrcpyW(toolPtr->lpszText,ttnmdi.lpszText);
     122        }
     123      } else
     124      {
     125        //ERR (tooltips, "recursive text callback!\n");
     126        infoPtr->szTipText[0] = '\0';
     127      }
     128    }
     129  } else
     130  {
     131    NMTTDISPINFOA ttnmdi;
     132
     133    /* fill NMHDR struct */
     134    ZeroMemory (&ttnmdi,sizeof(NMTTDISPINFOA));
     135    ttnmdi.hdr.hwndFrom = hwnd;
     136    ttnmdi.hdr.idFrom = toolPtr->uId;
     137    ttnmdi.hdr.code = TTN_GETDISPINFOA;
     138    ttnmdi.lpszText = (CHAR*)&ttnmdi.szText;
     139    ttnmdi.uFlags = toolPtr->uFlags;
     140    ttnmdi.lParam = toolPtr->lParam;
     141    SendMessageA(toolPtr->hwnd,WM_NOTIFY,(WPARAM)toolPtr->uId,(LPARAM)&ttnmdi);
     142
     143    if ((ttnmdi.hinst) && (HIWORD((UINT)ttnmdi.lpszText) == 0))
     144    {
     145      LoadStringW(ttnmdi.hinst,(UINT)ttnmdi.lpszText,infoPtr->szTipText,INFOTIPSIZE);
     146      if (ttnmdi.uFlags & TTF_DI_SETITEM)
     147      {
     148        toolPtr->hinst = ttnmdi.hinst;
     149        toolPtr->lpszText = (LPWSTR)ttnmdi.lpszText;
     150      }
     151    } else
     152    {
     153      if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA)
     154      {
     155        if (!HIWORD(ttnmdi.lpszText) && (ttnmdi.lpszText != NULL))
     156        {
     157          //error
     158          infoPtr->szTipText[0] = '\0';
     159          return;
     160        }
     161        lstrcpynAtoW(infoPtr->szTipText,ttnmdi.lpszText,INFOTIPSIZE);
     162        if (ttnmdi.uFlags & TTF_DI_SETITEM)
     163        {
     164          INT len = lstrlenA(ttnmdi.lpszText);
     165          toolPtr->hinst = 0;
     166          toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
     167          lstrcpyAtoW(toolPtr->lpszText,ttnmdi.lpszText);
     168        }
     169      } else
     170      {
     171        //ERR (tooltips, "recursive text callback!\n");
     172        infoPtr->szTipText[0] = '\0';
     173      }
     174    }
     175  }
     176}
     177
     178static VOID TOOLTIPS_GetTipText(HWND hwnd,TOOLTIPS_INFO *infoPtr,INT nTool)
     179{
     180    TTTOOL_INFO *toolPtr = &infoPtr->tools[nTool];
     181
     182    if ((toolPtr->hinst) && (HIWORD((UINT)toolPtr->lpszText) == 0))
     183    {
     184      /* load a resource */
     185
     186      LoadStringW(toolPtr->hinst,(UINT)toolPtr->lpszText,infoPtr->szTipText,INFOTIPSIZE);
     187    } else if (toolPtr->lpszText)
     188    {
     189      if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW)
     190        TOOLTIPS_GetCallbackText(hwnd,infoPtr,toolPtr);
     191      else
     192      {
     193        /* the item is a usual (unicode) text */
     194        lstrcpynW(infoPtr->szTipText,toolPtr->lpszText,INFOTIPSIZE);
     195      }
     196    } else
     197    {
     198      /* no text available */
     199      infoPtr->szTipText[0] = '\0';
     200    }
     201}
     202
     203static VOID
     204TOOLTIPS_CalcTipRect (HWND hwnd,TOOLTIPS_INFO *infoPtr,TTTOOL_INFO *toolPtr,LPRECT lpRect)
     205{
     206    HDC hdc;
     207    HFONT hOldFont;
     208    UINT uFlags = DT_EXTERNALLEADING | DT_CALCRECT;
     209    RECT rc = {0,0,0,0};
     210    SIZE size;
     211
    106212    if (infoPtr->nMaxTipWidth > -1)
    107         uFlags |= DT_WORDBREAK;
    108     if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX)
    109         uFlags |= DT_NOPREFIX;
    110     GetClientRect (hwnd, &rc);
    111 
    112     /* fill the background */
    113     hBrush = CreateSolidBrush (infoPtr->clrBk);
    114     FillRect (hdc, &rc, hBrush);
    115     DeleteObject (hBrush);
    116 
    117     /* calculate text rectangle */
    118     rc.left   += (2 + infoPtr->rcMargin.left);
    119     rc.top    += (2 + infoPtr->rcMargin.top);
    120     rc.right  -= (2 + infoPtr->rcMargin.right);
    121     rc.bottom -= (2 + infoPtr->rcMargin.bottom);
    122 
    123     /* draw text */
    124     oldBkMode = SetBkMode (hdc, TRANSPARENT);
    125     SetTextColor (hdc, infoPtr->clrText);
    126     hOldFont = SelectObject (hdc, infoPtr->hFont);
    127     DrawTextW (hdc, infoPtr->szTipText, -1, &rc, uFlags);
    128     SelectObject (hdc, hOldFont);
    129     if (oldBkMode != TRANSPARENT)
    130         SetBkMode (hdc, oldBkMode);
    131 }
    132 
    133 
    134 static VOID
    135 TOOLTIPS_GetTipText (HWND hwnd, TOOLTIPS_INFO *infoPtr, INT nTool)
    136 {
    137     TTTOOL_INFO *toolPtr = &infoPtr->tools[nTool];
    138 
    139     if ((toolPtr->hinst) && (HIWORD((UINT)toolPtr->lpszText) == 0)) {
    140         /* load a resource */
    141         TRACE("load res string %x %x\n",
    142                toolPtr->hinst, (int)toolPtr->lpszText);
    143         LoadStringW (toolPtr->hinst, (UINT)toolPtr->lpszText,
    144                        infoPtr->szTipText, INFOTIPSIZE);
    145     }
    146     else if (toolPtr->lpszText) {
    147         if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW) {
    148             NMTTDISPINFOA ttnmdi;
    149 
    150             /* fill NMHDR struct */
    151             ZeroMemory (&ttnmdi, sizeof(NMTTDISPINFOA));
    152             ttnmdi.hdr.hwndFrom = hwnd;
    153             ttnmdi.hdr.idFrom = toolPtr->uId;
    154             ttnmdi.hdr.code = TTN_GETDISPINFOA;
    155             ttnmdi.lpszText = (LPSTR)&ttnmdi.szText;
    156             ttnmdi.uFlags = toolPtr->uFlags;
    157             ttnmdi.lParam = toolPtr->lParam;
    158 
    159             TRACE("hdr.idFrom = %x\n", ttnmdi.hdr.idFrom);
    160             SendMessageA (toolPtr->hwnd, WM_NOTIFY,
    161                             (WPARAM)toolPtr->uId, (LPARAM)&ttnmdi);
    162 
    163             if ((ttnmdi.hinst) && (HIWORD((UINT)ttnmdi.lpszText) == 0)) {
    164                 LoadStringW (ttnmdi.hinst, (UINT)ttnmdi.lpszText,
    165                                infoPtr->szTipText, INFOTIPSIZE);
    166                 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
    167                     toolPtr->hinst = ttnmdi.hinst;
    168                     toolPtr->lpszText = (LPWSTR)ttnmdi.lpszText;
    169                 }
    170             }
    171             else if (ttnmdi.szText[0]) {
    172                 MultiByteToWideChar(CP_ACP, 0, ttnmdi.szText, 80,
    173                                     infoPtr->szTipText, INFOTIPSIZE);
    174                 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
    175                     INT len = MultiByteToWideChar(CP_ACP, 0, ttnmdi.szText,
    176                                                   80, NULL, 0);
    177                     toolPtr->hinst = 0;
    178                     toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc (len * sizeof(WCHAR));
    179                     MultiByteToWideChar(CP_ACP, 0, ttnmdi.szText, 80,
    180                                         toolPtr->lpszText, len);
    181                 }
    182             }
    183             else if (ttnmdi.lpszText == 0) {
    184                 /* no text available */
    185                 infoPtr->szTipText[0] = L'\0';
    186             }
    187             else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA) {
    188                 MultiByteToWideChar(CP_ACP, 0, ttnmdi.lpszText, -1,
    189                                     infoPtr->szTipText, INFOTIPSIZE);
    190                 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
    191                     INT len = MultiByteToWideChar(CP_ACP, 0, ttnmdi.lpszText,
    192                                                   -1, NULL, 0);
    193                     toolPtr->hinst = 0;
    194                     toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc (len * sizeof(WCHAR));
    195                     MultiByteToWideChar(CP_ACP, 0, ttnmdi.lpszText, -1,
    196                                         toolPtr->lpszText, len);
    197                 }
    198             }
    199             else {
    200                 ERR("recursive text callback!\n");
    201                 infoPtr->szTipText[0] = '\0';
    202             }
    203         }
    204         else {
    205             /* the item is a usual (unicode) text */
    206             lstrcpynW (infoPtr->szTipText, toolPtr->lpszText, INFOTIPSIZE);
    207         }
    208     }
    209     else {
    210         /* no text available */
    211         infoPtr->szTipText[0] = L'\0';
    212     }
    213 
    214     // TRACE("%s\n", debugstr_w(infoPtr->szTipText));
    215 }
    216 
     213    {
     214      rc.right = infoPtr->nMaxTipWidth;
     215      uFlags |= DT_WORDBREAK;
     216    }
     217    if (GetWindowLongA(hwnd,GWL_STYLE) & TTS_NOPREFIX) uFlags |= DT_NOPREFIX;
     218    //TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
     219
     220    hdc = GetDC(hwnd);
     221    hOldFont = SelectObject(hdc,infoPtr->hFont);
     222    DrawTextW(hdc,infoPtr->szTipText,-1,&rc,uFlags);
     223    SelectObject(hdc,hOldFont);
     224    ReleaseDC(hwnd,hdc);
     225
     226    size.cx = rc.right-rc.left+4+infoPtr->rcMargin.left+infoPtr->rcMargin.right;
     227    size.cy = rc.bottom-rc.top+4+infoPtr->rcMargin.bottom+infoPtr->rcMargin.top;
     228
     229    if (toolPtr->uFlags & TTF_ABSOLUTE)
     230    {
     231      rc.left = infoPtr->xTrackPos;
     232      rc.top  = infoPtr->yTrackPos;
     233
     234      if (toolPtr->uFlags & TTF_ALIGNMASK)
     235      {
     236        //CB: Odin only (Win32 does something similar but with an undocumented mechanism)
     237
     238        if (toolPtr->uFlags & TTF_ALIGNLEFT)
     239          rc.left -= size.cx;
     240        else if (toolPtr->uFlags & TTF_HCENTER)
     241          rc.left -= size.cx/2;
     242
     243        if (toolPtr->uFlags & TTF_ALIGNTOP)
     244          rc.top -= size.cy;
     245        else if (toolPtr->uFlags & TTF_VCENTER)
     246          rc.top -= size.cy/2;
     247
     248      } else
     249      {
     250        if (toolPtr->uFlags & TTF_CENTERTIP)
     251        {
     252          rc.left -= (size.cx/2);
     253          rc.top  -= (size.cy/2);
     254        }
     255      }
     256    } else
     257    {
     258      RECT rcTool;
     259
     260      if (toolPtr->uFlags & TTF_IDISHWND)
     261      {
     262        GetWindowRect((HWND)toolPtr->uId,&rcTool); //screen coordinates
     263      } else
     264      {
     265        rcTool = toolPtr->rect;
     266        MapWindowPoints(toolPtr->hwnd,(HWND)0,(LPPOINT)&rcTool,2);
     267      }
     268
     269      if (toolPtr->uFlags & TTF_CENTERTIP)
     270      {
     271        if (infoPtr->bTrackActive)
     272        {
     273          GetCursorPos((LPPOINT)&rc);
     274          rc.top += 20;
     275          rc.left -= (size.cx / 2);
     276          rc.top  -= (size.cy / 2);
     277        } else
     278        {
     279          rc.left = (rcTool.left + rcTool.right-size.cx)/ 2;
     280          rc.top  = rcTool.bottom+2;
     281        }
     282
     283      } else
     284      {
     285        GetCursorPos((LPPOINT)&rc);
     286        rc.top += 20;
     287      }
     288
     289      /* smart placement */
     290      if (infoPtr->bTrackActive)
     291      {
     292        if ((rc.left + size.cx > rcTool.left) && (rc.left < rcTool.right) &&
     293            (rc.top + size.cy > rcTool.top) && (rc.top < rcTool.bottom))
     294            rc.left = rcTool.right;
     295      }
     296    }
     297
     298    //TRACE (tooltips, "pos %d - %d\n", rect.left, rect.top);
     299
     300    rc.right = rc.left+size.cx;
     301    rc.bottom = rc.top+size.cy;
     302
     303    AdjustWindowRectEx (&rc,GetWindowLongA(hwnd,GWL_STYLE),
     304                        FALSE,GetWindowLongA(hwnd,GWL_EXSTYLE));
     305
     306    *lpRect = rc;
     307}
    217308
    218309static VOID
     
    225316
    226317    if (infoPtr->nMaxTipWidth > -1) {
    227         rc.right = infoPtr->nMaxTipWidth;
    228         uFlags |= DT_WORDBREAK;
     318        rc.right = infoPtr->nMaxTipWidth;
     319        uFlags |= DT_WORDBREAK;
    229320    }
    230321    if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX)
    231         uFlags |= DT_NOPREFIX;
    232     TRACE("%s\n", debugstr_w(infoPtr->szTipText));
     322        uFlags |= DT_NOPREFIX;
     323    //TRACE("\"%s\"\n", debugstr_w(infoPtr->szTipText));
    233324
    234325    hdc = GetDC (hwnd);
     
    238329    ReleaseDC (hwnd, hdc);
    239330
    240     lpSize->cx = rc.right - rc.left + 4 + 
    241                 infoPtr->rcMargin.left + infoPtr->rcMargin.right;
     331    lpSize->cx = rc.right - rc.left + 4 +
     332                infoPtr->rcMargin.left + infoPtr->rcMargin.right;
    242333    lpSize->cy = rc.bottom - rc.top + 4 +
    243                  infoPtr->rcMargin.bottom + infoPtr->rcMargin.top;
    244 }
    245 
     334                 infoPtr->rcMargin.bottom + infoPtr->rcMargin.top;
     335}
    246336
    247337static VOID
     
    251341    RECT rect, wndrect;
    252342    SIZE size;
     343    HDC  hdc;
    253344    NMHDR  hdr;
    254345
    255346    if (infoPtr->nTool == -1) {
    256         TRACE("invalid tool (-1)!\n");
    257         return;
     347//      TRACE("invalid tool (-1)!\n");
     348        return;
    258349    }
    259350
    260351    infoPtr->nCurrentTool = infoPtr->nTool;
    261352
    262     TRACE("Show tooltip pre %d! (%04x)\n", infoPtr->nTool, hwnd);
     353//    TRACE("Show tooltip pre %d!\n", infoPtr->nTool);
    263354
    264355    TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nCurrentTool);
    265356
    266357    if (infoPtr->szTipText[0] == L'\0') {
    267         infoPtr->nCurrentTool = -1;
    268         return;
    269     }
    270 
    271     TRACE("Show tooltip %d!\n", infoPtr->nCurrentTool);
     358        infoPtr->nCurrentTool = -1;
     359        return;
     360    }
     361
     362//    TRACE("Show tooltip %d!\n", infoPtr->nCurrentTool);
    272363    toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
    273364
     
    276367    hdr.code = TTN_SHOW;
    277368    SendMessageA (toolPtr->hwnd, WM_NOTIFY,
    278                     (WPARAM)toolPtr->uId, (LPARAM)&hdr);
    279 
    280     TRACE("%s\n", debugstr_w(infoPtr->szTipText));
     369                    (WPARAM)toolPtr->uId, (LPARAM)&hdr);
     370
     371//    TRACE("\"%s\"\n", debugstr_w(infoPtr->szTipText));
    281372
    282373    TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size);
    283     TRACE("size %d - %d\n", size.cx, size.cy);
     374//    TRACE("size %d - %d\n", size.cx, size.cy);
    284375
    285376    if (toolPtr->uFlags & TTF_CENTERTIP) {
    286         RECT rc;
    287 
    288         if (toolPtr->uFlags & TTF_IDISHWND)
    289             GetWindowRect ((HWND)toolPtr->uId, &rc);
    290         else {
    291             rc = toolPtr->rect;
    292             MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2);
    293         }
    294         rect.left = (rc.left + rc.right - size.cx) / 2;
    295         rect.top  = rc.bottom + 2;
     377        RECT rc;
     378
     379        if (toolPtr->uFlags & TTF_IDISHWND)
     380            GetWindowRect ((HWND)toolPtr->uId, &rc);
     381        else {
     382            rc = toolPtr->rect;
     383            MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2);
     384        }
     385        rect.left = (rc.left + rc.right - size.cx) / 2;
     386        rect.top  = rc.bottom + 2;
    296387    }
    297388    else {
    298         GetCursorPos ((LPPOINT)&rect);
    299         rect.top += 20;
    300     }
    301 
    302     TRACE("pos %d - %d\n", rect.left, rect.top);
     389        GetCursorPos ((LPPOINT)&rect);
     390        rect.top += 20;
     391    }
     392
     393//    TRACE("pos %d - %d\n", rect.left, rect.top);
    303394
    304395    rect.right = rect.left + size.cx;
     
    308399    wndrect.right = GetSystemMetrics( SM_CXSCREEN );
    309400    if( rect.right > wndrect.right ) {
    310            rect.left -= rect.right - wndrect.right + 2;
    311            rect.right = wndrect.right - 2;
     401           rect.left -= rect.right - wndrect.right + 2;
     402           rect.right = wndrect.right - 2;
    312403    }
    313404    wndrect.bottom = GetSystemMetrics( SM_CYSCREEN );
     
    315406        RECT rc;
    316407
    317         if (toolPtr->uFlags & TTF_IDISHWND)
    318             GetWindowRect ((HWND)toolPtr->uId, &rc);
    319         else {
    320             rc = toolPtr->rect;
    321             MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2);
    322         }   
    323         rect.bottom = rc.top - 2;
    324         rect.top = rect.bottom - size.cy;
     408        if (toolPtr->uFlags & TTF_IDISHWND)
     409            GetWindowRect ((HWND)toolPtr->uId, &rc);
     410        else {
     411            rc = toolPtr->rect;
     412            MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2);
     413        }
     414        rect.bottom = rc.top - 2;
     415        rect.top = rect.bottom - size.cy;
    325416    }
    326417
    327418    AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE),
    328                         FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE));
     419                        FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE));
    329420
    330421    SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top,
    331                     rect.right - rect.left, rect.bottom - rect.top,
    332                     SWP_SHOWWINDOW | SWP_NOACTIVATE);
     422                    rect.right - rect.left, rect.bottom - rect.top,
     423                    SWP_SHOWWINDOW | SWP_NOACTIVATE);
    333424
    334425    /* repaint the tooltip */
    335     InvalidateRect(hwnd, NULL, TRUE);
    336     UpdateWindow(hwnd);
     426    hdc = GetDC (hwnd);
     427    TOOLTIPS_Draw(hwnd, hdc);
     428    ReleaseDC (hwnd, hdc);
    337429
    338430    SetTimer (hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0);
    339     TRACE("timer 2 started!\n");
    340     SetTimer (hwnd, ID_TIMERLEAVE, infoPtr->nReshowTime, 0);
    341     TRACE("timer 3 started!\n");
    342431}
    343432
     
    349438    NMHDR hdr;
    350439
    351     TRACE("Hide tooltip %d! (%04x)\n", infoPtr->nCurrentTool, hwnd);
    352 
    353440    if (infoPtr->nCurrentTool == -1)
    354         return;
     441        return;
    355442
    356443    toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
     444    //TRACE (tooltips, "Hide tooltip %d!\n", infoPtr->nCurrentTool);
    357445    KillTimer (hwnd, ID_TIMERPOP);
    358446
     
    361449    hdr.code = TTN_POP;
    362450    SendMessageA (toolPtr->hwnd, WM_NOTIFY,
    363                     (WPARAM)toolPtr->uId, (LPARAM)&hdr);
     451                    (WPARAM)toolPtr->uId, (LPARAM)&hdr);
    364452
    365453    infoPtr->nCurrentTool = -1;
    366454
    367455    SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,
    368                     SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
     456                    SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
    369457}
    370458
     
    375463    TTTOOL_INFO *toolPtr;
    376464    RECT rect;
    377     SIZE size;
     465    HDC  hdc;
    378466    NMHDR hdr;
    379467
    380     if (infoPtr->nTrackTool == -1) {
    381         TRACE("invalid tracking tool (-1)!\n");
    382         return;
    383     }
    384 
    385     TRACE("show tracking tooltip pre %d!\n", infoPtr->nTrackTool);
    386 
    387     TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nTrackTool);
    388 
    389     if (infoPtr->szTipText[0] == L'\0') {
    390         infoPtr->nTrackTool = -1;
    391         return;
    392     }
    393 
    394     TRACE("show tracking tooltip %d!\n", infoPtr->nTrackTool);
     468    if (infoPtr->nTrackTool == -1)
     469    {
     470      //TRACE (tooltips, "invalid tracking tool (-1)!\n");
     471      return;
     472    }
     473
     474    //TRACE (tooltips, "show tracking tooltip pre %d!\n", infoPtr->nTrackTool);
     475
     476    TOOLTIPS_GetTipText(hwnd,infoPtr,infoPtr->nTrackTool);
     477
     478    if (infoPtr->szTipText[0] == '\0')
     479    {
     480      infoPtr->nTrackTool = -1;
     481      return;
     482    }
     483
     484    //TRACE (tooltips, "show tracking tooltip %d!\n", infoPtr->nTrackTool);
    395485    toolPtr = &infoPtr->tools[infoPtr->nTrackTool];
    396486
     
    398488    hdr.idFrom = toolPtr->uId;
    399489    hdr.code = TTN_SHOW;
    400     SendMessageA (toolPtr->hwnd, WM_NOTIFY,
    401                     (WPARAM)toolPtr->uId, (LPARAM)&hdr);
    402 
    403     TRACE("%s\n", debugstr_w(infoPtr->szTipText));
    404 
    405     TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size);
    406     TRACE("size %d - %d\n", size.cx, size.cy);
    407 
    408     if (toolPtr->uFlags & TTF_ABSOLUTE) {
    409         rect.left = infoPtr->xTrackPos;
    410         rect.top  = infoPtr->yTrackPos;
    411 
    412         if (toolPtr->uFlags & TTF_CENTERTIP) {
    413             rect.left -= (size.cx / 2);
    414             rect.top  -= (size.cy / 2);
    415         }
    416     }
    417     else {
    418         RECT rcTool;
    419 
    420         if (toolPtr->uFlags & TTF_IDISHWND)
    421             GetWindowRect ((HWND)toolPtr->uId, &rcTool);
    422         else {
    423             rcTool = toolPtr->rect;
    424             MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rcTool, 2);
    425         }
    426 
    427         GetCursorPos ((LPPOINT)&rect);
    428         rect.top += 20;
    429 
    430         if (toolPtr->uFlags & TTF_CENTERTIP) {
    431             rect.left -= (size.cx / 2);
    432             rect.top  -= (size.cy / 2);
    433         }
    434 
    435         /* smart placement */
    436         if ((rect.left + size.cx > rcTool.left) && (rect.left < rcTool.right) &&
    437             (rect.top + size.cy > rcTool.top) && (rect.top < rcTool.bottom))
    438             rect.left = rcTool.right;
    439     }
    440 
    441     TRACE("pos %d - %d\n", rect.left, rect.top);
    442 
    443     rect.right = rect.left + size.cx;
    444     rect.bottom = rect.top + size.cy;
    445 
    446     AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE),
    447                         FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE));
    448 
    449     SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top,
    450                     rect.right - rect.left, rect.bottom - rect.top,
    451                     SWP_SHOWWINDOW | SWP_NOACTIVATE );
    452 
    453     InvalidateRect(hwnd, NULL, TRUE);
    454     UpdateWindow(hwnd);
     490    SendMessageA(toolPtr->hwnd,WM_NOTIFY,(WPARAM)toolPtr->uId,(LPARAM)&hdr);
     491
     492    //TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
     493
     494    TOOLTIPS_CalcTipRect(hwnd,infoPtr,toolPtr,&rect);
     495
     496    SetWindowPos (hwnd,HWND_TOP,rect.left,rect.top,
     497                    rect.right-rect.left,rect.bottom-rect.top,
     498                    SWP_SHOWWINDOW | SWP_NOACTIVATE );
     499
     500    hdc = GetDC (hwnd);
     501    TOOLTIPS_Draw(hwnd, hdc);
     502    ReleaseDC (hwnd, hdc);
    455503}
    456504
     
    463511
    464512    if (infoPtr->nTrackTool == -1)
    465         return;
     513        return;
    466514
    467515    toolPtr = &infoPtr->tools[infoPtr->nTrackTool];
    468     TRACE("hide tracking tooltip %d!\n", infoPtr->nTrackTool);
     516//    TRACE (tooltips, "hide tracking tooltip %d!\n", infoPtr->nTrackTool);
    469517
    470518    hdr.hwndFrom = hwnd;
     
    472520    hdr.code = TTN_POP;
    473521    SendMessageA (toolPtr->hwnd, WM_NOTIFY,
    474                     (WPARAM)toolPtr->uId, (LPARAM)&hdr);
     522                    (WPARAM)toolPtr->uId, (LPARAM)&hdr);
    475523
    476524    SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,
    477                     SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
     525                    SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
    478526}
    479527
     
    486534
    487535    for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
    488         toolPtr = &infoPtr->tools[nTool];
    489 
    490         if (!(toolPtr->uFlags & TTF_IDISHWND) &&
    491             (lpToolInfo->hwnd == toolPtr->hwnd) &&
    492             (lpToolInfo->uId == toolPtr->uId))
    493             return nTool;
     536        toolPtr = &infoPtr->tools[nTool];
     537
     538        if (!(toolPtr->uFlags & TTF_IDISHWND) &&
     539            (lpToolInfo->hwnd == toolPtr->hwnd) &&
     540            (lpToolInfo->uId == toolPtr->uId))
     541            return nTool;
    494542    }
    495543
    496544    for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
    497         toolPtr = &infoPtr->tools[nTool];
    498 
    499         if ((toolPtr->uFlags & TTF_IDISHWND) &&
    500             (lpToolInfo->uId == toolPtr->uId))
    501             return nTool;
     545        toolPtr = &infoPtr->tools[nTool];
     546
     547        if ((toolPtr->uFlags & TTF_IDISHWND) &&
     548            (lpToolInfo->uId == toolPtr->uId))
     549            return nTool;
    502550    }
    503551
     
    513561
    514562    for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
    515         toolPtr = &infoPtr->tools[nTool];
    516 
    517         if (!(toolPtr->uFlags & TTF_IDISHWND) &&
    518             (lpToolInfo->hwnd == toolPtr->hwnd) &&
    519             (lpToolInfo->uId == toolPtr->uId))
    520             return nTool;
     563        toolPtr = &infoPtr->tools[nTool];
     564
     565        if (!(toolPtr->uFlags & TTF_IDISHWND) &&
     566            (lpToolInfo->hwnd == toolPtr->hwnd) &&
     567            (lpToolInfo->uId == toolPtr->uId))
     568            return nTool;
    521569    }
    522570
    523571    for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
    524         toolPtr = &infoPtr->tools[nTool];
    525 
    526         if ((toolPtr->uFlags & TTF_IDISHWND) &&
    527             (lpToolInfo->uId == toolPtr->uId))
    528             return nTool;
     572        toolPtr = &infoPtr->tools[nTool];
     573
     574        if ((toolPtr->uFlags & TTF_IDISHWND) &&
     575            (lpToolInfo->uId == toolPtr->uId))
     576            return nTool;
    529577    }
    530578
     
    539587    INT  nTool;
    540588
     589    //@@@AH 2000/02/25 make sure we don't get garbage in
     590    if (!infoPtr)
     591    {
     592      dprintf(("Tooltips:GetToolFromPoint: infoPtr == NULL!!!\n"));
     593      return 0;
     594    }
     595
    541596    for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
    542         toolPtr = &infoPtr->tools[nTool];
    543 
    544         if (!(toolPtr->uFlags & TTF_IDISHWND)) {
    545             if (hwnd != toolPtr->hwnd)
    546                 continue;
    547             if (!PtInRect (&toolPtr->rect, *lpPt))
    548                 continue;
    549             return nTool;
    550         }
     597        toolPtr = &infoPtr->tools[nTool];
     598
     599        if (!(toolPtr->uFlags & TTF_IDISHWND)) {
     600            if (hwnd != toolPtr->hwnd)
     601                continue;
     602            if (!PtInRect (&toolPtr->rect, *lpPt))
     603                continue;
     604            return nTool;
     605        }
    551606    }
    552607
    553608    for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
    554         toolPtr = &infoPtr->tools[nTool];
    555 
    556         if (toolPtr->uFlags & TTF_IDISHWND) {
    557             if ((HWND)toolPtr->uId == hwnd)
    558                 return nTool;
    559         }
     609        toolPtr = &infoPtr->tools[nTool];
     610
     611        if (toolPtr->uFlags & TTF_IDISHWND) {
     612            if ((HWND)toolPtr->uId == hwnd)
     613                return nTool;
     614        }
    560615    }
    561616
    562617    return -1;
     618}
     619
     620
     621static INT
     622TOOLTIPS_GetToolFromMessage (TOOLTIPS_INFO *infoPtr, HWND hwndTool)
     623{
     624    DWORD   dwPos;
     625    POINT pt;
     626
     627    dwPos = GetMessagePos ();
     628    pt.x = (INT)LOWORD(dwPos);
     629    pt.y = (INT)HIWORD(dwPos);
     630    ScreenToClient (hwndTool, &pt);
     631
     632    return TOOLTIPS_GetToolFromPoint (infoPtr, hwndTool, &pt);
    563633}
    564634
     
    569639    HWND hwndActive = GetActiveWindow ();
    570640    if (!hwndActive)
    571         return FALSE;
     641        return FALSE;
    572642    if (hwndActive == hwnd)
    573         return TRUE;
     643        return TRUE;
    574644    return IsChild (hwndActive, hwnd);
    575645}
     
    587657    hwndTool = SendMessageA (hwnd, TTM_WINDOWFROMPOINT, 0, (LPARAM)&pt);
    588658    if (hwndTool == 0)
    589         return -1;
     659        return -1;
    590660
    591661    ScreenToClient (hwndTool, &pt);
    592662    nTool = TOOLTIPS_GetToolFromPoint (infoPtr, hwndTool, &pt);
    593663    if (nTool == -1)
    594         return -1;
     664        return -1;
    595665
    596666    if (!(GetWindowLongA (hwnd, GWL_STYLE) & TTS_ALWAYSTIP) && bShowTest) {
    597         if (!TOOLTIPS_IsWindowActive (GetWindow (hwnd, GW_OWNER)))
    598             return -1;
    599     }
    600 
    601     TRACE("tool %d\n", nTool);
     667        if (!TOOLTIPS_IsWindowActive (GetWindow (hwnd, GW_OWNER)))
     668            return -1;
     669    }
    602670
    603671    return nTool;
     
    608676TOOLTIPS_Activate (HWND hwnd, WPARAM wParam, LPARAM lParam)
    609677{
    610     TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
     678    TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
    611679
    612680    infoPtr->bActive = (BOOL)wParam;
    613681
    614     if (infoPtr->bActive)
    615         TRACE("activate!\n");
    616 
    617682    if (!(infoPtr->bActive) && (infoPtr->nCurrentTool != -1))
    618         TOOLTIPS_Hide (hwnd, infoPtr);
    619 
    620     return 0;
    621 }
    622 
    623 
    624 static LRESULT
    625 TOOLTIPS_AddToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    626 {
    627     TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
     683        TOOLTIPS_Hide (hwnd, infoPtr);
     684
     685    return 0;
     686}
     687
     688
     689static VOID TOOLTIPS_Subclass(HWND hwnd,TTTOOL_INFO *toolPtr)
     690{
     691    if (toolPtr->uFlags & TTF_SUBCLASS)
     692    {
     693      if (toolPtr->uFlags & TTF_IDISHWND)
     694      {
     695        LPTT_SUBCLASS_INFO lpttsi =
     696            (LPTT_SUBCLASS_INFO)GetPropA((HWND)toolPtr->uId,COMCTL32_aSubclass);
     697        if (lpttsi == NULL)
     698        {
     699          lpttsi = (LPTT_SUBCLASS_INFO)COMCTL32_Alloc(sizeof(TT_SUBCLASS_INFO));
     700          lpttsi->wpOrigProc =
     701              (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId,
     702              GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
     703          lpttsi->hwndToolTip = hwnd;
     704          lpttsi->uRefCount++;
     705          SetPropA ((HWND)toolPtr->uId,COMCTL32_aSubclass,(HANDLE)lpttsi);
     706        }
     707//          else
     708//              WARN (tooltips, "A window tool must only be listed once!\n");
     709      } else
     710      {
     711        LPTT_SUBCLASS_INFO lpttsi =
     712           (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
     713        if (lpttsi == NULL)
     714        {
     715          lpttsi = (LPTT_SUBCLASS_INFO)COMCTL32_Alloc(sizeof(TT_SUBCLASS_INFO));
     716          lpttsi->wpOrigProc =
     717              (WNDPROC)SetWindowLongA (toolPtr->hwnd,
     718              GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
     719          lpttsi->hwndToolTip = hwnd;
     720          lpttsi->uRefCount++;
     721          SetPropA(toolPtr->hwnd,COMCTL32_aSubclass,(HANDLE)lpttsi);
     722        } else lpttsi->uRefCount++;
     723      }
     724//      TRACE (tooltips, "subclassing installed!\n");
     725    }
     726}
     727
     728static VOID TOOLTIPS_Desubclass(TTTOOL_INFO *toolPtr)
     729{
     730    if (toolPtr->uFlags & TTF_SUBCLASS)
     731    {
     732      if (toolPtr->uFlags & TTF_IDISHWND)
     733      {
     734        LPTT_SUBCLASS_INFO lpttsi =
     735            (LPTT_SUBCLASS_INFO)GetPropA((HWND)toolPtr->uId,COMCTL32_aSubclass);
     736        if (lpttsi)
     737        {
     738          SetWindowLongA ((HWND)toolPtr->uId,GWL_WNDPROC,(LONG)lpttsi->wpOrigProc);
     739          RemovePropA ((HWND)toolPtr->uId,COMCTL32_aSubclass);
     740          COMCTL32_Free(&lpttsi);
     741        }
     742//          else
     743//              ERR (tooltips, "Invalid data handle!\n");
     744      } else
     745      {
     746        LPTT_SUBCLASS_INFO lpttsi =
     747            (LPTT_SUBCLASS_INFO)GetPropA(toolPtr->hwnd,COMCTL32_aSubclass);
     748        if (lpttsi)
     749        {
     750          if (lpttsi->uRefCount == 1)
     751          {
     752            SetWindowLongA((HWND)toolPtr->uId,GWL_WNDPROC,(LONG)lpttsi->wpOrigProc);
     753            RemovePropA((HWND)toolPtr->uId,COMCTL32_aSubclass);
     754            COMCTL32_Free(&lpttsi);
     755          } else lpttsi->uRefCount--;
     756        }
     757//          else
     758//              ERR (tooltips, "Invalid data handle!\n");
     759      }
     760    }
     761}
     762
     763static LRESULT
     764TOOLTIPS_AddToolA(HWND hwnd,WPARAM wParam,LPARAM lParam)
     765{
     766    TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
    628767    LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
    629768    TTTOOL_INFO *toolPtr;
    630769
    631     if (lpToolInfo == NULL)
    632         return FALSE;
    633     if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    634         return FALSE;
    635 
    636     TRACE("add tool (%x) %x %d%s!\n",
    637            hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
    638            (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
    639 
    640     if (infoPtr->uNumTools == 0) {
    641         infoPtr->tools = (TTTOOL_INFO*)COMCTL32_Alloc (sizeof(TTTOOL_INFO));
    642         toolPtr = infoPtr->tools;
    643     }
    644     else {
    645         TTTOOL_INFO *oldTools = infoPtr->tools;
    646         infoPtr->tools =
    647             (TTTOOL_INFO*)COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1));
    648         memcpy (infoPtr->tools, oldTools,
    649                 infoPtr->uNumTools * sizeof(TTTOOL_INFO));
    650         COMCTL32_Free (oldTools);
    651         toolPtr = &infoPtr->tools[infoPtr->uNumTools];
     770    if (lpToolInfo == NULL) return FALSE;
     771    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) return FALSE;
     772
     773//    TRACE (tooltips, "add tool (%x) %x %d%s!\n",
     774//         hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
     775//         (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
     776
     777    if (infoPtr->uNumTools == 0)
     778    {
     779      infoPtr->tools = (TTTOOL_INFO*)COMCTL32_Alloc(sizeof(TTTOOL_INFO));
     780      toolPtr = infoPtr->tools;
     781    } else
     782    {
     783      TTTOOL_INFO *oldTools = infoPtr->tools;
     784      INT x;
     785
     786      toolPtr = NULL;
     787
     788      //check if toolinfo already exists
     789      for (x = 0;x < infoPtr->uNumTools;x++)
     790      {
     791        if (lpToolInfo->hwnd == infoPtr->tools[x].hwnd && lpToolInfo->uId == infoPtr->tools[x].uId)
     792        {
     793          //return toolPtr
     794          toolPtr = &infoPtr->tools[x];
     795          //free allocated memory
     796          TOOLTIPS_Desubclass(toolPtr);
     797          if ((toolPtr->hinst) && (toolPtr->lpszText))
     798          {
     799            if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(toolPtr->lpszText);
     800          }
     801
     802          break;
     803        }
     804      }
     805
     806      if (toolPtr == NULL)
     807      {
     808        infoPtr->tools = (TTTOOL_INFO*)COMCTL32_Alloc (sizeof(TTTOOL_INFO)*(infoPtr->uNumTools+1));
     809        memcpy(infoPtr->tools,oldTools,infoPtr->uNumTools*sizeof(TTTOOL_INFO));
     810        COMCTL32_Free(oldTools);
     811        toolPtr = &infoPtr->tools[infoPtr->uNumTools];
     812      }
    652813    }
    653814
     
    661822    toolPtr->hinst  = lpToolInfo->hinst;
    662823
    663     if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
    664         TRACE("add string id %x!\n", (int)lpToolInfo->lpszText);
    665         toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
    666     }
    667     else if (lpToolInfo->lpszText) {
    668         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) {
    669             TRACE("add CALLBACK!\n");
    670             toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    671         }
    672         else {
    673             INT len = MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, -1,
    674                                           NULL, 0);
    675             TRACE("add text \"%s\"!\n", lpToolInfo->lpszText);
    676             toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc (len * sizeof(WCHAR));
    677             MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, -1,
    678                                 toolPtr->lpszText, len);
    679         }
    680     }
     824    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0))
     825    {
     826//    TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText);
     827      toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
     828    } else if (lpToolInfo->lpszText)
     829    {
     830      if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
     831      {
     832//      TRACE (tooltips, "add CALLBACK!\n");
     833        toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     834      } else
     835      {
     836        INT len = lstrlenA (lpToolInfo->lpszText);
     837//          TRACE (tooltips, "add text \"%s\"!\n", lpToolInfo->lpszText);
     838        toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
     839        lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
     840      }
     841    } else toolPtr->lpszText = NULL;
    681842
    682843    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
    683         toolPtr->lParam = lpToolInfo->lParam;
     844        toolPtr->lParam = lpToolInfo->lParam;
    684845
    685846    /* install subclassing hook */
    686     if (toolPtr->uFlags & TTF_SUBCLASS) {
    687         if (toolPtr->uFlags & TTF_IDISHWND) {
    688             LPTT_SUBCLASS_INFO lpttsi =
    689                 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    690             if (lpttsi == NULL) {
    691                 lpttsi =
    692                     (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
    693                 lpttsi->wpOrigProc =
    694                     (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId,
    695                     GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
    696                 lpttsi->hwndToolTip = hwnd;
    697                 lpttsi->uRefCount++;
    698                 SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass,
    699                             (HANDLE)lpttsi);
    700             }
    701             else
    702                 WARN("A window tool must only be listed once!\n");
    703         }
    704         else {
    705             LPTT_SUBCLASS_INFO lpttsi =
    706                 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
    707             if (lpttsi == NULL) {
    708                 lpttsi =
    709                     (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
    710                 lpttsi->wpOrigProc =
    711                     (WNDPROC)SetWindowLongA (toolPtr->hwnd,
    712                     GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
    713                 lpttsi->hwndToolTip = hwnd;
    714                 lpttsi->uRefCount++;
    715                 SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi);
    716             }
    717             else
    718                 lpttsi->uRefCount++;
    719         }
    720         TRACE("subclassing installed!\n");
    721     }
     847    TOOLTIPS_Subclass(hwnd,toolPtr);
    722848
    723849    return TRUE;
     
    733859
    734860    if (lpToolInfo == NULL)
    735         return FALSE;
     861        return FALSE;
    736862    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    737         return FALSE;
    738 
    739     TRACE("add tool (%x) %x %d%s!\n",
    740            hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
    741            (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
    742 
    743     if (infoPtr->uNumTools == 0) {
    744         infoPtr->tools = (TTTOOL_INFO*)COMCTL32_Alloc (sizeof(TTTOOL_INFO));
    745         toolPtr = infoPtr->tools;
    746     }
    747     else {
    748         TTTOOL_INFO *oldTools = infoPtr->tools;
    749         infoPtr->tools =
    750             (TTTOOL_INFO*)COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1));
    751         memcpy (infoPtr->tools, oldTools,
    752                 infoPtr->uNumTools * sizeof(TTTOOL_INFO));
    753         COMCTL32_Free (oldTools);
    754         toolPtr = &infoPtr->tools[infoPtr->uNumTools];
     863        return FALSE;
     864
     865//    TRACE (tooltips, "add tool (%x) %x %d%s!\n",
     866//         hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
     867//         (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
     868
     869    if (infoPtr->uNumTools == 0)
     870    {
     871      infoPtr->tools = (TTTOOL_INFO*)COMCTL32_Alloc (sizeof(TTTOOL_INFO));
     872      toolPtr = infoPtr->tools;
     873    } else
     874    {
     875      TTTOOL_INFO *oldTools = infoPtr->tools;
     876      INT x;
     877
     878      toolPtr = NULL;
     879
     880      //check if toolinfo already exists
     881      for (x = 0;x < infoPtr->uNumTools;x++)
     882      {
     883        if (lpToolInfo->hwnd == infoPtr->tools[x].hwnd && lpToolInfo->uId == infoPtr->tools[x].uId)
     884        {
     885          //return toolPtr
     886          toolPtr = &infoPtr->tools[x];
     887          //free allocated memory
     888          TOOLTIPS_Desubclass(toolPtr);
     889          if ((toolPtr->hinst) && (toolPtr->lpszText))
     890          {
     891            if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(toolPtr->lpszText);
     892          }
     893
     894          break;
     895        }
     896      }
     897
     898      if (toolPtr == NULL)
     899      {
     900        infoPtr->tools = (TTTOOL_INFO*)COMCTL32_Alloc(sizeof(TTTOOL_INFO)*(infoPtr->uNumTools+1));
     901        memcpy (infoPtr->tools,oldTools,infoPtr->uNumTools*sizeof(TTTOOL_INFO));
     902        COMCTL32_Free(oldTools);
     903        toolPtr = &infoPtr->tools[infoPtr->uNumTools];
     904      }
    755905    }
    756906
     
    765915
    766916    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
    767         TRACE("add string id %x!\n", (int)lpToolInfo->lpszText);
    768         toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
     917//      TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText);
     918        toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
    769919    }
    770920    else if (lpToolInfo->lpszText) {
    771         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) {
    772             TRACE("add CALLBACK!\n");
    773             toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    774         }
    775         else {
    776             INT len = lstrlenW (lpToolInfo->lpszText);
    777             TRACE("add text %s!\n",
    778                    debugstr_w(lpToolInfo->lpszText));
    779             toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    780             lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
    781         }
     921        if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) {
     922//          TRACE (tooltips, "add CALLBACK!\n");
     923            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     924        }
     925        else {
     926            INT len = lstrlenW (lpToolInfo->lpszText);
     927//          TRACE (tooltips, "add text \"%s\"!\n",
     928//                 debugstr_w(lpToolInfo->lpszText));
     929            toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     930            lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
     931        }
    782932    }
    783933
    784934    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
    785         toolPtr->lParam = lpToolInfo->lParam;
     935        toolPtr->lParam = lpToolInfo->lParam;
    786936
    787937    /* install subclassing hook */
    788     if (toolPtr->uFlags & TTF_SUBCLASS) {
    789         if (toolPtr->uFlags & TTF_IDISHWND) {
    790             LPTT_SUBCLASS_INFO lpttsi =
    791                 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    792             if (lpttsi == NULL) {
    793                 lpttsi =
    794                     (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
    795                 lpttsi->wpOrigProc =
    796                     (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId,
    797                     GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
    798                 lpttsi->hwndToolTip = hwnd;
    799                 lpttsi->uRefCount++;
    800                 SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass,
    801                             (HANDLE)lpttsi);
    802             }
    803             else
    804                 WARN("A window tool must only be listed once!\n");
    805         }
    806         else {
    807             LPTT_SUBCLASS_INFO lpttsi =
    808                 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
    809             if (lpttsi == NULL) {
    810                 lpttsi =
    811                     (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
    812                 lpttsi->wpOrigProc =
    813                     (WNDPROC)SetWindowLongA (toolPtr->hwnd,
    814                     GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
    815                 lpttsi->hwndToolTip = hwnd;
    816                 lpttsi->uRefCount++;
    817                 SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi);
    818             }
    819             else
    820                 lpttsi->uRefCount++;
    821         }
    822         TRACE("subclassing installed!\n");
    823     }
     938    TOOLTIPS_Subclass(hwnd,toolPtr);
    824939
    825940    return TRUE;
     
    836951
    837952    if (lpToolInfo == NULL)
    838         return 0;
     953        return 0;
    839954    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    840         return 0;
     955        return 0;
    841956    if (infoPtr->uNumTools == 0)
    842         return 0;
     957        return 0;
    843958
    844959    nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
    845960    if (nTool == -1) return 0;
    846961
    847     TRACE("tool %d\n", nTool);
     962//    TRACE (tooltips, "tool %d\n", nTool);
    848963
    849964    /* delete text string */
    850     toolPtr = &infoPtr->tools[nTool]; 
     965    toolPtr = &infoPtr->tools[nTool];
    851966    if ((toolPtr->hinst) && (toolPtr->lpszText)) {
    852         if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
    853              (HIWORD((INT)toolPtr->lpszText) != 0) )
    854             COMCTL32_Free (toolPtr->lpszText);
     967        if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
     968             (HIWORD((INT)toolPtr->lpszText) != 0) )
     969            COMCTL32_Free (toolPtr->lpszText);
    855970    }
    856971
    857972    /* remove subclassing */
    858     if (toolPtr->uFlags & TTF_SUBCLASS) {
    859         if (toolPtr->uFlags & TTF_IDISHWND) {
    860             LPTT_SUBCLASS_INFO lpttsi =
    861                 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    862             if (lpttsi) {
    863                 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
    864                                   (LONG)lpttsi->wpOrigProc);
    865                 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    866                 COMCTL32_Free (&lpttsi);
    867             }
    868             else
    869                 ERR("Invalid data handle!\n");
    870         }
    871         else {
    872             LPTT_SUBCLASS_INFO lpttsi =
    873                 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
    874             if (lpttsi) {
    875                 if (lpttsi->uRefCount == 1) {
    876                     SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
    877                                       (LONG)lpttsi->wpOrigProc);
    878                     RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    879                     COMCTL32_Free (&lpttsi);
    880                 }
    881                 else
    882                     lpttsi->uRefCount--;
    883             }
    884             else
    885                 ERR("Invalid data handle!\n");
    886         }
    887     }
     973    TOOLTIPS_Desubclass(toolPtr);
    888974
    889975    /* delete tool from tool list */
    890976    if (infoPtr->uNumTools == 1) {
    891         COMCTL32_Free (infoPtr->tools);
    892         infoPtr->tools = NULL;
     977        COMCTL32_Free (infoPtr->tools);
     978        infoPtr->tools = NULL;
    893979    }
    894980    else {
    895         TTTOOL_INFO *oldTools = infoPtr->tools;
    896         infoPtr->tools =
    897             (TTTOOL_INFO*)COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
    898 
    899         if (nTool > 0)
    900             memcpy (&infoPtr->tools[0], &oldTools[0],
    901                     nTool * sizeof(TTTOOL_INFO));
    902 
    903         if (nTool < infoPtr->uNumTools - 1)
    904             memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
    905                     (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
    906 
    907         COMCTL32_Free (oldTools);
     981        TTTOOL_INFO *oldTools = infoPtr->tools;
     982        infoPtr->tools =
     983            (TTTOOL_INFO*)COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
     984
     985        if (nTool > 0)
     986            memcpy (&infoPtr->tools[0], &oldTools[0],
     987                    nTool * sizeof(TTTOOL_INFO));
     988
     989        if (nTool < infoPtr->uNumTools - 1)
     990            memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
     991                    (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
     992
     993        COMCTL32_Free (oldTools);
    908994    }
    909995
     
    9231009
    9241010    if (lpToolInfo == NULL)
    925         return 0;
     1011        return 0;
    9261012    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    927         return 0;
     1013        return 0;
    9281014    if (infoPtr->uNumTools == 0)
    929         return 0;
     1015        return 0;
    9301016
    9311017    nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
    9321018    if (nTool == -1) return 0;
    9331019
    934     TRACE("tool %d\n", nTool);
     1020//    TRACE (tooltips, "tool %d\n", nTool);
    9351021
    9361022    /* delete text string */
    937     toolPtr = &infoPtr->tools[nTool]; 
     1023    toolPtr = &infoPtr->tools[nTool];
    9381024    if ((toolPtr->hinst) && (toolPtr->lpszText)) {
    939         if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
    940              (HIWORD((INT)toolPtr->lpszText) != 0) )
    941             COMCTL32_Free (toolPtr->lpszText);
     1025        if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
     1026             (HIWORD((INT)toolPtr->lpszText) != 0) )
     1027            COMCTL32_Free (toolPtr->lpszText);
    9421028    }
    9431029
    9441030    /* remove subclassing */
    945     if (toolPtr->uFlags & TTF_SUBCLASS) {
    946         if (toolPtr->uFlags & TTF_IDISHWND) {
    947             LPTT_SUBCLASS_INFO lpttsi =
    948                 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    949             if (lpttsi) {
    950                 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
    951                                   (LONG)lpttsi->wpOrigProc);
    952                 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    953                 COMCTL32_Free (&lpttsi);
    954             }
    955             else
    956                 ERR("Invalid data handle!\n");
    957         }
    958         else {
    959             LPTT_SUBCLASS_INFO lpttsi =
    960                 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
    961             if (lpttsi) {
    962                 if (lpttsi->uRefCount == 1) {
    963                     SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
    964                                       (LONG)lpttsi->wpOrigProc);
    965                     RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    966                     COMCTL32_Free (&lpttsi);
    967                 }
    968                 else
    969                     lpttsi->uRefCount--;
    970             }
    971             else
    972                 ERR("Invalid data handle!\n");
    973         }
    974     }
     1031    TOOLTIPS_Desubclass(toolPtr);
    9751032
    9761033    /* delete tool from tool list */
    9771034    if (infoPtr->uNumTools == 1) {
    978         COMCTL32_Free (infoPtr->tools);
    979         infoPtr->tools = NULL;
     1035        COMCTL32_Free (infoPtr->tools);
     1036        infoPtr->tools = NULL;
    9801037    }
    9811038    else {
    982         TTTOOL_INFO *oldTools = infoPtr->tools;
    983         infoPtr->tools =
    984             (TTTOOL_INFO*)COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
    985 
    986         if (nTool > 0)
    987             memcpy (&infoPtr->tools[0], &oldTools[0],
    988                     nTool * sizeof(TTTOOL_INFO));
    989 
    990         if (nTool < infoPtr->uNumTools - 1)
    991             memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
    992                     (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
    993 
    994         COMCTL32_Free (oldTools);
     1039        TTTOOL_INFO *oldTools = infoPtr->tools;
     1040        infoPtr->tools =
     1041            (TTTOOL_INFO*)COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
     1042
     1043        if (nTool > 0)
     1044            memcpy (&infoPtr->tools[0], &oldTools[0],
     1045                    nTool * sizeof(TTTOOL_INFO));
     1046
     1047        if (nTool < infoPtr->uNumTools - 1)
     1048            memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
     1049                    (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
     1050
     1051        COMCTL32_Free (oldTools);
    9951052    }
    9961053
     
    10101067
    10111068    if (lpToolInfo == NULL)
    1012         return FALSE;
     1069        return FALSE;
    10131070    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    1014         return FALSE;
     1071        return FALSE;
    10151072    if (uIndex >= infoPtr->uNumTools)
    1016         return FALSE;
    1017 
    1018     TRACE("index=%u\n", uIndex);
     1073        return FALSE;
     1074
     1075//    TRACE (tooltips, "index=%u\n", uIndex);
    10191076
    10201077    toolPtr = &infoPtr->tools[uIndex];
     
    10301087
    10311088    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
    1032         lpToolInfo->lParam = toolPtr->lParam;
     1089        lpToolInfo->lParam = toolPtr->lParam;
    10331090
    10341091    return TRUE;
     
    10451102
    10461103    if (lpToolInfo == NULL)
    1047         return FALSE;
     1104        return FALSE;
    10481105    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    1049         return FALSE;
     1106        return FALSE;
    10501107    if (uIndex >= infoPtr->uNumTools)
    1051         return FALSE;
    1052 
    1053     TRACE("index=%u\n", uIndex);
     1108        return FALSE;
     1109
     1110//    TRACE (tooltips, "index=%u\n", uIndex);
    10541111
    10551112    toolPtr = &infoPtr->tools[uIndex];
     
    10651122
    10661123    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
    1067         lpToolInfo->lParam = toolPtr->lParam;
     1124        lpToolInfo->lParam = toolPtr->lParam;
    10681125
    10691126    return TRUE;
     
    10791136
    10801137    if (lpToolInfo == NULL)
    1081         return FALSE;
     1138        return FALSE;
    10821139    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    1083         return FALSE;
     1140        return FALSE;
    10841141
    10851142    if (lpToolInfo) {
    1086         if (infoPtr->nCurrentTool > -1) {
    1087             toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
    1088 
    1089             /* copy tool data */
    1090             lpToolInfo->uFlags   = toolPtr->uFlags;
    1091             lpToolInfo->rect     = toolPtr->rect;
    1092             lpToolInfo->hinst    = toolPtr->hinst;
    1093 /*          lpToolInfo->lpszText = toolPtr->lpszText; */
    1094             lpToolInfo->lpszText = NULL;  /* FIXME */
    1095 
    1096             if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
    1097                 lpToolInfo->lParam = toolPtr->lParam;
    1098 
    1099             return TRUE;
    1100         }
    1101         else
    1102             return FALSE;
     1143        if (infoPtr->nCurrentTool > -1) {
     1144            toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
     1145
     1146            /* copy tool data */
     1147            lpToolInfo->uFlags   = toolPtr->uFlags;
     1148            lpToolInfo->rect     = toolPtr->rect;
     1149            lpToolInfo->hinst    = toolPtr->hinst;
     1150/*          lpToolInfo->lpszText = toolPtr->lpszText; */
     1151            lpToolInfo->lpszText = NULL;  /* FIXME */
     1152
     1153            if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
     1154                lpToolInfo->lParam = toolPtr->lParam;
     1155
     1156            return TRUE;
     1157        }
     1158        else
     1159            return FALSE;
    11031160    }
    11041161    else
    1105         return (infoPtr->nCurrentTool != -1);
     1162        return (infoPtr->nCurrentTool != -1);
    11061163
    11071164    return FALSE;
     
    11171174
    11181175    if (lpToolInfo == NULL)
    1119         return FALSE;
     1176        return FALSE;
    11201177    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    1121         return FALSE;
     1178        return FALSE;
    11221179
    11231180    if (lpToolInfo) {
    1124         if (infoPtr->nCurrentTool > -1) {
    1125             toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
    1126 
    1127             /* copy tool data */
    1128             lpToolInfo->uFlags   = toolPtr->uFlags;
    1129             lpToolInfo->rect     = toolPtr->rect;
    1130             lpToolInfo->hinst    = toolPtr->hinst;
    1131 /*          lpToolInfo->lpszText = toolPtr->lpszText; */
    1132             lpToolInfo->lpszText = NULL;  /* FIXME */
    1133 
    1134             if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
    1135                 lpToolInfo->lParam = toolPtr->lParam;
    1136 
    1137             return TRUE;
    1138         }
    1139         else
    1140             return FALSE;
     1181        if (infoPtr->nCurrentTool > -1) {
     1182            toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
     1183
     1184            /* copy tool data */
     1185            lpToolInfo->uFlags   = toolPtr->uFlags;
     1186            lpToolInfo->rect     = toolPtr->rect;
     1187            lpToolInfo->hinst    = toolPtr->hinst;
     1188/*          lpToolInfo->lpszText = toolPtr->lpszText; */
     1189            lpToolInfo->lpszText = NULL;  /* FIXME */
     1190
     1191            if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
     1192                lpToolInfo->lParam = toolPtr->lParam;
     1193
     1194            return TRUE;
     1195        }
     1196        else
     1197            return FALSE;
    11411198    }
    11421199    else
    1143         return (infoPtr->nCurrentTool != -1);
     1200        return (infoPtr->nCurrentTool != -1);
    11441201
    11451202    return FALSE;
     
    11531210
    11541211    switch (wParam) {
    1155     case TTDT_RESHOW:
    1156         return infoPtr->nReshowTime;
    1157 
    1158     case TTDT_AUTOPOP:
    1159         return infoPtr->nAutoPopTime;
    1160 
    1161     case TTDT_INITIAL:
    1162     case TTDT_AUTOMATIC: /* Apparently TTDT_AUTOMATIC returns TTDT_INITIAL */
    1163         return infoPtr->nInitialTime;
    1164 
    1165     default:
    1166         WARN("Invalid wParam %x\n", wParam);
    1167         break;
    1168     }
    1169 
    1170     return -1;
     1212        case TTDT_AUTOMATIC:
     1213            return infoPtr->nAutomaticTime;
     1214
     1215        case TTDT_RESHOW:
     1216            return infoPtr->nReshowTime;
     1217
     1218        case TTDT_AUTOPOP:
     1219            return infoPtr->nAutoPopTime;
     1220
     1221        case TTDT_INITIAL:
     1222            return infoPtr->nInitialTime;
     1223    }
     1224
     1225    return 0;
    11711226}
    11721227
     
    11871242
    11881243
    1189 inline static LRESULT
     1244static LRESULT
    11901245TOOLTIPS_GetMaxTipWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
    11911246{
     
    12041259
    12051260    if (lpToolInfo == NULL)
    1206         return 0;
     1261        return 0;
    12071262    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    1208         return 0;
     1263        return 0;
    12091264
    12101265    nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
    12111266    if (nTool == -1) return 0;
    12121267
    1213     /* NB this API is broken, there is no way for the app to determine
    1214        what size buffer it requires nor a way to specify how long the
    1215        one it supplies is.  We'll assume it's upto INFOTIPSIZE */
    1216 
    1217     WideCharToMultiByte(CP_ACP, 0, infoPtr->tools[nTool].lpszText, -1,
    1218                         lpToolInfo->lpszText, INFOTIPSIZE, NULL, NULL);
     1268    TOOLTIPS_GetTipText(hwnd,infoPtr,nTool);
     1269
     1270    lstrcpyWtoA(lpToolInfo->lpszText,infoPtr->szTipText);
    12191271
    12201272    return 0;
     
    12301282
    12311283    if (lpToolInfo == NULL)
    1232         return 0;
     1284        return 0;
    12331285    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    1234         return 0;
     1286        return 0;
    12351287
    12361288    nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
    12371289    if (nTool == -1) return 0;
    12381290
    1239     lstrcpyW (lpToolInfo->lpszText, infoPtr->tools[nTool].lpszText);
    1240 
    1241     return 0;
    1242 }
    1243 
    1244 
    1245 inline static LRESULT
     1291    TOOLTIPS_GetTipText(hwnd,infoPtr,nTool);
     1292
     1293    lstrcpyW(lpToolInfo->lpszText,infoPtr->szTipText);
     1294
     1295    return 0;
     1296}
     1297
     1298
     1299static LRESULT
    12461300TOOLTIPS_GetTipBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
    12471301{
     
    12511305
    12521306
    1253 inline static LRESULT
     1307static LRESULT
    12541308TOOLTIPS_GetTipTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
    12551309{
     
    12591313
    12601314
    1261 inline static LRESULT
     1315static LRESULT
    12621316TOOLTIPS_GetToolCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
    12631317{
     
    12761330
    12771331    if (lpToolInfo == NULL)
    1278         return FALSE;
     1332        return FALSE;
    12791333    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    1280         return FALSE;
     1334        return FALSE;
    12811335    if (infoPtr->uNumTools == 0)
    1282         return FALSE;
     1336        return FALSE;
    12831337
    12841338    nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
    12851339    if (nTool == -1)
    1286         return FALSE;
    1287 
    1288     TRACE("tool %d\n", nTool);
     1340        return FALSE;
     1341
     1342//    TRACE (tooltips, "tool %d\n", nTool);
    12891343
    12901344    toolPtr = &infoPtr->tools[nTool];
     
    12981352
    12991353    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
    1300         lpToolInfo->lParam = toolPtr->lParam;
     1354        lpToolInfo->lParam = toolPtr->lParam;
    13011355
    13021356    return TRUE;
     
    13131367
    13141368    if (lpToolInfo == NULL)
    1315         return FALSE;
     1369        return FALSE;
    13161370    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    1317         return FALSE;
     1371        return FALSE;
    13181372    if (infoPtr->uNumTools == 0)
    1319         return FALSE;
     1373        return FALSE;
    13201374
    13211375    nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
    13221376    if (nTool == -1)
    1323         return FALSE;
    1324 
    1325     TRACE("tool %d\n", nTool);
     1377        return FALSE;
     1378
     1379//    TRACE (tooltips, "tool %d\n", nTool);
    13261380
    13271381    toolPtr = &infoPtr->tools[nTool];
     
    13351389
    13361390    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
    1337         lpToolInfo->lParam = toolPtr->lParam;
     1391        lpToolInfo->lParam = toolPtr->lParam;
    13381392
    13391393    return TRUE;
     
    13501404
    13511405    if (lptthit == 0)
    1352         return FALSE;
     1406        return FALSE;
    13531407
    13541408    nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt);
    13551409    if (nTool == -1)
    1356         return FALSE;
    1357 
    1358     TRACE("tool %d!\n", nTool);
     1410        return FALSE;
     1411
     1412//    TRACE (tooltips, "tool %d!\n", nTool);
    13591413
    13601414    /* copy tool data */
    13611415    if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOA)) {
    1362         toolPtr = &infoPtr->tools[nTool];
    1363 
    1364         lptthit->ti.uFlags   = toolPtr->uFlags;
    1365         lptthit->ti.hwnd     = toolPtr->hwnd;
    1366         lptthit->ti.uId      = toolPtr->uId;
    1367         lptthit->ti.rect     = toolPtr->rect;
    1368         lptthit->ti.hinst    = toolPtr->hinst;
    1369 /*      lptthit->ti.lpszText = toolPtr->lpszText; */
    1370         lptthit->ti.lpszText = NULL;  /* FIXME */
    1371         lptthit->ti.lParam   = toolPtr->lParam;
     1416        toolPtr = &infoPtr->tools[nTool];
     1417
     1418        lptthit->ti.uFlags   = toolPtr->uFlags;
     1419        lptthit->ti.hwnd     = toolPtr->hwnd;
     1420        lptthit->ti.uId      = toolPtr->uId;
     1421        lptthit->ti.rect     = toolPtr->rect;
     1422        lptthit->ti.hinst    = toolPtr->hinst;
     1423/*      lptthit->ti.lpszText = toolPtr->lpszText; */
     1424        lptthit->ti.lpszText = NULL;  /* FIXME */
     1425        lptthit->ti.lParam   = toolPtr->lParam;
    13721426    }
    13731427
     
    13851439
    13861440    if (lptthit == 0)
    1387         return FALSE;
     1441        return FALSE;
    13881442
    13891443    nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt);
    13901444    if (nTool == -1)
    1391         return FALSE;
    1392 
    1393     TRACE("tool %d!\n", nTool);
     1445        return FALSE;
     1446
     1447//    TRACE (tooltips, "tool %d!\n", nTool);
    13941448
    13951449    /* copy tool data */
    13961450    if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOW)) {
    1397         toolPtr = &infoPtr->tools[nTool];
    1398 
    1399         lptthit->ti.uFlags   = toolPtr->uFlags;
    1400         lptthit->ti.hwnd     = toolPtr->hwnd;
    1401         lptthit->ti.uId      = toolPtr->uId;
    1402         lptthit->ti.rect     = toolPtr->rect;
    1403         lptthit->ti.hinst    = toolPtr->hinst;
    1404 /*      lptthit->ti.lpszText = toolPtr->lpszText; */
    1405         lptthit->ti.lpszText = NULL;  /* FIXME */
    1406         lptthit->ti.lParam   = toolPtr->lParam;
     1451        toolPtr = &infoPtr->tools[nTool];
     1452
     1453        lptthit->ti.uFlags   = toolPtr->uFlags;
     1454        lptthit->ti.hwnd     = toolPtr->hwnd;
     1455        lptthit->ti.uId      = toolPtr->uId;
     1456        lptthit->ti.rect     = toolPtr->rect;
     1457        lptthit->ti.hinst    = toolPtr->hinst;
     1458/*      lptthit->ti.lpszText = toolPtr->lpszText; */
     1459        lptthit->ti.lpszText = NULL;  /* FIXME */
     1460        lptthit->ti.lParam   = toolPtr->lParam;
    14071461    }
    14081462
     
    14191473
    14201474    if (lpti == NULL)
    1421         return 0;
     1475        return 0;
    14221476    if (lpti->cbSize < TTTOOLINFO_V1_SIZEA)
    1423         return FALSE;
     1477        return FALSE;
    14241478
    14251479    nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpti);
     
    14401494
    14411495    if (lpti == NULL)
    1442         return 0;
     1496        return 0;
    14431497    if (lpti->cbSize < TTTOOLINFO_V1_SIZEW)
    1444         return FALSE;
     1498        return FALSE;
    14451499
    14461500    nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpti);
     
    14531507
    14541508
    1455 inline static LRESULT
     1509static LRESULT
    14561510TOOLTIPS_Pop (HWND hwnd, WPARAM wParam, LPARAM lParam)
    14571511{
    14581512    TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
     1513
     1514    /*
     1515     * Need to set nCurrentTool to nOldTool so we hide the tool.
     1516     *  nTool and nOldTool values change when the mouse leaves the window.
     1517     * If using TTM_UPDATETIPTEXT we can end up with an nCurrentTool = -1 if the
     1518     * text can't be found, thus the tooltip would never be hidden.
     1519     */
     1520    if (infoPtr->nTool != infoPtr->nOldTool)
     1521      infoPtr->nCurrentTool = infoPtr->nOldTool;
     1522
    14591523    TOOLTIPS_Hide (hwnd, infoPtr);
    14601524
     
    14691533    LPMSG lpMsg = (LPMSG)lParam;
    14701534    POINT pt;
    1471     INT nOldTool;
    1472 
    1473     if (lParam == 0) {
    1474         ERR("lpMsg == NULL!\n");
    1475         return 0;
    1476     }
    1477 
    1478     switch (lpMsg->message) {
    1479         case WM_LBUTTONDOWN:
    1480         case WM_LBUTTONUP:
    1481         case WM_MBUTTONDOWN:
    1482         case WM_MBUTTONUP:
    1483         case WM_RBUTTONDOWN:
    1484         case WM_RBUTTONUP:
    1485             pt.x = LOWORD(lParam);
    1486             pt.y = HIWORD(lParam);
    1487             infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd, &pt);
    1488             TRACE("tool (%x) %d %d\n",
    1489                    hwnd, infoPtr->nTool, infoPtr->nCurrentTool);
    1490             TOOLTIPS_Hide (hwnd, infoPtr);
    1491             break;
    1492 
    1493         case WM_MOUSEMOVE:
    1494             pt.x = LOWORD(lpMsg->lParam);
    1495             pt.y = HIWORD(lpMsg->lParam);
    1496             nOldTool = infoPtr->nTool;
    1497             infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr, lpMsg->hwnd,
    1498                                                        &pt);
    1499             TRACE("tool (%x) %d %d %d\n", hwnd, nOldTool,
    1500                   infoPtr->nTool, infoPtr->nCurrentTool);
    1501             TRACE("WM_MOUSEMOVE (%04x %ld %ld)\n", hwnd, pt.x, pt.y);
    1502 
    1503             if (infoPtr->nTool != nOldTool) {
    1504                 if(infoPtr->nTool == -1) { /* Moved out of all tools */
    1505                     TOOLTIPS_Hide(hwnd, infoPtr);
    1506                     KillTimer(hwnd, ID_TIMERLEAVE);
    1507                 } else if (nOldTool == -1) { /* Moved from outside */
    1508                     if(infoPtr->bActive) {
    1509                         SetTimer(hwnd, ID_TIMERSHOW, infoPtr->nInitialTime, 0);
    1510                         TRACE("timer 1 started!\n");
    1511                     }
    1512                 } else { /* Moved from one to another */
    1513                     TOOLTIPS_Hide (hwnd, infoPtr);
    1514                     KillTimer(hwnd, ID_TIMERLEAVE);
    1515                     if(infoPtr->bActive) {
    1516                         SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0);
    1517                         TRACE("timer 1 started!\n");
    1518                     }
    1519                 }
    1520             } else if(infoPtr->nCurrentTool != -1) { /* restart autopop */
    1521                 KillTimer(hwnd, ID_TIMERPOP);
    1522                 SetTimer(hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0);
    1523                 TRACE("timer 2 restarted\n");
    1524             }
    1525             break;
     1535
     1536    if (lParam == 0)
     1537    {
     1538//    ERR (tooltips, "lpMsg == NULL!\n");
     1539      return 0;
     1540    }
     1541
     1542    switch (lpMsg->message)
     1543    {
     1544        case WM_LBUTTONDOWN:
     1545        case WM_LBUTTONUP:
     1546        case WM_MBUTTONDOWN:
     1547        case WM_MBUTTONUP:
     1548        case WM_RBUTTONDOWN:
     1549        case WM_RBUTTONUP:
     1550            pt = lpMsg->pt;
     1551            ScreenToClient(lpMsg->hwnd,&pt);
     1552            infoPtr->nOldTool = infoPtr->nTool;
     1553            infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr,lpMsg->hwnd,&pt);
     1554//          TRACE (tooltips, "tool (%x) %d %d\n",
     1555//                 hwnd, infoPtr->nOldTool, infoPtr->nTool);
     1556            TOOLTIPS_Hide (hwnd, infoPtr);
     1557            break;
     1558
     1559        case WM_MOUSEMOVE:
     1560            pt = lpMsg->pt;
     1561            ScreenToClient(lpMsg->hwnd,&pt);
     1562            infoPtr->nOldTool = infoPtr->nTool;
     1563            infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr,lpMsg->hwnd,&pt);
     1564            //TRACE (tooltips, "tool (%x) %d %d\n",
     1565            //       hwnd, infoPtr->nOldTool, infoPtr->nTool);
     1566            //TRACE (tooltips, "WM_MOUSEMOVE (%04x %ld %ld)\n",
     1567            //       hwnd, pt.x, pt.y);
     1568
     1569            if (infoPtr->bActive && (infoPtr->nTool != infoPtr->nOldTool))
     1570            {
     1571              if (infoPtr->nOldTool == -1)
     1572              {
     1573                SetTimer(hwnd,ID_TIMERSHOW,infoPtr->nInitialTime,0);
     1574                //TRACE (tooltips, "timer 1 started!\n");
     1575              } else
     1576              {
     1577                /*
     1578                 * Need to set nCurrentTool to nOldTool so we hide the tool.
     1579                 *  nTool and nOldTool values change when the mouse leaves the window.
     1580                 * If using TTM_UPDATETIPTEXT we can end up with an nCurrentTool = -1 if the
     1581                 * text can't be found, thus the tooltip would never be hidden.
     1582                 */
     1583                if (infoPtr->nTool != infoPtr->nOldTool)
     1584                  infoPtr->nCurrentTool = infoPtr->nOldTool;
     1585
     1586                TOOLTIPS_Hide(hwnd,infoPtr);
     1587                SetTimer (hwnd,ID_TIMERSHOW,infoPtr->nReshowTime,0);
     1588                //TRACE (tooltips, "timer 2 started!\n");
     1589              }
     1590            }
     1591            if (infoPtr->nCurrentTool != -1)
     1592            {
     1593              SetTimer(hwnd,ID_TIMERLEAVE,100,0);
     1594              //TRACE (tooltips, "timer 3 started!\n");
     1595            }
     1596            break;
    15261597    }
    15271598
     
    15371608
    15381609    switch (wParam) {
    1539     case TTDT_AUTOMATIC:
    1540         if (nTime <= 0)
    1541             nTime = GetDoubleClickTime();
    1542         infoPtr->nReshowTime    = nTime / 5;
    1543         infoPtr->nAutoPopTime   = nTime * 10;
    1544         infoPtr->nInitialTime   = nTime;
    1545         break;
    1546 
    1547     case TTDT_RESHOW:
    1548         if(nTime < 0)
    1549             nTime = GetDoubleClickTime() / 5;
    1550         infoPtr->nReshowTime = nTime;
    1551         break;
    1552 
    1553     case TTDT_AUTOPOP:
    1554         if(nTime < 0)
    1555             nTime = GetDoubleClickTime() * 10;
    1556         infoPtr->nAutoPopTime = nTime;
    1557         break;
    1558 
    1559     case TTDT_INITIAL:
    1560         if(nTime < 0)
    1561             nTime = GetDoubleClickTime();
    1562         infoPtr->nInitialTime = nTime;
    1563             break;
    1564 
    1565     default:
    1566         WARN("Invalid wParam %x\n", wParam);
    1567         break;
     1610        case TTDT_AUTOMATIC:
     1611            if (nTime == 0) {
     1612                infoPtr->nAutomaticTime = 500;
     1613                infoPtr->nReshowTime    = 100;
     1614                infoPtr->nAutoPopTime   = 5000;
     1615                infoPtr->nInitialTime   = 500;
     1616            }
     1617            else {
     1618                infoPtr->nAutomaticTime = nTime;
     1619                infoPtr->nReshowTime    = nTime / 5;
     1620                infoPtr->nAutoPopTime   = nTime * 10;
     1621                infoPtr->nInitialTime   = nTime;
     1622            }
     1623            break;
     1624
     1625        case TTDT_RESHOW:
     1626            infoPtr->nReshowTime = nTime;
     1627            break;
     1628
     1629        case TTDT_AUTOPOP:
     1630            infoPtr->nAutoPopTime = nTime;
     1631            break;
     1632
     1633        case TTDT_INITIAL:
     1634            infoPtr->nInitialTime = nTime;
     1635            break;
    15681636    }
    15691637
     
    15871655
    15881656
    1589 inline static LRESULT
     1657static LRESULT
    15901658TOOLTIPS_SetMaxTipWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
    15911659{
     
    15991667
    16001668
    1601 inline static LRESULT
     1669static LRESULT
    16021670TOOLTIPS_SetTipBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
    16031671{
     
    16101678
    16111679
    1612 inline static LRESULT
     1680static LRESULT
    16131681TOOLTIPS_SetTipTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
    16141682{
     
    16301698
    16311699    if (lpToolInfo == NULL)
    1632         return 0;
     1700        return 0;
    16331701    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    1634         return 0;
     1702        return 0;
    16351703
    16361704    nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
    16371705    if (nTool == -1) return 0;
    16381706
    1639     TRACE("tool %d\n", nTool);
     1707//    TRACE (tooltips, "tool %d\n", nTool);
    16401708
    16411709    toolPtr = &infoPtr->tools[nTool];
     
    16491717
    16501718    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
    1651         TRACE("set string id %x!\n", (INT)lpToolInfo->lpszText);
    1652         toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
     1719//      TRACE (tooltips, "set string id %x!\n", (INT)lpToolInfo->lpszText);
     1720        toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
    16531721    }
    16541722    else if (lpToolInfo->lpszText) {
    1655         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
    1656             toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    1657         else {
    1658             if ( (toolPtr->lpszText) &&
    1659                  (HIWORD((INT)toolPtr->lpszText) != 0) ) {
    1660                 COMCTL32_Free (toolPtr->lpszText);
    1661                 toolPtr->lpszText = NULL;
    1662             }
    1663             if (lpToolInfo->lpszText) {
    1664                 INT len = MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText,
    1665                                               -1, NULL, 0);
    1666                 toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc (len * sizeof(WCHAR));
    1667                 MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, -1,
    1668                                     toolPtr->lpszText, len);
    1669             }
    1670         }
     1723        if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
     1724            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     1725        else {
     1726            if ( (toolPtr->lpszText) &&
     1727                 (HIWORD((INT)toolPtr->lpszText) != 0) ) {
     1728                COMCTL32_Free (toolPtr->lpszText);
     1729                toolPtr->lpszText = NULL;
     1730            }
     1731            if (lpToolInfo->lpszText) {
     1732                INT len = lstrlenA (lpToolInfo->lpszText);
     1733                toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1734                lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
     1735            }
     1736        }
    16711737    }
    16721738
    16731739    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
    1674         toolPtr->lParam = lpToolInfo->lParam;
     1740        toolPtr->lParam = lpToolInfo->lParam;
    16751741
    16761742    return 0;
     
    16871753
    16881754    if (lpToolInfo == NULL)
    1689         return 0;
     1755        return 0;
    16901756    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    1691         return 0;
     1757        return 0;
    16921758
    16931759    nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
    16941760    if (nTool == -1) return 0;
    16951761
    1696     TRACE("tool %d\n", nTool);
     1762//    TRACE (tooltips, "tool %d\n", nTool);
    16971763
    16981764    toolPtr = &infoPtr->tools[nTool];
     
    17061772
    17071773    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
    1708         TRACE("set string id %x!\n", (INT)lpToolInfo->lpszText);
    1709         toolPtr->lpszText = lpToolInfo->lpszText;
     1774//      TRACE (tooltips, "set string id %x!\n", (INT)lpToolInfo->lpszText);
     1775        toolPtr->lpszText = lpToolInfo->lpszText;
    17101776    }
    17111777    else if (lpToolInfo->lpszText) {
    1712         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
    1713             toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    1714         else {
    1715             if ( (toolPtr->lpszText) &&
    1716                 (HIWORD((INT)toolPtr->lpszText) != 0) ) {
    1717                 COMCTL32_Free (toolPtr->lpszText);
    1718                 toolPtr->lpszText = NULL;
    1719             }
    1720             if (lpToolInfo->lpszText) {
    1721                 INT len = lstrlenW (lpToolInfo->lpszText);
    1722                 toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    1723                 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
    1724             }
    1725         }
     1778        if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
     1779            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     1780        else {
     1781            if ( (toolPtr->lpszText) &&
     1782                (HIWORD((INT)toolPtr->lpszText) != 0) ) {
     1783                COMCTL32_Free (toolPtr->lpszText);
     1784                toolPtr->lpszText = NULL;
     1785            }
     1786            if (lpToolInfo->lpszText) {
     1787                INT len = lstrlenW (lpToolInfo->lpszText);
     1788                toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1789                lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
     1790            }
     1791        }
    17261792    }
    17271793
    17281794    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
    1729         toolPtr->lParam = lpToolInfo->lParam;
     1795        toolPtr->lParam = lpToolInfo->lParam;
    17301796
    17311797    return 0;
     
    17391805    LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
    17401806
    1741     if (lpToolInfo == NULL)
    1742         return 0;
    1743     if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    1744         return FALSE;
    1745 
    1746     if ((BOOL)wParam) {
    1747         /* activate */
    1748         infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
    1749         if (infoPtr->nTrackTool != -1) {
    1750             TRACE("activated!\n");
    1751             infoPtr->bTrackActive = TRUE;
    1752             TOOLTIPS_TrackShow (hwnd, infoPtr);
    1753         }
    1754     }
    1755     else {
    1756         /* deactivate */
    1757         TOOLTIPS_TrackHide (hwnd, infoPtr);
    1758 
    1759         infoPtr->bTrackActive = FALSE;
    1760         infoPtr->nTrackTool = -1;
    1761 
    1762         TRACE("deactivated!\n");
     1807    if (lpToolInfo == NULL) return 0;
     1808    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) return FALSE;
     1809
     1810    if ((BOOL)wParam)
     1811    {
     1812      /* activate */
     1813      infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA(infoPtr,lpToolInfo);
     1814      if (infoPtr->nTrackTool != -1)
     1815      {
     1816        //TRACE (tooltips, "activated!\n");
     1817        infoPtr->bTrackActive = TRUE;
     1818        TOOLTIPS_TrackShow(hwnd,infoPtr);
     1819      }
     1820    } else
     1821    {
     1822      /* deactivate */
     1823      TOOLTIPS_TrackHide(hwnd,infoPtr);
     1824
     1825      infoPtr->bTrackActive = FALSE;
     1826      infoPtr->nTrackTool = -1;
     1827
     1828      //TRACE (tooltips, "deactivated!\n");
    17631829    }
    17641830
     
    17751841    infoPtr->yTrackPos = (INT)HIWORD(lParam);
    17761842
    1777     if (infoPtr->bTrackActive) {
    1778         TRACE("[%d %d]\n",
    1779                infoPtr->xTrackPos, infoPtr->yTrackPos);
    1780 
    1781         TOOLTIPS_TrackShow (hwnd, infoPtr);
     1843    if (infoPtr->bTrackActive)
     1844    {
     1845//      TRACE (tooltips, "[%d %d]\n",
     1846//             infoPtr->xTrackPos, infoPtr->yTrackPos);
     1847      TOOLTIPS_TrackShow(hwnd,infoPtr);
    17821848    }
    17831849
     
    17921858
    17931859    if (infoPtr->nCurrentTool != -1)
    1794         UpdateWindow (hwnd);
    1795 
    1796     return 0;
    1797 }
    1798 
    1799 
    1800 static LRESULT
     1860        UpdateWindow (hwnd);
     1861
     1862    return 0;
     1863}
     1864
     1865
    18011866TOOLTIPS_UpdateTipTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    18021867{
     
    18071872
    18081873    if (lpToolInfo == NULL)
    1809         return 0;
     1874        return 0;
    18101875    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    1811         return FALSE;
     1876        return FALSE;
    18121877
    18131878    nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
    18141879    if (nTool == -1) return 0;
    18151880
    1816     TRACE("tool %d\n", nTool);
     1881//    TRACE("tool %d\n", nTool);
    18171882
    18181883    toolPtr = &infoPtr->tools[nTool];
     
    18221887
    18231888    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){
    1824         toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
     1889        toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
    18251890    }
    18261891    else if (lpToolInfo->lpszText) {
    1827         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
    1828             toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    1829         else {
    1830             if ( (toolPtr->lpszText) &&
    1831                  (HIWORD((INT)toolPtr->lpszText) != 0) ) {
    1832                 COMCTL32_Free (toolPtr->lpszText);
    1833                 toolPtr->lpszText = NULL;
    1834             }
    1835             if (lpToolInfo->lpszText) {
    1836                 INT len = MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText,
    1837                                               -1, NULL, 0);
    1838                 toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc (len * sizeof(WCHAR));
    1839                 MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, -1,
    1840                                     toolPtr->lpszText, len);
    1841             }
    1842         }
     1892        if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
     1893            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     1894        else {
     1895            if ( (toolPtr->lpszText) &&
     1896                 (HIWORD((INT)toolPtr->lpszText) != 0) ) {
     1897                COMCTL32_Free (toolPtr->lpszText);
     1898                toolPtr->lpszText = NULL;
     1899            }
     1900            if (lpToolInfo->lpszText) {
     1901                INT len = lstrlenA (lpToolInfo->lpszText);
     1902                toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1903                lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
     1904            }
     1905        }
    18431906    }
    18441907
    18451908    /* force repaint */
    18461909    if (infoPtr->bActive)
    1847         TOOLTIPS_Show (hwnd, infoPtr);
     1910        TOOLTIPS_Show (hwnd, infoPtr);
    18481911    else if (infoPtr->bTrackActive)
    1849         TOOLTIPS_TrackShow (hwnd, infoPtr);
     1912        TOOLTIPS_TrackShow (hwnd, infoPtr);
    18501913
    18511914    return 0;
     
    18621925
    18631926    if (lpToolInfo == NULL)
    1864         return 0;
     1927        return 0;
    18651928    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    1866         return FALSE;
     1929        return FALSE;
    18671930
    18681931    nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
    18691932    if (nTool == -1)
    1870         return 0;
    1871 
    1872     TRACE("tool %d\n", nTool);
     1933        return 0;
     1934
     1935//    TRACE("tool %d\n", nTool);
    18731936
    18741937    toolPtr = &infoPtr->tools[nTool];
     
    18781941
    18791942    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){
    1880         toolPtr->lpszText = lpToolInfo->lpszText;
     1943        toolPtr->lpszText = lpToolInfo->lpszText;
    18811944    }
    18821945    else if (lpToolInfo->lpszText) {
    1883         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
    1884             toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    1885         else {
    1886             if ( (toolPtr->lpszText)  &&
    1887                 (HIWORD((INT)toolPtr->lpszText) != 0) ) {
    1888                 COMCTL32_Free (toolPtr->lpszText);
    1889                 toolPtr->lpszText = NULL;
    1890             }
    1891             if (lpToolInfo->lpszText) {
    1892                 INT len = lstrlenW (lpToolInfo->lpszText);
    1893                 toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    1894                 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
    1895             }
    1896         }
     1946        if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
     1947            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     1948        else {
     1949            if ( (toolPtr->lpszText)  &&
     1950                (HIWORD((INT)toolPtr->lpszText) != 0) ) {
     1951                COMCTL32_Free (toolPtr->lpszText);
     1952                toolPtr->lpszText = NULL;
     1953            }
     1954            if (lpToolInfo->lpszText) {
     1955                INT len = lstrlenW (lpToolInfo->lpszText);
     1956                toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1957                lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
     1958            }
     1959        }
    18971960    }
    18981961
    18991962    /* force repaint */
    19001963    if (infoPtr->bActive)
    1901         TOOLTIPS_Show (hwnd, infoPtr);
     1964        TOOLTIPS_Show (hwnd, infoPtr);
    19021965    else if (infoPtr->bTrackActive)
    1903         TOOLTIPS_TrackShow (hwnd, infoPtr);
     1966        TOOLTIPS_TrackShow (hwnd, infoPtr);
    19041967
    19051968    return 0;
     
    19231986
    19241987    /* allocate memory for info structure */
    1925     infoPtr = (TOOLTIPS_INFO *)COMCTL32_Alloc (sizeof(TOOLTIPS_INFO));
    1926     SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
     1988    infoPtr = (TOOLTIPS_INFO*)initControl(hwnd,sizeof(TOOLTIPS_INFO));
    19271989
    19281990    /* initialize info structure */
     1991    infoPtr->szTipText[0] = '\0';
    19291992    infoPtr->bActive = TRUE;
    19301993    infoPtr->bTrackActive = FALSE;
    1931     infoPtr->clrBk   = GetSysColor (COLOR_INFOBK);
    1932     infoPtr->clrText = GetSysColor (COLOR_INFOTEXT);
     1994    infoPtr->clrBk   = GetSysColor(COLOR_INFOBK);
     1995    infoPtr->clrText = GetSysColor(COLOR_INFOTEXT);
     1996    infoPtr->xTrackPos = 0;
     1997    infoPtr->yTrackPos = 0;
    19331998
    19341999    nclm.cbSize = sizeof(NONCLIENTMETRICSA);
    1935     SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
    1936     infoPtr->hFont = CreateFontIndirectA (&nclm.lfStatusFont);
     2000    SystemParametersInfoA(SPI_GETNONCLIENTMETRICS,0,&nclm,0);
     2001    infoPtr->hFont = CreateFontIndirectA(&nclm.lfStatusFont);
    19372002
    19382003    infoPtr->nMaxTipWidth = -1;
    19392004    infoPtr->nTool = -1;
     2005    infoPtr->nOldTool = -1;
    19402006    infoPtr->nCurrentTool = -1;
    19412007    infoPtr->nTrackTool = -1;
    19422008
    1943     TOOLTIPS_SetDelayTime(hwnd, TTDT_AUTOMATIC, 0L);
    1944 
    1945     nResult = (INT) SendMessageA (GetParent (hwnd), WM_NOTIFYFORMAT,
    1946                                   (WPARAM)hwnd, (LPARAM)NF_QUERY);
    1947     if (nResult == NFR_ANSI) {
    1948         infoPtr->bNotifyUnicode = FALSE;
    1949         TRACE(" -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
    1950     }
    1951     else if (nResult == NFR_UNICODE) {
    1952         infoPtr->bNotifyUnicode = TRUE;
    1953         TRACE(" -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
    1954     }
    1955     else {
    1956         ERR (" -- WM_NOTIFYFORMAT returns: error!\n");
    1957     }
    1958 
    1959     SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
     2009    infoPtr->nAutomaticTime = 500;
     2010    infoPtr->nReshowTime    = 100;
     2011    infoPtr->nAutoPopTime   = 5000;
     2012    infoPtr->nInitialTime   = 500;
     2013
     2014    SetRectEmpty(&infoPtr->rcMargin);
     2015
     2016    SetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
    19602017
    19612018    return 0;
     
    19662023TOOLTIPS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
    19672024{
    1968     TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
     2025    TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
    19692026    TTTOOL_INFO *toolPtr;
    19702027    INT i;
     
    19722029    /* free tools */
    19732030    if (infoPtr->tools) {
    1974         for (i = 0; i < infoPtr->uNumTools; i++) {
    1975             toolPtr = &infoPtr->tools[i];
    1976             if ((toolPtr->hinst) && (toolPtr->lpszText)) {
    1977                 if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
    1978                      (HIWORD((INT)toolPtr->lpszText) != 0) )
    1979                 {
    1980                     COMCTL32_Free (toolPtr->lpszText);
    1981                     toolPtr->lpszText = NULL;
    1982                 }
    1983             }
    1984 
    1985             /* remove subclassing */
    1986             if (toolPtr->uFlags & TTF_SUBCLASS) {
    1987                 LPTT_SUBCLASS_INFO lpttsi;
    1988 
    1989                 if (toolPtr->uFlags & TTF_IDISHWND)
    1990                     lpttsi = (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    1991                 else
    1992                     lpttsi = (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
    1993 
    1994                 if (lpttsi) {
    1995                     SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
    1996                                       (LONG)lpttsi->wpOrigProc);
    1997                     RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    1998                     COMCTL32_Free (&lpttsi);
    1999                 }
    2000             }
    2001         }
    2002         COMCTL32_Free (infoPtr->tools);
     2031        for (i = 0; i < infoPtr->uNumTools; i++) {
     2032            toolPtr = &infoPtr->tools[i];
     2033            if ((toolPtr->hinst) && (toolPtr->lpszText)) {
     2034                if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
     2035                     (HIWORD((INT)toolPtr->lpszText) != 0) )
     2036                {
     2037                    COMCTL32_Free (toolPtr->lpszText);
     2038                    toolPtr->lpszText = NULL;
     2039                }
     2040            }
     2041
     2042            /* remove subclassing */
     2043            if (toolPtr->uFlags & TTF_SUBCLASS) {
     2044                LPTT_SUBCLASS_INFO lpttsi;
     2045
     2046                if (toolPtr->uFlags & TTF_IDISHWND)
     2047                    lpttsi = (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
     2048                else
     2049                    lpttsi = (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
     2050
     2051                if (lpttsi) {
     2052                    SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
     2053                                      (LONG)lpttsi->wpOrigProc);
     2054                    RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
     2055                    COMCTL32_Free (&lpttsi);
     2056                }
     2057            }
     2058      }
     2059      COMCTL32_Free (infoPtr->tools);
    20032060    }
    20042061
     
    20072064
    20082065    /* free tool tips info data */
    2009     COMCTL32_Free (infoPtr);
    2010     SetWindowLongA(hwnd, 0, 0);
     2066    doneControl(hwnd);
     2067
    20112068    return 0;
    20122069}
     
    20412098TOOLTIPS_MouseMessage (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    20422099{
    2043     TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
    2044 
     2100  TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
     2101
     2102  if (infoPtr->nTrackTool > -1)
     2103  {
     2104    //CB: tocheck: tracking tool without TTF_TRANSPARENT style
     2105  } else
     2106  {
    20452107    TOOLTIPS_Hide (hwnd, infoPtr);
    2046 
    2047     return 0;
     2108  }
     2109
     2110  return 0;
    20482111}
    20492112
     
    20522115TOOLTIPS_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
    20532116{
    2054     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     2117    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     2118    DWORD dwExStyle = GetWindowLongA(hwnd,GWL_EXSTYLE);
    20552119
    20562120    dwStyle &= 0x0000FFFF;
    20572121    dwStyle |= (WS_POPUP | WS_BORDER | WS_CLIPSIBLINGS);
    2058     SetWindowLongA (hwnd, GWL_STYLE, dwStyle);
     2122    SetWindowLongA(hwnd,GWL_STYLE,dwStyle);
     2123
     2124    SetWindowLongA(hwnd,GWL_EXSTYLE,dwExStyle | WS_EX_TOOLWINDOW);
    20592125
    20602126    return TRUE;
     
    20682134    INT nTool = (infoPtr->bTrackActive) ? infoPtr->nTrackTool : infoPtr->nTool;
    20692135
    2070     TRACE(" nTool=%d\n", nTool);
     2136//    TRACE (tooltips, " nTool=%d\n", nTool);
    20712137
    20722138    if ((nTool > -1) && (nTool < infoPtr->uNumTools)) {
    2073         if (infoPtr->tools[nTool].uFlags & TTF_TRANSPARENT) {
    2074             TRACE("-- in transparent mode!\n");
    2075             return HTTRANSPARENT;
    2076         }
     2139        if (infoPtr->tools[nTool].uFlags & TTF_TRANSPARENT) {
     2140//          TRACE (tooltips, "-- in transparent mode!\n");
     2141            return HTTRANSPARENT;
     2142        }
    20772143    }
    20782144
    20792145    return DefWindowProcA (hwnd, WM_NCHITTEST, wParam, lParam);
    20802146}
    2081 
    2082 
    2083 static LRESULT
    2084 TOOLTIPS_NotifyFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2085 {
    2086     FIXME ("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam);
    2087 
    2088     return 0;
    2089 }
    2090 
    20912147
    20922148static LRESULT
     
    20972153
    20982154    hdc = (wParam == 0) ? BeginPaint (hwnd, &ps) : (HDC)wParam;
    2099     TOOLTIPS_Refresh (hwnd, hdc);
     2155    TOOLTIPS_Draw(hwnd, hdc);
    21002156    if (!wParam)
    2101         EndPaint (hwnd, &ps);
     2157        EndPaint (hwnd, &ps);
    21022158    return 0;
    21032159}
     
    21112167    infoPtr->hFont = (HFONT)wParam;
    21122168
    2113     if ((LOWORD(lParam)) && (infoPtr->nCurrentTool != -1)) {
    2114         FIXME("full redraw needed!\n");
     2169    if ((LOWORD(lParam)) && (infoPtr->nCurrentTool != -1))
     2170    {
     2171      /* force repaint */
     2172      if (infoPtr->bActive) TOOLTIPS_Show(hwnd,infoPtr);
     2173      else if (infoPtr->bTrackActive) TOOLTIPS_TrackShow(hwnd,infoPtr);
    21152174    }
    21162175
     
    21272186 * returns the length, in characters, of the tip text
    21282187 ******************************************************************/
     2188
    21292189static LRESULT
    21302190TOOLTIPS_OnWMGetTextLength(HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    21332193    return lstrlenW(infoPtr->szTipText);
    21342194}
    2135 
    21362195/******************************************************************
    21372196 * TOOLTIPS_OnWMGetText
     
    21492208{
    21502209    TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
     2210    INT length;
    21512211
    21522212    if(!infoPtr || !(infoPtr->szTipText))
    21532213        return 0;
    21542214
    2155     return WideCharToMultiByte(CP_ACP, 0, infoPtr->szTipText, -1,
    2156                                (LPSTR)lParam, wParam, NULL, NULL);
     2215    length = lstrlenW(infoPtr->szTipText);
     2216    /* When wParam is smaller than the lenght of the tip text
     2217       copy wParam characters of the tip text and return wParam */
     2218    if(wParam < length)
     2219    {
     2220        lstrcpynWtoA((LPSTR)lParam,infoPtr->szTipText,(UINT)wParam);//includes 0 terminator
     2221        return wParam;
     2222    }
     2223    lstrcpyWtoA((LPSTR)lParam,infoPtr->szTipText);
     2224    return length;
     2225
    21572226}
    21582227
     
    21612230{
    21622231    TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
    2163     INT nOldTool;
    2164 
    2165     TRACE("timer %d (%x) expired!\n", wParam, hwnd);
    2166 
    2167     switch (wParam) {
    2168     case ID_TIMERSHOW:
    2169         KillTimer (hwnd, ID_TIMERSHOW);
    2170         nOldTool = infoPtr->nTool;
    2171         if ((infoPtr->nTool = TOOLTIPS_CheckTool (hwnd, TRUE)) == nOldTool)
    2172             TOOLTIPS_Show (hwnd, infoPtr);
    2173         break;
    2174 
    2175     case ID_TIMERPOP:
    2176         TOOLTIPS_Hide (hwnd, infoPtr);
    2177         break;
    2178 
    2179     case ID_TIMERLEAVE:
    2180         nOldTool = infoPtr->nTool;
    2181         infoPtr->nTool = TOOLTIPS_CheckTool (hwnd, FALSE);
    2182         TRACE("tool (%x) %d %d %d\n", hwnd, nOldTool,
    2183               infoPtr->nTool, infoPtr->nCurrentTool);
    2184         if (infoPtr->nTool != nOldTool) {
    2185             if(infoPtr->nTool == -1) { /* Moved out of all tools */
    2186                 TOOLTIPS_Hide(hwnd, infoPtr);
    2187                 KillTimer(hwnd, ID_TIMERLEAVE);
    2188             } else if (nOldTool == -1) { /* Moved from outside */
    2189                 ERR("How did this happen?\n");
    2190             } else { /* Moved from one to another */
    2191                 TOOLTIPS_Hide (hwnd, infoPtr);
    2192                 KillTimer(hwnd, ID_TIMERLEAVE);
    2193                 if(infoPtr->bActive) {
    2194                     SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0);
    2195                     TRACE("timer 1 started!\n");
    2196                 }
    2197             }
    2198         }
    2199         break;
    2200 
    2201     default:
    2202         ERR("Unknown timer id %d\n", wParam);
    2203         break;
    2204     }
     2232
     2233//    TRACE (tooltips, "timer %d (%x) expired!\n", wParam, hwnd);
     2234    switch (wParam)
     2235    {
     2236      case ID_TIMERSHOW:
     2237          KillTimer(hwnd,ID_TIMERSHOW);
     2238          if (TOOLTIPS_CheckTool(hwnd,TRUE) == infoPtr->nTool)
     2239              TOOLTIPS_Show(hwnd,infoPtr);
     2240          break;
     2241
     2242      case ID_TIMERPOP:
     2243          TOOLTIPS_Hide (hwnd, infoPtr);
     2244          break;
     2245
     2246      case ID_TIMERLEAVE:
     2247          KillTimer (hwnd,ID_TIMERLEAVE);
     2248          if (TOOLTIPS_CheckTool(hwnd,FALSE) == -1)
     2249          {
     2250            infoPtr->nTool = -1;
     2251            infoPtr->nOldTool = -1;
     2252            TOOLTIPS_Hide(hwnd,infoPtr);
     2253          }
     2254          break;
     2255    }
     2256
    22052257    return 0;
    22062258}
     
    22242276}
    22252277
     2278LRESULT TOOLTIPS_MouseActivate(HWND hwnd,WPARAM wParam,LPARAM lParam)
     2279{
     2280  return MA_NOACTIVATE;
     2281}
    22262282
    22272283LRESULT CALLBACK
     
    22292285{
    22302286    LPTT_SUBCLASS_INFO lpttsi =
    2231         (LPTT_SUBCLASS_INFO)GetPropA (hwnd, COMCTL32_aSubclass);
    2232     MSG msg;
    2233 
    2234     switch(uMsg) {
    2235     case WM_MOUSEMOVE:
    2236     case WM_LBUTTONDOWN:
    2237     case WM_LBUTTONUP:
    2238     case WM_MBUTTONDOWN:
    2239     case WM_MBUTTONUP:
    2240     case WM_RBUTTONDOWN:
    2241     case WM_RBUTTONUP:
    2242         msg.hwnd = hwnd;
    2243         msg.message = uMsg;
    2244         msg.wParam = wParam;
    2245         msg.lParam = lParam;
    2246         TOOLTIPS_RelayEvent(lpttsi->hwndToolTip, 0, (LPARAM)&msg);
    2247         break;
    2248 
    2249     default:
    2250         break;
    2251     }
     2287        (LPTT_SUBCLASS_INFO)GetPropA (hwnd, COMCTL32_aSubclass);
     2288    TOOLTIPS_INFO *infoPtr;
     2289    UINT nTool;
     2290
     2291    switch (uMsg) {
     2292        case WM_LBUTTONDOWN:
     2293        case WM_LBUTTONUP:
     2294        case WM_MBUTTONDOWN:
     2295        case WM_MBUTTONUP:
     2296        case WM_RBUTTONDOWN:
     2297        case WM_RBUTTONUP:
     2298            infoPtr = TOOLTIPS_GetInfoPtr(lpttsi->hwndToolTip);
     2299            if (!infoPtr) break;
     2300            nTool = TOOLTIPS_GetToolFromMessage (infoPtr, hwnd);
     2301
     2302            infoPtr->nOldTool = infoPtr->nTool;
     2303            infoPtr->nTool = nTool;
     2304            TOOLTIPS_Hide (lpttsi->hwndToolTip, infoPtr);
     2305            break;
     2306
     2307        case WM_MOUSEMOVE:
     2308                infoPtr = TOOLTIPS_GetInfoPtr (lpttsi->hwndToolTip);
     2309                if (!infoPtr) break;
     2310                nTool = TOOLTIPS_GetToolFromMessage (infoPtr, hwnd);
     2311
     2312                infoPtr->nOldTool = infoPtr->nTool;
     2313                infoPtr->nTool = nTool;
     2314
     2315                if ((infoPtr->bActive) &&
     2316                    (infoPtr->nTool != infoPtr->nOldTool)) {
     2317                    if (infoPtr->nOldTool == -1) {
     2318                    SetTimer (hwnd, ID_TIMERSHOW,
     2319                                    infoPtr->nInitialTime, 0);
     2320                      //TRACE (tooltips, "timer 1 started!\n");
     2321                    }
     2322                    else {
     2323                    TOOLTIPS_Hide (lpttsi->hwndToolTip, infoPtr);
     2324                    SetTimer (hwnd, ID_TIMERSHOW,
     2325                                infoPtr->nReshowTime, 0);
     2326//                      TRACE (tooltips, "timer 2 started!\n");
     2327                    }
     2328                }
     2329                if (infoPtr->nCurrentTool != -1) {
     2330                SetTimer (hwnd, ID_TIMERLEAVE, 100, 0);
     2331//                  TRACE (tooltips, "timer 3 started!\n");
     2332                }
     2333            break;
     2334    }
     2335
    22522336    return CallWindowProcA (lpttsi->wpOrigProc, hwnd, uMsg, wParam, lParam);
    22532337}
     
    22572341TOOLTIPS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    22582342{
    2259     TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
    2260     if (!TOOLTIPS_GetInfoPtr(hwnd) && (uMsg != WM_CREATE) && (uMsg != WM_NCCREATE))
    2261         return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    22622343    switch (uMsg)
    22632344    {
    2264         case TTM_ACTIVATE:
    2265             return TOOLTIPS_Activate (hwnd, wParam, lParam);
    2266 
    2267         case TTM_ADDTOOLA:
    2268             return TOOLTIPS_AddToolA (hwnd, wParam, lParam);
    2269 
    2270         case TTM_ADDTOOLW:
    2271             return TOOLTIPS_AddToolW (hwnd, wParam, lParam);
    2272 
    2273         case TTM_DELTOOLA:
    2274             return TOOLTIPS_DelToolA (hwnd, wParam, lParam);
    2275 
    2276         case TTM_DELTOOLW:
    2277             return TOOLTIPS_DelToolW (hwnd, wParam, lParam);
    2278 
    2279         case TTM_ENUMTOOLSA:
    2280             return TOOLTIPS_EnumToolsA (hwnd, wParam, lParam);
    2281 
    2282         case TTM_ENUMTOOLSW:
    2283             return TOOLTIPS_EnumToolsW (hwnd, wParam, lParam);
    2284 
    2285         case TTM_GETCURRENTTOOLA:
    2286             return TOOLTIPS_GetCurrentToolA (hwnd, wParam, lParam);
    2287 
    2288         case TTM_GETCURRENTTOOLW:
    2289             return TOOLTIPS_GetCurrentToolW (hwnd, wParam, lParam);
    2290 
    2291         case TTM_GETDELAYTIME:
    2292             return TOOLTIPS_GetDelayTime (hwnd, wParam, lParam);
    2293 
    2294         case TTM_GETMARGIN:
    2295             return TOOLTIPS_GetMargin (hwnd, wParam, lParam);
    2296 
    2297         case TTM_GETMAXTIPWIDTH:
    2298             return TOOLTIPS_GetMaxTipWidth (hwnd, wParam, lParam);
    2299 
    2300         case TTM_GETTEXTA:
    2301             return TOOLTIPS_GetTextA (hwnd, wParam, lParam);
    2302 
    2303         case TTM_GETTEXTW:
    2304             return TOOLTIPS_GetTextW (hwnd, wParam, lParam);
    2305 
    2306         case TTM_GETTIPBKCOLOR:
    2307             return TOOLTIPS_GetTipBkColor (hwnd, wParam, lParam);
    2308 
    2309         case TTM_GETTIPTEXTCOLOR:
    2310             return TOOLTIPS_GetTipTextColor (hwnd, wParam, lParam);
    2311 
    2312         case TTM_GETTOOLCOUNT:
    2313             return TOOLTIPS_GetToolCount (hwnd, wParam, lParam);
    2314 
    2315         case TTM_GETTOOLINFOA:
    2316             return TOOLTIPS_GetToolInfoA (hwnd, wParam, lParam);
    2317 
    2318         case TTM_GETTOOLINFOW:
    2319             return TOOLTIPS_GetToolInfoW (hwnd, wParam, lParam);
    2320 
    2321         case TTM_HITTESTA:
    2322             return TOOLTIPS_HitTestA (hwnd, wParam, lParam);
    2323 
    2324         case TTM_HITTESTW:
    2325             return TOOLTIPS_HitTestW (hwnd, wParam, lParam);
    2326 
    2327         case TTM_NEWTOOLRECTA:
    2328             return TOOLTIPS_NewToolRectA (hwnd, wParam, lParam);
    2329 
    2330         case TTM_NEWTOOLRECTW:
    2331             return TOOLTIPS_NewToolRectW (hwnd, wParam, lParam);
    2332 
    2333         case TTM_POP:
    2334             return TOOLTIPS_Pop (hwnd, wParam, lParam);
    2335 
    2336         case TTM_RELAYEVENT:
    2337             return TOOLTIPS_RelayEvent (hwnd, wParam, lParam);
    2338 
    2339         case TTM_SETDELAYTIME:
    2340             return TOOLTIPS_SetDelayTime (hwnd, wParam, lParam);
    2341 
    2342         case TTM_SETMARGIN:
    2343             return TOOLTIPS_SetMargin (hwnd, wParam, lParam);
    2344 
    2345         case TTM_SETMAXTIPWIDTH:
    2346             return TOOLTIPS_SetMaxTipWidth (hwnd, wParam, lParam);
    2347 
    2348         case TTM_SETTIPBKCOLOR:
    2349             return TOOLTIPS_SetTipBkColor (hwnd, wParam, lParam);
    2350 
    2351         case TTM_SETTIPTEXTCOLOR:
    2352             return TOOLTIPS_SetTipTextColor (hwnd, wParam, lParam);
    2353 
    2354         case TTM_SETTOOLINFOA:
    2355             return TOOLTIPS_SetToolInfoA (hwnd, wParam, lParam);
    2356 
    2357         case TTM_SETTOOLINFOW:
    2358             return TOOLTIPS_SetToolInfoW (hwnd, wParam, lParam);
    2359 
    2360         case TTM_TRACKACTIVATE:
    2361             return TOOLTIPS_TrackActivate (hwnd, wParam, lParam);
    2362 
    2363         case TTM_TRACKPOSITION:
    2364             return TOOLTIPS_TrackPosition (hwnd, wParam, lParam);
    2365 
    2366         case TTM_UPDATE:
    2367             return TOOLTIPS_Update (hwnd, wParam, lParam);
    2368 
    2369         case TTM_UPDATETIPTEXTA:
    2370             return TOOLTIPS_UpdateTipTextA (hwnd, wParam, lParam);
    2371 
    2372         case TTM_UPDATETIPTEXTW:
    2373             return TOOLTIPS_UpdateTipTextW (hwnd, wParam, lParam);
    2374 
    2375         case TTM_WINDOWFROMPOINT:
    2376             return TOOLTIPS_WindowFromPoint (hwnd, wParam, lParam);
    2377 
    2378 
    2379         case WM_CREATE:
    2380             return TOOLTIPS_Create (hwnd, wParam, lParam);
    2381 
    2382         case WM_DESTROY:
    2383             return TOOLTIPS_Destroy (hwnd, wParam, lParam);
    2384 
    2385         case WM_ERASEBKGND:
    2386             return TOOLTIPS_EraseBackground (hwnd, wParam, lParam);
    2387 
    2388         case WM_GETFONT:
    2389             return TOOLTIPS_GetFont (hwnd, wParam, lParam);
     2345        case TTM_ACTIVATE:
     2346            return TOOLTIPS_Activate (hwnd, wParam, lParam);
     2347
     2348        case TTM_ADDTOOLA:
     2349            return TOOLTIPS_AddToolA (hwnd, wParam, lParam);
     2350
     2351        case TTM_ADDTOOLW:
     2352            return TOOLTIPS_AddToolW (hwnd, wParam, lParam);
     2353
     2354        case TTM_DELTOOLA:
     2355            return TOOLTIPS_DelToolA (hwnd, wParam, lParam);
     2356
     2357        case TTM_DELTOOLW:
     2358            return TOOLTIPS_DelToolW (hwnd, wParam, lParam);
     2359
     2360        case TTM_ENUMTOOLSA:
     2361            return TOOLTIPS_EnumToolsA (hwnd, wParam, lParam);
     2362
     2363        case TTM_ENUMTOOLSW:
     2364            return TOOLTIPS_EnumToolsW (hwnd, wParam, lParam);
     2365
     2366        case TTM_GETCURRENTTOOLA:
     2367            return TOOLTIPS_GetCurrentToolA (hwnd, wParam, lParam);
     2368
     2369        case TTM_GETCURRENTTOOLW:
     2370            return TOOLTIPS_GetCurrentToolW (hwnd, wParam, lParam);
     2371
     2372        case TTM_GETDELAYTIME:
     2373            return TOOLTIPS_GetDelayTime (hwnd, wParam, lParam);
     2374
     2375        case TTM_GETMARGIN:
     2376            return TOOLTIPS_GetMargin (hwnd, wParam, lParam);
     2377
     2378        case TTM_GETMAXTIPWIDTH:
     2379            return TOOLTIPS_GetMaxTipWidth (hwnd, wParam, lParam);
     2380
     2381        case TTM_GETTEXTA:
     2382            return TOOLTIPS_GetTextA (hwnd, wParam, lParam);
     2383
     2384        case TTM_GETTEXTW:
     2385            return TOOLTIPS_GetTextW (hwnd, wParam, lParam);
     2386
     2387        case TTM_GETTIPBKCOLOR:
     2388            return TOOLTIPS_GetTipBkColor (hwnd, wParam, lParam);
     2389
     2390        case TTM_GETTIPTEXTCOLOR:
     2391            return TOOLTIPS_GetTipTextColor (hwnd, wParam, lParam);
     2392
     2393        case TTM_GETTOOLCOUNT:
     2394            return TOOLTIPS_GetToolCount (hwnd, wParam, lParam);
     2395
     2396        case TTM_GETTOOLINFOA:
     2397            return TOOLTIPS_GetToolInfoA (hwnd, wParam, lParam);
     2398
     2399        case TTM_GETTOOLINFOW:
     2400            return TOOLTIPS_GetToolInfoW (hwnd, wParam, lParam);
     2401
     2402        case TTM_HITTESTA:
     2403            return TOOLTIPS_HitTestA (hwnd, wParam, lParam);
     2404
     2405        case TTM_HITTESTW:
     2406            return TOOLTIPS_HitTestW (hwnd, wParam, lParam);
     2407
     2408        case TTM_NEWTOOLRECTA:
     2409            return TOOLTIPS_NewToolRectA (hwnd, wParam, lParam);
     2410
     2411        case TTM_NEWTOOLRECTW:
     2412            return TOOLTIPS_NewToolRectW (hwnd, wParam, lParam);
     2413
     2414        case TTM_POP:
     2415            return TOOLTIPS_Pop (hwnd, wParam, lParam);
     2416
     2417        case TTM_RELAYEVENT:
     2418            return TOOLTIPS_RelayEvent (hwnd, wParam, lParam);
     2419
     2420        case TTM_SETDELAYTIME:
     2421            return TOOLTIPS_SetDelayTime (hwnd, wParam, lParam);
     2422
     2423        case TTM_SETMARGIN:
     2424            return TOOLTIPS_SetMargin (hwnd, wParam, lParam);
     2425
     2426        case TTM_SETMAXTIPWIDTH:
     2427            return TOOLTIPS_SetMaxTipWidth (hwnd, wParam, lParam);
     2428
     2429        case TTM_SETTIPBKCOLOR:
     2430            return TOOLTIPS_SetTipBkColor (hwnd, wParam, lParam);
     2431
     2432        case TTM_SETTIPTEXTCOLOR:
     2433            return TOOLTIPS_SetTipTextColor (hwnd, wParam, lParam);
     2434
     2435        case TTM_SETTOOLINFOA:
     2436            return TOOLTIPS_SetToolInfoA (hwnd, wParam, lParam);
     2437
     2438        case TTM_SETTOOLINFOW:
     2439            return TOOLTIPS_SetToolInfoW (hwnd, wParam, lParam);
     2440
     2441        case TTM_TRACKACTIVATE:
     2442            return TOOLTIPS_TrackActivate (hwnd, wParam, lParam);
     2443
     2444        case TTM_TRACKPOSITION:
     2445            return TOOLTIPS_TrackPosition (hwnd, wParam, lParam);
     2446
     2447        case TTM_UPDATE:
     2448            return TOOLTIPS_Update (hwnd, wParam, lParam);
     2449
     2450        case TTM_UPDATETIPTEXTA:
     2451            return TOOLTIPS_UpdateTipTextA (hwnd, wParam, lParam);
     2452
     2453        case TTM_UPDATETIPTEXTW:
     2454            return TOOLTIPS_UpdateTipTextW (hwnd, wParam, lParam);
     2455
     2456        case TTM_WINDOWFROMPOINT:
     2457            return TOOLTIPS_WindowFromPoint (hwnd, wParam, lParam);
     2458
     2459
     2460        case WM_CREATE:
     2461            return TOOLTIPS_Create (hwnd, wParam, lParam);
     2462
     2463        case WM_DESTROY:
     2464            return TOOLTIPS_Destroy (hwnd, wParam, lParam);
     2465
     2466        case WM_ERASEBKGND:
     2467            return TOOLTIPS_EraseBackground (hwnd, wParam, lParam);
     2468
     2469        case WM_GETFONT:
     2470            return TOOLTIPS_GetFont (hwnd, wParam, lParam);
    23902471
    23912472        case WM_GETTEXT:
    23922473            return TOOLTIPS_OnWMGetText (hwnd, wParam, lParam);
    2393        
     2474
    23942475        case WM_GETTEXTLENGTH:
    23952476            return TOOLTIPS_OnWMGetTextLength (hwnd, wParam, lParam);
    2396  
    2397 
    2398         case WM_LBUTTONDOWN:
    2399         case WM_LBUTTONUP:
    2400         case WM_MBUTTONDOWN:
    2401         case WM_MBUTTONUP:
    2402         case WM_RBUTTONDOWN:
    2403         case WM_RBUTTONUP:
    2404         case WM_MOUSEMOVE:
    2405             return TOOLTIPS_MouseMessage (hwnd, uMsg, wParam, lParam);
    2406 
    2407         case WM_NCCREATE:
    2408             return TOOLTIPS_NCCreate (hwnd, wParam, lParam);
    2409 
    2410         case WM_NCHITTEST:
    2411             return TOOLTIPS_NCHitTest (hwnd, wParam, lParam);
    2412 
    2413         case WM_NOTIFYFORMAT:
    2414             return TOOLTIPS_NotifyFormat (hwnd, wParam, lParam);
    2415 
    2416         case WM_PAINT:
    2417             return TOOLTIPS_Paint (hwnd, wParam, lParam);
    2418 
    2419         case WM_SETFONT:
    2420             return TOOLTIPS_SetFont (hwnd, wParam, lParam);
    2421 
    2422         case WM_TIMER:
    2423             return TOOLTIPS_Timer (hwnd, wParam, lParam);
    2424 
    2425         case WM_WININICHANGE:
    2426             return TOOLTIPS_WinIniChange (hwnd, wParam, lParam);
    2427 
    2428         default:
    2429             if (uMsg >= WM_USER)
    2430                 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    2431                      uMsg, wParam, lParam);
    2432             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     2477
     2478
     2479        case WM_LBUTTONDOWN:
     2480        case WM_LBUTTONUP:
     2481        case WM_LBUTTONDBLCLK:
     2482        case WM_MBUTTONDOWN:
     2483        case WM_MBUTTONUP:
     2484        case WM_MBUTTONDBLCLK:
     2485        case WM_RBUTTONDOWN:
     2486        case WM_RBUTTONUP:
     2487        case WM_RBUTTONDBLCLK:
     2488        case WM_MOUSEMOVE:
     2489            return TOOLTIPS_MouseMessage (hwnd, uMsg, wParam, lParam);
     2490
     2491        case WM_MOUSEACTIVATE:
     2492            return TOOLTIPS_MouseActivate(hwnd,wParam,lParam);
     2493
     2494        case WM_NCCREATE:
     2495            return TOOLTIPS_NCCreate (hwnd, wParam, lParam);
     2496
     2497        case WM_NCHITTEST:
     2498            return TOOLTIPS_NCHitTest (hwnd, wParam, lParam);
     2499
     2500        case WM_PAINT:
     2501            return TOOLTIPS_Paint (hwnd, wParam, lParam);
     2502
     2503        case WM_SETFONT:
     2504            return TOOLTIPS_SetFont (hwnd, wParam, lParam);
     2505
     2506        case WM_TIMER:
     2507            return TOOLTIPS_Timer (hwnd, wParam, lParam);
     2508
     2509        case WM_WININICHANGE:
     2510            return TOOLTIPS_WinIniChange (hwnd, wParam, lParam);
     2511
     2512        default:
     2513//            if (uMsg >= WM_USER)
     2514//              ERR (tooltips, "unknown msg %04x wp=%08x lp=%08lx\n",
     2515//                   uMsg, wParam, lParam);
     2516            return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
    24332517    }
    24342518    return 0;
     
    24372521
    24382522VOID
    2439 TOOLTIPS_Register (void)
     2523TOOLTIPS_Register (VOID)
    24402524{
    24412525    WNDCLASSA wndClass;
     
    24492533    wndClass.hbrBackground = 0;
    24502534    wndClass.lpszClassName = TOOLTIPS_CLASSA;
    2451  
     2535
    24522536    RegisterClassA (&wndClass);
    24532537}
     
    24552539
    24562540VOID
    2457 TOOLTIPS_Unregister (void)
     2541TOOLTIPS_Unregister (VOID)
    24582542{
    24592543    UnregisterClassA (TOOLTIPS_CLASSA, (HINSTANCE)NULL);
Note: See TracChangeset for help on using the changeset viewer.