Ignore:
Timestamp:
Jun 24, 1999, 6:37:46 PM (26 years ago)
Author:
cbratschi
Message:

Several COMCTL32 changes

File:
1 edited

Legend:

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

    r110 r180  
    1 /* $Id: tooltips.c,v 1.5 1999-06-16 20:25:44 cbratschi Exp $ */
     1/* $Id: tooltips.c,v 1.6 1999-06-24 16:37:45 cbratschi Exp $ */
    22/*
    33 * Tool tip control
     
    1818 */
    1919
     20/* CB: Odin32 problems
     21 - not defined colors: COLOR_INFOBK, COLOR_INFOTEXT
     22 - WM_NCCREATE not handled first -> title bar visible if WS_POPUP wasn't set before
     23*/
     24
    2025#include <string.h>
    2126
     
    5358    UINT uFlags = DT_EXTERNALLEADING;
    5459
    55     if (infoPtr->nMaxTipWidth > -1)
    56         uFlags |= DT_WORDBREAK;
    57     if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX)
    58         uFlags |= DT_NOPREFIX;
    59     GetClientRect (hwnd, &rc);
     60    if (infoPtr->nMaxTipWidth > -1) uFlags |= DT_WORDBREAK;
     61    if (GetWindowLongA(hwnd,GWL_STYLE) & TTS_NOPREFIX) uFlags |= DT_NOPREFIX;
     62    GetClientRect(hwnd,&rc);
    6063
    6164    /* fill the background */
    62     hBrush = CreateSolidBrush (infoPtr->clrBk);
    63     FillRect (hdc, &rc, hBrush);
    64     DeleteObject (hBrush);
     65    hBrush = CreateSolidBrush(infoPtr->clrBk);
     66    FillRect(hdc,&rc,hBrush);
     67    DeleteObject(hBrush);
    6568
    6669    /* 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);
     70    rc.left   += (2+infoPtr->rcMargin.left);
     71    rc.top    += (2+infoPtr->rcMargin.top);
     72    rc.right  -= (2+infoPtr->rcMargin.right);
     73    rc.bottom -= (2+infoPtr->rcMargin.bottom);
    7174
    7275    /* 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)
    79         SetBkMode (hdc, oldBkMode);
     76    oldBkMode = SetBkMode(hdc,TRANSPARENT);
     77    SetTextColor(hdc,infoPtr->clrText);
     78    hOldFont = SelectObject(hdc,infoPtr->hFont);
     79    DrawTextW(hdc,infoPtr->szTipText,-1,&rc,uFlags);
     80    SelectObject(hdc,hOldFont);
     81    if (oldBkMode != TRANSPARENT) SetBkMode(hdc,oldBkMode);
    8082}
    8183
    8284
    8385static VOID
    84 TOOLTIPS_GetTipText (HWND hwnd, TOOLTIPS_INFO *infoPtr, INT nTool)
     86TOOLTIPS_GetTipText(HWND hwnd,TOOLTIPS_INFO *infoPtr,INT nTool)
    8587{
    8688    TTTOOL_INFO *toolPtr = &infoPtr->tools[nTool];
    8789
    88     if ((toolPtr->hinst) && (HIWORD((UINT)toolPtr->lpszText) == 0)) {
    89         /* load a resource */
    90 //      TRACE (tooltips, "load res string %x %x\n",
    91 //             toolPtr->hinst, (int)toolPtr->lpszText);
    92         LoadStringW (toolPtr->hinst, (UINT)toolPtr->lpszText,
    93                        infoPtr->szTipText, INFOTIPSIZE);
    94     }
    95     else if (toolPtr->lpszText) {
    96         if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW) {
    97             NMTTDISPINFOA ttnmdi;
    98 
    99             /* fill NMHDR struct */
    100             ZeroMemory (&ttnmdi, sizeof(NMTTDISPINFOA));
    101             ttnmdi.hdr.hwndFrom = hwnd;
    102             ttnmdi.hdr.idFrom = toolPtr->uId;
    103             ttnmdi.hdr.code = TTN_GETDISPINFOA;
    104             ttnmdi.lpszText = (LPSTR)&ttnmdi.szText;
    105             ttnmdi.uFlags = toolPtr->uFlags;
    106             ttnmdi.lParam = toolPtr->lParam;
    107 
    108 //          TRACE (tooltips, "hdr.idFrom = %x\n", ttnmdi.hdr.idFrom);
    109             SendMessageA (toolPtr->hwnd, WM_NOTIFY,
    110                             (WPARAM)toolPtr->uId, (LPARAM)&ttnmdi);
    111 
    112             if ((ttnmdi.hinst) && (HIWORD((UINT)ttnmdi.szText) == 0)) {
    113                 LoadStringW (ttnmdi.hinst, (UINT)ttnmdi.szText,
    114                                infoPtr->szTipText, INFOTIPSIZE);
    115                 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
    116                     toolPtr->hinst = ttnmdi.hinst;
    117                     toolPtr->lpszText = (LPWSTR)ttnmdi.szText;
    118                 }
    119             }
    120             else if (ttnmdi.szText[0]) {
    121                 lstrcpynAtoW (infoPtr->szTipText, ttnmdi.szText, 80);
    122                 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
    123                     INT len = lstrlenA (ttnmdi.szText);
    124                     toolPtr->hinst = 0;
    125                     toolPtr->lpszText = COMCTL32_Alloc ((len+1)* sizeof(WCHAR));
    126                     lstrcpyAtoW (toolPtr->lpszText, ttnmdi.szText);
    127                 }
    128             }
    129             else if (ttnmdi.lpszText == 0) {
    130                 /* no text available */
    131                 infoPtr->szTipText[0] = L'\0';
    132             }
    133             else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA) {
    134                 lstrcpynAtoW (infoPtr->szTipText, ttnmdi.lpszText, INFOTIPSIZE);
    135                 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
    136                     INT len = lstrlenA (ttnmdi.lpszText);
    137                     toolPtr->hinst = 0;
    138                     toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    139                     lstrcpyAtoW (toolPtr->lpszText, ttnmdi.lpszText);
    140                 }
    141             }
    142             else {
    143 //              ERR (tooltips, "recursive text callback!\n");
    144                 infoPtr->szTipText[0] = '\0';
    145             }
     90    if ((toolPtr->hinst) && (HIWORD((UINT)toolPtr->lpszText) == 0))
     91    {
     92      /* load a resource */
     93//    TRACE (tooltips,"load res string %x %x\n",toolPtr->hinst,(int)toolPtr->lpszText);
     94      LoadStringW(toolPtr->hinst,(UINT)toolPtr->lpszText,infoPtr->szTipText,INFOTIPSIZE);
     95    } else if (toolPtr->lpszText)
     96    {
     97      if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW)
     98      {
     99        NMTTDISPINFOA ttnmdi;
     100
     101        /* fill NMHDR struct */
     102        ZeroMemory (&ttnmdi,sizeof(NMTTDISPINFOA));
     103        ttnmdi.hdr.hwndFrom = hwnd;
     104        ttnmdi.hdr.idFrom = toolPtr->uId;
     105        ttnmdi.hdr.code = TTN_GETDISPINFOA;
     106        ttnmdi.lpszText = (LPSTR)&ttnmdi.szText;
     107        ttnmdi.uFlags = toolPtr->uFlags;
     108        ttnmdi.lParam = toolPtr->lParam;
     109        //          TRACE (tooltips, "hdr.idFrom = %x\n", ttnmdi.hdr.idFrom);
     110        SendMessageA (toolPtr->hwnd,WM_NOTIFY,(WPARAM)toolPtr->uId,(LPARAM)&ttnmdi);
     111
     112        if ((ttnmdi.hinst) && (HIWORD((UINT)ttnmdi.szText) == 0))
     113        {
     114          LoadStringW (ttnmdi.hinst,(UINT)ttnmdi.szText,infoPtr->szTipText,INFOTIPSIZE);
     115          if (ttnmdi.uFlags & TTF_DI_SETITEM)
     116          {
     117            toolPtr->hinst = ttnmdi.hinst;
     118            toolPtr->lpszText = (LPWSTR)ttnmdi.szText;
     119          }
     120        } else if (ttnmdi.szText[0])
     121        {
     122          lstrcpynAtoW (infoPtr->szTipText,ttnmdi.szText,80);
     123          if (ttnmdi.uFlags & TTF_DI_SETITEM)
     124          {
     125            INT len = lstrlenA(ttnmdi.szText);
     126            toolPtr->hinst = 0;
     127            toolPtr->lpszText = COMCTL32_Alloc((len+1)* sizeof(WCHAR));
     128            lstrcpyAtoW(toolPtr->lpszText,ttnmdi.szText);
     129          }
     130        } else if (ttnmdi.lpszText == 0)
     131        {
     132          /* no text available */
     133          infoPtr->szTipText[0] = L'\0';
     134        } else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA)
     135        {
     136          lstrcpynAtoW(infoPtr->szTipText,ttnmdi.lpszText,INFOTIPSIZE);
     137          if (ttnmdi.uFlags & TTF_DI_SETITEM)
     138          {
     139            INT len = lstrlenA(ttnmdi.lpszText);
     140            toolPtr->hinst = 0;
     141            toolPtr->lpszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR));
     142            lstrcpyAtoW(toolPtr->lpszText,ttnmdi.lpszText);
     143          }
     144        } else
     145        {
     146//        ERR (tooltips, "recursive text callback!\n");
     147          infoPtr->szTipText[0] = '\0';
    146148        }
    147         else {
    148             /* the item is a usual (unicode) text */
    149 //          lstrcpynW (infoPtr->szTipText, toolPtr->lpszText, INFOTIPSIZE);
    150             strncpy(infoPtr->szTipText, toolPtr->lpszText, INFOTIPSIZE);
    151         }
    152     }
    153     else {
    154         /* no text available */
    155         infoPtr->szTipText[0] = L'\0';
     149      } else
     150      {
     151        /* the item is a usual (unicode) text */
     152      lstrcpynW (infoPtr->szTipText,toolPtr->lpszText,INFOTIPSIZE);
     153      }
     154    }
     155    else
     156    {
     157      /* no text available */
     158      infoPtr->szTipText[0] = L'\0';
    156159    }
    157160
     
    159162}
    160163
    161 
    162164static VOID
    163 TOOLTIPS_CalcTipSize (HWND hwnd, TOOLTIPS_INFO *infoPtr, LPSIZE lpSize)
     165TOOLTIPS_CalcTipSize (HWND hwnd,TOOLTIPS_INFO *infoPtr,LPSIZE lpSize)
    164166{
    165167    HDC hdc;
    166168    HFONT hOldFont;
    167169    UINT uFlags = DT_EXTERNALLEADING | DT_CALCRECT;
    168     RECT rc = {0, 0, 0, 0};
    169 
    170     if (infoPtr->nMaxTipWidth > -1) {
    171         rc.right = infoPtr->nMaxTipWidth;
    172         uFlags |= DT_WORDBREAK;
    173     }
    174     if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX)
    175         uFlags |= DT_NOPREFIX;
     170    RECT rc = {0,0,0,0};
     171
     172    if (infoPtr->nMaxTipWidth > -1)
     173    {
     174      rc.right = infoPtr->nMaxTipWidth;
     175      uFlags |= DT_WORDBREAK;
     176    }
     177    if (GetWindowLongA(hwnd,GWL_STYLE) & TTS_NOPREFIX) uFlags |= DT_NOPREFIX;
    176178//    TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
    177179
    178     hdc = GetDC (hwnd);
    179     hOldFont = SelectObject (hdc, infoPtr->hFont);
    180     DrawTextW (hdc, infoPtr->szTipText, -1, &rc, uFlags);
    181     SelectObject (hdc, hOldFont);
    182     ReleaseDC (hwnd, hdc);
    183 
    184     lpSize->cx = rc.right - rc.left + 4 +
    185                  infoPtr->rcMargin.left + infoPtr->rcMargin.right;
    186     lpSize->cy = rc.bottom - rc.top + 4 +
    187                  infoPtr->rcMargin.bottom + infoPtr->rcMargin.top;
     180    hdc = GetDC(hwnd);
     181    hOldFont = SelectObject(hdc,infoPtr->hFont);
     182    DrawTextW(hdc,infoPtr->szTipText,-1,&rc,uFlags);
     183    SelectObject(hdc,hOldFont);
     184    ReleaseDC(hwnd,hdc);
     185
     186    lpSize->cx = rc.right-rc.left+4+infoPtr->rcMargin.left+infoPtr->rcMargin.right;
     187    lpSize->cy = rc.bottom-rc.top+4+infoPtr->rcMargin.bottom+infoPtr->rcMargin.top;
    188188}
    189189
     
    198198    NMHDR  hdr;
    199199
    200     if (infoPtr->nTool == -1) {
     200    if (infoPtr->nTool == -1)
     201    {
    201202//      TRACE (tooltips, "invalid tool (-1)!\n");
    202203        return;
     
    207208//    TRACE (tooltips, "Show tooltip pre %d!\n", infoPtr->nTool);
    208209
    209     TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nCurrentTool);
    210 
    211     if (infoPtr->szTipText[0] == L'\0') {
     210    TOOLTIPS_GetTipText(hwnd,infoPtr,infoPtr->nCurrentTool);
     211
     212    if (infoPtr->szTipText[0] == L'\0')
     213    {
    212214        infoPtr->nCurrentTool = -1;
    213215        return;
     
    220222    hdr.idFrom = toolPtr->uId;
    221223    hdr.code = TTN_SHOW;
    222     SendMessageA (toolPtr->hwnd, WM_NOTIFY,
    223                     (WPARAM)toolPtr->uId, (LPARAM)&hdr);
     224    SendMessageA(toolPtr->hwnd,WM_NOTIFY,
     225                    (WPARAM)toolPtr->uId,(LPARAM)&hdr);
    224226
    225227//    TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
     
    228230//    TRACE (tooltips, "size %d - %d\n", size.cx, size.cy);
    229231
    230     if (toolPtr->uFlags & TTF_CENTERTIP) {
     232    if (toolPtr->uFlags & TTF_CENTERTIP)
     233    {
    231234        RECT rc;
    232235
    233236        if (toolPtr->uFlags & TTF_IDISHWND)
    234237            GetWindowRect ((HWND)toolPtr->uId, &rc);
    235         else {
     238        else
     239        {
    236240            rc = toolPtr->rect;
    237241            MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2);
     
    239243        rect.left = (rc.left + rc.right - size.cx) / 2;
    240244        rect.top  = rc.bottom + 2;
    241     }
    242     else {
    243         GetCursorPos ((LPPOINT)&rect);
     245    } else
     246    {
     247        GetCursorPos((LPPOINT)&rect);
    244248        rect.top += 20;
    245249    }
     
    252256    rect.bottom = rect.top + size.cy;
    253257
    254     AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE),
    255                         FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE));
    256 
    257     SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top,
    258                     rect.right - rect.left, rect.bottom - rect.top,
     258    AdjustWindowRectEx (&rect,GetWindowLongA(hwnd, GWL_STYLE),
     259                        FALSE,GetWindowLongA(hwnd, GWL_EXSTYLE));
     260
     261    SetWindowPos (hwnd,HWND_TOP,rect.left,rect.top,
     262                    rect.right-rect.left,rect.bottom-rect.top,
    259263                    SWP_SHOWWINDOW | SWP_NOACTIVATE);
    260264
    261265    /* repaint the tooltip */
    262     hdc = GetDC (hwnd);
    263     TOOLTIPS_Refresh (hwnd, hdc);
    264     ReleaseDC (hwnd, hdc);
    265 
    266     SetTimer (hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0);
     266    hdc = GetDC(hwnd);
     267    TOOLTIPS_Refresh(hwnd,hdc);
     268    ReleaseDC(hwnd,hdc);
     269
     270    SetTimer (hwnd,ID_TIMERPOP,infoPtr->nAutoPopTime,0);
    267271}
    268272
     
    303307    NMHDR hdr;
    304308
    305     if (infoPtr->nTrackTool == -1) {
    306 //      TRACE (tooltips, "invalid tracking tool (-1)!\n");
    307         return;
     309    if (infoPtr->nTrackTool == -1)
     310    {
     311//    TRACE (tooltips, "invalid tracking tool (-1)!\n");
     312      return;
    308313    }
    309314
    310315//    TRACE (tooltips, "show tracking tooltip pre %d!\n", infoPtr->nTrackTool);
    311316
    312     TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nTrackTool);
    313 
    314     if (infoPtr->szTipText[0] == L'\0') {
    315         infoPtr->nTrackTool = -1;
    316         return;
     317    TOOLTIPS_GetTipText(hwnd,infoPtr,infoPtr->nTrackTool);
     318
     319    if (infoPtr->szTipText[0] == L'\0')
     320    {
     321      infoPtr->nTrackTool = -1;
     322      return;
    317323    }
    318324
     
    323329    hdr.idFrom = toolPtr->uId;
    324330    hdr.code = TTN_SHOW;
    325     SendMessageA (toolPtr->hwnd, WM_NOTIFY,
    326                     (WPARAM)toolPtr->uId, (LPARAM)&hdr);
     331    SendMessageA(toolPtr->hwnd,WM_NOTIFY,(WPARAM)toolPtr->uId,(LPARAM)&hdr);
    327332
    328333//    TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
    329334
    330     TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size);
     335    TOOLTIPS_CalcTipSize(hwnd,infoPtr,&size);
    331336//    TRACE (tooltips, "size %d - %d\n", size.cx, size.cy);
    332337
    333     if (toolPtr->uFlags & TTF_ABSOLUTE) {
    334         rect.left = infoPtr->xTrackPos;
    335         rect.top  = infoPtr->yTrackPos;
    336 
    337         if (toolPtr->uFlags & TTF_CENTERTIP) {
    338             rect.left -= (size.cx / 2);
    339             rect.top  -= (size.cy / 2);
    340         }
    341     }
    342     else {
    343         RECT rcTool;
    344 
    345         if (toolPtr->uFlags & TTF_IDISHWND)
    346             GetWindowRect ((HWND)toolPtr->uId, &rcTool);
    347         else {
    348             rcTool = toolPtr->rect;
    349             MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rcTool, 2);
    350         }
    351 
    352         GetCursorPos ((LPPOINT)&rect);
    353         rect.top += 20;
    354 
    355         if (toolPtr->uFlags & TTF_CENTERTIP) {
    356             rect.left -= (size.cx / 2);
    357             rect.top  -= (size.cy / 2);
    358         }
    359 
    360         /* smart placement */
    361         if ((rect.left + size.cx > rcTool.left) && (rect.left < rcTool.right) &&
    362             (rect.top + size.cy > rcTool.top) && (rect.top < rcTool.bottom))
    363             rect.left = rcTool.right;
     338    if (toolPtr->uFlags & TTF_ABSOLUTE)
     339    {
     340      rect.left = infoPtr->xTrackPos;
     341      rect.top  = infoPtr->yTrackPos;
     342
     343      if (toolPtr->uFlags & TTF_CENTERTIP)
     344      {
     345        rect.left -= (size.cx/2);
     346        rect.top  -= (size.cy/2);
     347      }
     348    } else
     349    {
     350      RECT rcTool;
     351
     352      if (toolPtr->uFlags & TTF_IDISHWND)
     353      {
     354        GetWindowRect((HWND)toolPtr->uId,&rcTool); //screen coordinates
     355      } else
     356      {
     357        rcTool = toolPtr->rect;
     358        MapWindowPoints(toolPtr->hwnd,(HWND)0,(LPPOINT)&rcTool,2);
     359      }
     360
     361      GetCursorPos ((LPPOINT)&rect);
     362      rect.top += 20;
     363
     364      if (toolPtr->uFlags & TTF_CENTERTIP)
     365      {
     366        rect.left -= (size.cx / 2);
     367        rect.top  -= (size.cy / 2);
     368      }
     369
     370      /* smart placement */
     371      if ((rect.left + size.cx > rcTool.left) && (rect.left < rcTool.right) &&
     372          (rect.top + size.cy > rcTool.top) && (rect.top < rcTool.bottom))
     373          rect.left = rcTool.right;
    364374    }
    365375
    366376//    TRACE (tooltips, "pos %d - %d\n", rect.left, rect.top);
    367377
    368     rect.right = rect.left + size.cx;
    369     rect.bottom = rect.top + size.cy;
    370 
    371     AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE),
    372                         FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE));
    373 
    374     SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top,
    375                     rect.right - rect.left, rect.bottom - rect.top,
     378    rect.right = rect.left+size.cx;
     379    rect.bottom = rect.top+size.cy;
     380
     381    AdjustWindowRectEx (&rect,GetWindowLongA(hwnd,GWL_STYLE),
     382                        FALSE,GetWindowLongA(hwnd,GWL_EXSTYLE));
     383
     384    SetWindowPos (hwnd,HWND_TOP,rect.left,rect.top,
     385                    rect.right-rect.left,rect.bottom-rect.top,
    376386                    SWP_SHOWWINDOW | SWP_NOACTIVATE );
    377387
     
    564574
    565575static LRESULT
    566 TOOLTIPS_AddToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    567 {
    568     TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
     576TOOLTIPS_AddToolA(HWND hwnd,WPARAM wParam,LPARAM lParam)
     577{
     578    TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
    569579    LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
    570580    TTTOOL_INFO *toolPtr;
    571581
     582    if (lpToolInfo == NULL) return FALSE;
     583    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) return FALSE;
     584
     585//    TRACE (tooltips, "add tool (%x) %x %d%s!\n",
     586//         hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
     587//         (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
     588
     589    if (infoPtr->uNumTools == 0)
     590    {
     591      infoPtr->tools = COMCTL32_Alloc(sizeof(TTTOOL_INFO));
     592      toolPtr = infoPtr->tools;
     593    } else
     594    {
     595      TTTOOL_INFO *oldTools = infoPtr->tools;
     596
     597      //CB: check if already exists!
     598
     599      infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO)*(infoPtr->uNumTools+1));
     600      memcpy (infoPtr->tools,oldTools,infoPtr->uNumTools*sizeof(TTTOOL_INFO));
     601      COMCTL32_Free(oldTools);
     602      toolPtr = &infoPtr->tools[infoPtr->uNumTools];
     603    }
     604
     605    infoPtr->uNumTools++;
     606
     607    /* copy tool data */
     608    toolPtr->uFlags = lpToolInfo->uFlags;
     609    toolPtr->hwnd   = lpToolInfo->hwnd;
     610    toolPtr->uId    = lpToolInfo->uId;
     611    toolPtr->rect   = lpToolInfo->rect;
     612    toolPtr->hinst  = lpToolInfo->hinst;
     613
     614    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0))
     615    {
     616//    TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText);
     617      toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
     618    } else if (lpToolInfo->lpszText)
     619    {
     620      if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
     621      {
     622//      TRACE (tooltips, "add CALLBACK!\n");
     623        toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     624      } else
     625      {
     626        INT len = lstrlenA (lpToolInfo->lpszText);
     627//          TRACE (tooltips, "add text \"%s\"!\n", lpToolInfo->lpszText);
     628        toolPtr->lpszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR));
     629        lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
     630      }
     631    } else toolPtr->lpszText = NULL;
     632
     633    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
     634        toolPtr->lParam = lpToolInfo->lParam;
     635
     636    /* install subclassing hook */
     637    if (toolPtr->uFlags & TTF_SUBCLASS)
     638    {
     639      if (toolPtr->uFlags & TTF_IDISHWND)
     640      {
     641        LPTT_SUBCLASS_INFO lpttsi =
     642            (LPTT_SUBCLASS_INFO)GetPropA((HWND)toolPtr->uId,COMCTL32_aSubclass);
     643        if (lpttsi == NULL)
     644        {
     645          lpttsi = (LPTT_SUBCLASS_INFO)COMCTL32_Alloc(sizeof(TT_SUBCLASS_INFO));
     646          lpttsi->wpOrigProc =
     647              (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId,
     648              GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
     649          lpttsi->hwndToolTip = hwnd;
     650          lpttsi->uRefCount++;
     651          SetPropA ((HWND)toolPtr->uId,COMCTL32_aSubclass,(HANDLE)lpttsi);
     652        }
     653//          else
     654//              WARN (tooltips, "A window tool must only be listed once!\n");
     655      } else
     656      {
     657        LPTT_SUBCLASS_INFO lpttsi =
     658           (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
     659        if (lpttsi == NULL)
     660        {
     661          lpttsi = (LPTT_SUBCLASS_INFO)COMCTL32_Alloc(sizeof(TT_SUBCLASS_INFO));
     662          lpttsi->wpOrigProc =
     663              (WNDPROC)SetWindowLongA (toolPtr->hwnd,
     664              GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
     665          lpttsi->hwndToolTip = hwnd;
     666          lpttsi->uRefCount++;
     667          SetPropA(toolPtr->hwnd,COMCTL32_aSubclass,(HANDLE)lpttsi);
     668        } else lpttsi->uRefCount++;
     669      }
     670//      TRACE (tooltips, "subclassing installed!\n");
     671    }
     672
     673    return TRUE;
     674}
     675
     676
     677static LRESULT
     678TOOLTIPS_AddToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
     679{
     680    TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
     681    LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
     682    TTTOOL_INFO *toolPtr;
     683
    572684    if (lpToolInfo == NULL)
    573685        return FALSE;
    574     if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
     686    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    575687        return FALSE;
    576688
     
    607719    }
    608720    else if (lpToolInfo->lpszText) {
    609         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) {
     721        if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) {
    610722//          TRACE (tooltips, "add CALLBACK!\n");
    611723            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    612724        }
    613725        else {
    614             INT len = lstrlenA (lpToolInfo->lpszText);
    615 //          TRACE (tooltips, "add text \"%s\"!\n", lpToolInfo->lpszText);
     726            INT len = lstrlenW (lpToolInfo->lpszText);
     727//          TRACE (tooltips, "add text \"%s\"!\n",
     728//                 debugstr_w(lpToolInfo->lpszText));
    616729            toolPtr->lpszText = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    617             lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
     730            lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
    618731        }
    619732    }
    620733
    621     if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
     734    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
    622735        toolPtr->lParam = lpToolInfo->lParam;
    623736
     
    665778
    666779static LRESULT
    667 TOOLTIPS_AddToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    668 {
    669     TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
    670     LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
    671     TTTOOL_INFO *toolPtr;
    672 
    673     if (lpToolInfo == NULL)
    674         return FALSE;
    675     if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    676         return FALSE;
    677 
    678 //    TRACE (tooltips, "add tool (%x) %x %d%s!\n",
    679 //         hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
    680 //         (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
    681 
    682     if (infoPtr->uNumTools == 0) {
    683         infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO));
    684         toolPtr = infoPtr->tools;
    685     }
    686     else {
    687         TTTOOL_INFO *oldTools = infoPtr->tools;
    688         infoPtr->tools =
    689             COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1));
    690         memcpy (infoPtr->tools, oldTools,
    691                 infoPtr->uNumTools * sizeof(TTTOOL_INFO));
    692         COMCTL32_Free (oldTools);
    693         toolPtr = &infoPtr->tools[infoPtr->uNumTools];
    694     }
    695 
    696     infoPtr->uNumTools++;
    697 
    698     /* copy tool data */
    699     toolPtr->uFlags = lpToolInfo->uFlags;
    700     toolPtr->hwnd   = lpToolInfo->hwnd;
    701     toolPtr->uId    = lpToolInfo->uId;
    702     toolPtr->rect   = lpToolInfo->rect;
    703     toolPtr->hinst  = lpToolInfo->hinst;
    704 
    705     if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
    706 //      TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText);
    707         toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
    708     }
    709     else if (lpToolInfo->lpszText) {
    710         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) {
    711 //          TRACE (tooltips, "add CALLBACK!\n");
    712             toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    713         }
    714         else {
    715             INT len = lstrlenW (lpToolInfo->lpszText);
    716 //          TRACE (tooltips, "add text \"%s\"!\n",
    717 //                 debugstr_w(lpToolInfo->lpszText));
    718             toolPtr->lpszText = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    719             lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
    720         }
    721     }
    722 
    723     if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
    724         toolPtr->lParam = lpToolInfo->lParam;
    725 
    726     /* install subclassing hook */
    727     if (toolPtr->uFlags & TTF_SUBCLASS) {
    728         if (toolPtr->uFlags & TTF_IDISHWND) {
    729             LPTT_SUBCLASS_INFO lpttsi =
    730                 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    731             if (lpttsi == NULL) {
    732                 lpttsi =
    733                     (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
    734                 lpttsi->wpOrigProc =
    735                     (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId,
    736                     GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
    737                 lpttsi->hwndToolTip = hwnd;
    738                 lpttsi->uRefCount++;
    739                 SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass,
    740                             (HANDLE)lpttsi);
    741             }
    742 //          else
    743 //              WARN (tooltips, "A window tool must only be listed once!\n");
    744         }
    745         else {
    746             LPTT_SUBCLASS_INFO lpttsi =
    747                 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
    748             if (lpttsi == NULL) {
    749                 lpttsi =
    750                     (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
    751                 lpttsi->wpOrigProc =
    752                     (WNDPROC)SetWindowLongA (toolPtr->hwnd,
    753                     GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
    754                 lpttsi->hwndToolTip = hwnd;
    755                 lpttsi->uRefCount++;
    756                 SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi);
    757             }
    758             else
    759                 lpttsi->uRefCount++;
    760         }
    761 //      TRACE (tooltips, "subclassing installed!\n");
    762     }
    763 
    764     return TRUE;
    765 }
    766 
    767 
    768 static LRESULT
    769780TOOLTIPS_DelToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    770781{
     
    14011412    POINT pt;
    14021413
    1403     if (lParam == 0) {
    1404 //      ERR (tooltips, "lpMsg == NULL!\n");
    1405         return 0;
    1406     }
    1407 
    1408     switch (lpMsg->message) {
     1414    if (lParam == 0)
     1415    {
     1416//    ERR (tooltips, "lpMsg == NULL!\n");
     1417      return 0;
     1418    }
     1419
     1420    switch (lpMsg->message)
     1421    {
    14091422        case WM_LBUTTONDOWN:
    14101423        case WM_LBUTTONUP:
     
    14141427        case WM_RBUTTONUP:
    14151428            pt = lpMsg->pt;
    1416             ScreenToClient (lpMsg->hwnd, &pt);
     1429            ScreenToClient(lpMsg->hwnd,&pt);
    14171430            infoPtr->nOldTool = infoPtr->nTool;
    1418             infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd, &pt);
     1431            infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr,lpMsg->hwnd,&pt);
    14191432//          TRACE (tooltips, "tool (%x) %d %d\n",
    14201433//                 hwnd, infoPtr->nOldTool, infoPtr->nTool);
     
    14241437        case WM_MOUSEMOVE:
    14251438            pt = lpMsg->pt;
    1426             ScreenToClient (lpMsg->hwnd, &pt);
     1439            ScreenToClient(lpMsg->hwnd,&pt);
    14271440            infoPtr->nOldTool = infoPtr->nTool;
    1428             infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd, &pt);
     1441            infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr,lpMsg->hwnd,&pt);
    14291442//          TRACE (tooltips, "tool (%x) %d %d\n",
    14301443//                 hwnd, infoPtr->nOldTool, infoPtr->nTool);
    14311444//          TRACE (tooltips, "WM_MOUSEMOVE (%04x %ld %ld)\n",
    14321445//                 hwnd, pt.x, pt.y);
    1433             if ((infoPtr->bActive) && (infoPtr->nTool != infoPtr->nOldTool)) {
    1434                 if (infoPtr->nOldTool == -1) {
    1435                     SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nInitialTime, 0);
    1436 //                  TRACE (tooltips, "timer 1 started!\n");
    1437                 }
    1438                 else {
    1439                     TOOLTIPS_Hide (hwnd, infoPtr);
    1440                     SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0);
    1441 //                  TRACE (tooltips, "timer 2 started!\n");
    1442                 }
     1446infoPtr->bActive = TRUE;//CB: somewhere reset, find it!!!
     1447            if (infoPtr->bActive && (infoPtr->nTool != infoPtr->nOldTool))
     1448            {
     1449              if (infoPtr->nOldTool == -1)
     1450              {
     1451                SetTimer(hwnd,ID_TIMERSHOW,infoPtr->nInitialTime,0);
     1452//              TRACE (tooltips, "timer 1 started!\n");
     1453              } else
     1454              {
     1455                TOOLTIPS_Hide(hwnd,infoPtr);
     1456                SetTimer (hwnd,ID_TIMERSHOW,infoPtr->nReshowTime,0);
     1457//              TRACE (tooltips, "timer 2 started!\n");
     1458              }
    14431459            }
    1444             if (infoPtr->nCurrentTool != -1) {
    1445                 SetTimer (hwnd, ID_TIMERLEAVE, 100, 0);
    1446 //              TRACE (tooltips, "timer 3 started!\n");
     1460            if (infoPtr->nCurrentTool != -1)
     1461            {
     1462              SetTimer(hwnd,ID_TIMERLEAVE,100,0);
     1463//            TRACE (tooltips, "timer 3 started!\n");
    14471464            }
    14481465            break;
     
    16551672    LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
    16561673
    1657     if (lpToolInfo == NULL)
    1658         return 0;
    1659     if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    1660         return FALSE;
    1661 
    1662     if ((BOOL)wParam) {
    1663         /* activate */
    1664         infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
    1665         if (infoPtr->nTrackTool != -1) {
    1666 //          TRACE (tooltips, "activated!\n");
    1667             infoPtr->bTrackActive = TRUE;
    1668             TOOLTIPS_TrackShow (hwnd, infoPtr);
    1669         }
    1670     }
    1671     else {
    1672         /* deactivate */
    1673         TOOLTIPS_TrackHide (hwnd, infoPtr);
    1674 
    1675         infoPtr->bTrackActive = FALSE;
    1676         infoPtr->nTrackTool = -1;
     1674    if (lpToolInfo == NULL) return 0;
     1675    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) return FALSE;
     1676
     1677    if ((BOOL)wParam)
     1678    {
     1679      /* activate */
     1680      infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA(infoPtr,lpToolInfo);
     1681      if (infoPtr->nTrackTool != -1)
     1682      {
     1683//      TRACE (tooltips, "activated!\n");
     1684        infoPtr->bTrackActive = TRUE;
     1685        TOOLTIPS_TrackShow(hwnd,infoPtr);
     1686      }
     1687    } else
     1688    {
     1689      /* deactivate */
     1690      TOOLTIPS_TrackHide(hwnd,infoPtr);
     1691
     1692      infoPtr->bTrackActive = FALSE;
     1693      infoPtr->nTrackTool = -1;
    16771694
    16781695//      TRACE (tooltips, "deactivated!\n");
     
    16911708    infoPtr->yTrackPos = (INT)HIWORD(lParam);
    16921709
    1693     if (infoPtr->bTrackActive) {
     1710    if (infoPtr->bTrackActive)
     1711    {
    16941712//      TRACE (tooltips, "[%d %d]\n",
    16951713//             infoPtr->xTrackPos, infoPtr->yTrackPos);
    16961714
    1697         TOOLTIPS_TrackShow (hwnd, infoPtr);
     1715      TOOLTIPS_TrackShow(hwnd,infoPtr);
    16981716    }
    16991717
     
    17221740    INT nTool;
    17231741
    1724     if (lpToolInfo == NULL)
    1725         return 0;
    1726     if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
    1727         return FALSE;
    1728 
    1729     nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
     1742    if (lpToolInfo == NULL) return 0;
     1743    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) return FALSE;
     1744
     1745    nTool = TOOLTIPS_GetToolFromInfoA(infoPtr,lpToolInfo);
    17301746    if (nTool == -1) return 0;
    17311747
     
    17371753    toolPtr->hinst  = lpToolInfo->hinst;
    17381754
    1739     if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){
    1740         toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
    1741     }
    1742     else if (lpToolInfo->lpszText) {
    1743         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
    1744             toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    1745         else {
    1746             if (toolPtr->lpszText) {
    1747                 COMCTL32_Free (toolPtr->lpszText);
    1748                 toolPtr->lpszText = NULL;
    1749             }
    1750             if (lpToolInfo->lpszText) {
    1751                 INT len = lstrlenA (lpToolInfo->lpszText);
    1752                 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    1753                 lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
    1754             }
     1755    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0))
     1756    {
     1757      toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
     1758    } else if (lpToolInfo->lpszText)
     1759    {
     1760      if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     1761      else
     1762      {
     1763        if (toolPtr->lpszText)
     1764        {
     1765          COMCTL32_Free(toolPtr->lpszText);
     1766          toolPtr->lpszText = NULL;
    17551767        }
     1768        if (lpToolInfo->lpszText)
     1769        {
     1770          INT len = lstrlenA(lpToolInfo->lpszText);
     1771          toolPtr->lpszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR));
     1772          lstrcpyAtoW(toolPtr->lpszText,lpToolInfo->lpszText);
     1773        }
     1774      }
    17561775    }
    17571776
    17581777    /* force repaint */
    1759     if (infoPtr->bActive)
    1760         TOOLTIPS_Show (hwnd, infoPtr);
    1761     else if (infoPtr->bTrackActive)
    1762         TOOLTIPS_TrackShow (hwnd, infoPtr);
     1778    if (infoPtr->bActive) TOOLTIPS_Show(hwnd,infoPtr);
     1779    else if (infoPtr->bTrackActive) TOOLTIPS_TrackShow(hwnd,infoPtr);
    17631780
    17641781    return 0;
     
    18351852
    18361853    /* allocate memory for info structure */
    1837     infoPtr = (TOOLTIPS_INFO *)COMCTL32_Alloc (sizeof(TOOLTIPS_INFO));
    1838     SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
     1854    infoPtr = (TOOLTIPS_INFO *)COMCTL32_Alloc(sizeof(TOOLTIPS_INFO));
     1855    SetWindowLongA(hwnd,0,(DWORD)infoPtr);
    18391856
    18401857    /* initialize info structure */
    18411858    infoPtr->bActive = TRUE;
    18421859    infoPtr->bTrackActive = FALSE;
    1843     infoPtr->clrBk   = GetSysColor (COLOR_INFOBK);
    1844     infoPtr->clrText = GetSysColor (COLOR_INFOTEXT);
     1860    infoPtr->clrBk   = RGB(0,0,0);//GetSysColor(COLOR_INFOBK);//CB: to change
     1861    infoPtr->clrText = RGB(255,255,255);//GetSysColor(COLOR_INFOTEXT);//CB: to change
    18451862
    18461863    nclm.cbSize = sizeof(NONCLIENTMETRICSA);
    1847     SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
    1848     infoPtr->hFont = CreateFontIndirectA (&nclm.lfStatusFont);
     1864    SystemParametersInfoA(SPI_GETNONCLIENTMETRICS,0,&nclm,0);
     1865    infoPtr->hFont = CreateFontIndirectA(&nclm.lfStatusFont);
    18491866
    18501867    infoPtr->nMaxTipWidth = -1;
     
    18591876    infoPtr->nInitialTime   = 500;
    18601877
    1861     nResult = (INT) SendMessageA (GetParent (hwnd), WM_NOTIFYFORMAT,
    1862                                   (WPARAM)hwnd, (LPARAM)NF_QUERY);
     1878    SetRectEmpty(&infoPtr->rcMargin);
     1879
     1880    nResult = (INT)SendMessageA(GetParent(hwnd),WM_NOTIFYFORMAT,(WPARAM)hwnd,(LPARAM)NF_QUERY);
    18631881//    if (nResult == NFR_ANSI)
    18641882//      TRACE (tooltips, " -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
     
    18681886//      FIXME (tooltips, " -- WM_NOTIFYFORMAT returns: error!\n");
    18691887
    1870     SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
     1888    SetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
    18711889
    18721890    return 0;
     
    18771895TOOLTIPS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
    18781896{
    1879     TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
     1897    TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
    18801898    TTTOOL_INFO *toolPtr;
    18811899    INT i;
    18821900
    18831901    /* free tools */
    1884     if (infoPtr->tools) {
    1885         for (i = 0; i < infoPtr->uNumTools; i++) {
    1886             toolPtr = &infoPtr->tools[i];
    1887             if ((toolPtr->hinst) && (toolPtr->lpszText)) {
    1888                 if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW)
    1889                     COMCTL32_Free (toolPtr->lpszText);
    1890             }
    1891 
    1892             /* remove subclassing */
    1893             if (toolPtr->uFlags & TTF_SUBCLASS) {
    1894                 LPTT_SUBCLASS_INFO lpttsi;
    1895 
    1896                 if (toolPtr->uFlags & TTF_IDISHWND)
    1897                     lpttsi = (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    1898                 else
    1899                     lpttsi = (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
    1900 
    1901                 if (lpttsi) {
    1902                     SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
    1903                                       (LONG)lpttsi->wpOrigProc);
    1904                     RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
    1905                     COMCTL32_Free (&lpttsi);
    1906                 }
    1907             }
     1902    if (infoPtr->tools)
     1903    {
     1904      for (i = 0;i < infoPtr->uNumTools;i++)
     1905      {
     1906        toolPtr = &infoPtr->tools[i];
     1907        if ((toolPtr->hinst) && (toolPtr->lpszText))
     1908        {
     1909          if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(toolPtr->lpszText);
    19081910        }
    1909         COMCTL32_Free (infoPtr->tools);
     1911
     1912        /* remove subclassing */
     1913        if (toolPtr->uFlags & TTF_SUBCLASS)
     1914        {
     1915          LPTT_SUBCLASS_INFO lpttsi;
     1916
     1917          if (toolPtr->uFlags & TTF_IDISHWND)
     1918              lpttsi = (LPTT_SUBCLASS_INFO)GetPropA((HWND)toolPtr->uId,COMCTL32_aSubclass);
     1919          else
     1920              lpttsi = (LPTT_SUBCLASS_INFO)GetPropA(toolPtr->hwnd,COMCTL32_aSubclass);
     1921
     1922          if (lpttsi)
     1923          {
     1924            SetWindowLongA ((HWND)toolPtr->uId,GWL_WNDPROC,(LONG)lpttsi->wpOrigProc);
     1925            RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
     1926            COMCTL32_Free (&lpttsi);
     1927          }
     1928        }
     1929      }
     1930      COMCTL32_Free (infoPtr->tools);
    19101931    }
    19111932
     
    19141935
    19151936    /* free tool tips info data */
    1916     COMCTL32_Free (infoPtr);
     1937    COMCTL32_Free(infoPtr);
    19171938
    19181939    return 0;
     
    19591980TOOLTIPS_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
    19601981{
    1961     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     1982    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     1983    DWORD dwExStyle = GetWindowLongA(hwnd,GWL_EXSTYLE);
    19621984
    19631985    dwStyle &= 0x0000FFFF;
    19641986    dwStyle |= (WS_POPUP | WS_BORDER | WS_CLIPSIBLINGS);
    1965     SetWindowLongA (hwnd, GWL_STYLE, dwStyle);
     1987    SetWindowLongA(hwnd,GWL_STYLE,dwStyle);
     1988
     1989    SetWindowLongA(hwnd,GWL_EXSTYLE,dwExStyle | WS_EX_TOOLWINDOW);
    19661990
    19671991    return TRUE;
     
    20732097    switch (wParam)
    20742098    {
    2075         case ID_TIMERSHOW:
    2076             KillTimer (hwnd, ID_TIMERSHOW);
    2077             if (TOOLTIPS_CheckTool (hwnd, TRUE) == infoPtr->nTool)
    2078                 TOOLTIPS_Show (hwnd, infoPtr);
    2079             break;
    2080 
    2081         case ID_TIMERPOP:
    2082             TOOLTIPS_Hide (hwnd, infoPtr);
    2083             break;
    2084 
    2085         case ID_TIMERLEAVE:
    2086             KillTimer (hwnd, ID_TIMERLEAVE);
    2087             if (TOOLTIPS_CheckTool (hwnd, FALSE) == -1) {
    2088                 infoPtr->nTool = -1;
    2089                 infoPtr->nOldTool = -1;
    2090                 TOOLTIPS_Hide (hwnd, infoPtr);
    2091             }
    2092             break;
     2099      case ID_TIMERSHOW:
     2100          KillTimer (hwnd,ID_TIMERSHOW);
     2101          if (TOOLTIPS_CheckTool(hwnd,TRUE) == infoPtr->nTool)
     2102              TOOLTIPS_Show(hwnd,infoPtr);
     2103          break;
     2104
     2105      case ID_TIMERPOP:
     2106          TOOLTIPS_Hide (hwnd, infoPtr);
     2107          break;
     2108
     2109      case ID_TIMERLEAVE:
     2110          KillTimer (hwnd,ID_TIMERLEAVE);
     2111          if (TOOLTIPS_CheckTool(hwnd,FALSE) == -1)
     2112          {
     2113            infoPtr->nTool = -1;
     2114            infoPtr->nOldTool = -1;
     2115            TOOLTIPS_Hide(hwnd,infoPtr);
     2116          }
     2117          break;
    20932118    }
    20942119    return 0;
Note: See TracChangeset for help on using the changeset viewer.