Index: trunk/src/comctl32/CCBase.cpp
===================================================================
--- trunk/src/comctl32/CCBase.cpp	(revision 3279)
+++ trunk/src/comctl32/CCBase.cpp	(revision 3280)
@@ -1,3 +1,3 @@
-/* $Id: CCBase.cpp,v 1.5 2000-03-21 17:30:40 cbratschi Exp $ */
+/* $Id: CCBase.cpp,v 1.6 2000-03-30 15:39:08 cbratschi Exp $ */
 /*
  * COMCTL32 Base Functions and Macros for all Controls
@@ -180,4 +180,15 @@
 }
 
+LRESULT sendNotify(HWND hwndFrom,HWND hwndTo,UINT code)
+{
+  NMHDR nmhdr;
+
+  nmhdr.hwndFrom = hwndFrom;
+  nmhdr.idFrom   = GetWindowLongA(hwndFrom,GWL_ID);
+  nmhdr.code     = code;
+
+  return SendMessageA(hwndTo,WM_NOTIFY,nmhdr.idFrom,(LPARAM)&nmhdr);
+}
+
 LRESULT sendNotify(HWND hwnd,UINT code,LPNMHDR nmhdr)
 {
@@ -189,4 +200,15 @@
 
   return SendMessageA(getNotifyWindow(hwnd),WM_NOTIFY,nmhdr->idFrom,(LPARAM)nmhdr);
+}
+
+LRESULT sendNotify(HWND hwndFrom,HWND hwndTo,UINT code,LPNMHDR nmhdr)
+{
+  if (!nmhdr) return 0;
+
+  nmhdr->hwndFrom = hwndFrom;
+  nmhdr->idFrom   = GetWindowLongA(hwndFrom,GWL_ID);
+  nmhdr->code     = code;
+
+  return SendMessageA(hwndTo,WM_NOTIFY,nmhdr->idFrom,(LPARAM)nmhdr);
 }
 
@@ -276,2 +298,24 @@
   DeleteObject(pen);
 }
+
+//string functions
+
+//compare ANSI with UNICODE string
+INT lstrcmpAtoW(CHAR* textA,WCHAR* textW)
+{
+  INT len,res;
+  WCHAR* tmp;
+
+  len = lstrlenA(textA);
+  if (len > 0)
+  {
+    len++;
+    tmp = (WCHAR*)COMCTL32_Alloc(len*sizeof(WCHAR));
+    lstrcpyAtoW(tmp,textA);
+  } else tmp = NULL;
+
+  res = lstrcmpW(tmp,textW);
+
+  if (tmp) COMCTL32_Free(tmp);
+  return res;
+}
Index: trunk/src/comctl32/CCBase.h
===================================================================
--- trunk/src/comctl32/CCBase.h	(revision 3279)
+++ trunk/src/comctl32/CCBase.h	(revision 3280)
@@ -1,3 +1,3 @@
-/* $Id: CCBase.h,v 1.6 2000-03-21 17:30:40 cbratschi Exp $ */
+/* $Id: CCBase.h,v 1.7 2000-03-30 15:39:09 cbratschi Exp $ */
 /*
  * COMCTL32 Base Functions and Macros for all Controls
@@ -33,5 +33,7 @@
 
 LRESULT sendNotify(HWND hwnd,UINT code);
+LRESULT sendNotify(HWND hwndFrom,HWND hwndTo,UINT code);
 LRESULT sendNotify(HWND hwnd,UINT code,LPNMHDR nmhdr);
+LRESULT sendNotify(HWND hwndFrom,HWND hwndTo,UINT code,LPNMHDR nmhdr);
 LRESULT sendNotifyFormat(HWND hwnd,HWND hwndFrom,LPARAM command);
 LRESULT sendCommand(HWND hwnd,UINT wNotifyCode);
@@ -44,3 +46,5 @@
 VOID drawStubControl(HWND hwnd,HDC hdc);
 
+INT lstrcmpAtoW(CHAR* textA,WCHAR* textW);
+
 #endif
Index: trunk/src/comctl32/tooltips.cpp
===================================================================
--- trunk/src/comctl32/tooltips.cpp	(revision 3279)
+++ trunk/src/comctl32/tooltips.cpp	(revision 3280)
@@ -1,3 +1,3 @@
-/* $Id: tooltips.cpp,v 1.5 2000-03-21 17:30:45 cbratschi Exp $ */
+/* $Id: tooltips.cpp,v 1.6 2000-03-30 15:39:09 cbratschi Exp $ */
 /*
  * Tool tip control
@@ -442,5 +442,5 @@
 
     toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
-//    TRACE (tooltips, "Hide tooltip %d!\n", infoPtr->nCurrentTool);
+    //TRACE (tooltips, "Hide tooltip %d!\n", infoPtr->nCurrentTool);
     KillTimer (hwnd, ID_TIMERPOP);
 
@@ -2080,9 +2080,45 @@
 TOOLTIPS_MouseMessage (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
-    TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
-
+  TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
+
+  if (infoPtr->nTrackTool > -1)
+  {
+    DWORD code = 0;
+
+    switch (uMsg)
+    {
+      case WM_LBUTTONDOWN:
+        code = NM_CLICK;
+        break;
+
+      case WM_LBUTTONDBLCLK:
+        code = NM_DBLCLK;
+        break;
+
+      case WM_RBUTTONDOWN:
+        code = NM_RCLICK;
+        break;
+
+      case WM_RBUTTONDBLCLK:
+        code = NM_RDBLCLK;
+        break;
+    }
+
+    if (code)
+    {
+      TTTOOL_INFO *toolPtr = &infoPtr->tools[infoPtr->nTrackTool];
+      NMHDR hdr;
+
+      hdr.hwndFrom = hwnd;
+      hdr.idFrom = toolPtr->uId;
+      hdr.code = code;
+      SendMessageA(toolPtr->hwnd,WM_NOTIFY,(WPARAM)toolPtr->uId,(LPARAM)&hdr);
+    }
+  } else
+  {
     TOOLTIPS_Hide (hwnd, infoPtr);
-
-    return 0;
+  }
+
+  return 0;
 }
 
@@ -2252,4 +2288,8 @@
 }
 
+LRESULT TOOLTIPS_MouseActivate(HWND hwnd,WPARAM wParam,LPARAM lParam)
+{
+  return MA_NOACTIVATE;
+}
 
 LRESULT CALLBACK
@@ -2451,10 +2491,16 @@
         case WM_LBUTTONDOWN:
         case WM_LBUTTONUP:
+        case WM_LBUTTONDBLCLK:
         case WM_MBUTTONDOWN:
         case WM_MBUTTONUP:
+        case WM_MBUTTONDBLCLK:
         case WM_RBUTTONDOWN:
         case WM_RBUTTONUP:
+        case WM_RBUTTONDBLCLK:
         case WM_MOUSEMOVE:
             return TOOLTIPS_MouseMessage (hwnd, uMsg, wParam, lParam);
+
+        case WM_MOUSEACTIVATE:
+            return TOOLTIPS_MouseActivate(hwnd,wParam,lParam);
 
         case WM_NCCREATE:
Index: trunk/src/comctl32/treeview.cpp
===================================================================
--- trunk/src/comctl32/treeview.cpp	(revision 3279)
+++ trunk/src/comctl32/treeview.cpp	(revision 3280)
@@ -1,3 +1,3 @@
-/* $Id: treeview.cpp,v 1.4 2000-03-21 17:30:46 cbratschi Exp $ */
+/* $Id: treeview.cpp,v 1.5 2000-03-30 15:39:10 cbratschi Exp $ */
 /* Treeview control
  *
@@ -33,5 +33,4 @@
  - bug in SetScrollInfo/ShowScrollBar: WM_SIZE and WM_NCPAINT problems (i.e. RegEdit)
  - VK_LEFT in WinHlp32 displays expanded icon
- - tooltips not finished
  - expand not finished
  - TVS_FULLROWSELECT
@@ -84,4 +83,5 @@
 static LRESULT TREEVIEW_EnsureVisible(HWND hwnd,HTREEITEM hItem);
 static VOID    TREEVIEW_ISearch(HWND hwnd,CHAR ch);
+static VOID    TREEVIEW_CheckInfoTip(HWND hwnd);
 
 static LRESULT CALLBACK TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
@@ -1030,5 +1030,6 @@
   INT iItem,len;
   BOOL mustRefresh = FALSE;
-  BOOL mustRepaint = FALSE;
+  BOOL mustRepaintItem = FALSE;
+  BOOL refreshFullLine = FALSE;
 
   if (infoPtr->hwndEdit) SetFocus(hwnd);
@@ -1049,5 +1050,5 @@
   {
     wineItem->iImage = tvItem->iImage;
-    mustRepaint = TRUE;
+    mustRepaintItem = TRUE;
   }
 
@@ -1064,5 +1065,5 @@
   {
     wineItem->iSelectedImage = tvItem->iSelectedImage;
-    mustRepaint = TRUE;
+    mustRepaintItem = TRUE;
   }
 
@@ -1074,5 +1075,5 @@
     wineItem->state |= (tvItem->state & tvItem->stateMask);
     wineItem->stateMask |= tvItem->stateMask;
-    mustRepaint = (oldState != wineItem->state) || (oldMask != wineItem->stateMask);
+    mustRepaintItem = (oldState != wineItem->state) || (oldMask != wineItem->stateMask);
   }
 
@@ -1085,4 +1086,5 @@
         len = lstrlenW(tvItem->pszText)+1;
 
+        mustRepaintItem = ((wineItem->pszText == LPSTR_TEXTCALLBACKW) || (lstrcmpW(wineItem->pszText,tvItem->pszText) != 0));
         if (len > wineItem->cchTextMax)
         {
@@ -1094,10 +1096,8 @@
       } else
       {
-        if (wineItem->cchTextMax)
-        {
-          if (wineItem->pszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free (wineItem->pszText);
-          wineItem->cchTextMax = 0;
-        }
+        if (wineItem->pszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(wineItem->pszText);
+        wineItem->cchTextMax = 0;
         wineItem->pszText = LPSTR_TEXTCALLBACKW;
+        mustRepaintItem = TRUE;
       }
     } else
@@ -1105,4 +1105,5 @@
       if ((LPSTR)tvItem->pszText != LPSTR_TEXTCALLBACKA)
       {
+        mustRepaintItem = ((wineItem->pszText == LPSTR_TEXTCALLBACKW) || (lstrcmpAtoW((CHAR*)tvItem->pszText,wineItem->pszText) != 0));
         len = lstrlenA((LPSTR)tvItem->pszText)+1;
         if (len > wineItem->cchTextMax)
@@ -1115,13 +1116,11 @@
       } else
       {
-        if (wineItem->cchTextMax)
-        {
-          if (wineItem->pszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(wineItem->pszText);
-          wineItem->cchTextMax = 0;
-        }
+        if (wineItem->pszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(wineItem->pszText);
+        wineItem->cchTextMax = 0;
         wineItem->pszText = LPSTR_TEXTCALLBACKW;
+        mustRepaintItem = TRUE;
       }
     }
-    mustRepaint = TRUE;
+    refreshFullLine = TRUE;
   }
 
@@ -1129,8 +1128,8 @@
   {
     wineItem->mask |= tvItem->mask;
-    mustRepaint = TRUE;
-  }
-
-  if (mustRepaint || mustRefresh)
+    mustRepaintItem = TRUE;
+  }
+
+  if (mustRepaintItem || mustRefresh)
   {
     wineItem->calculated = FALSE;
@@ -1138,5 +1137,5 @@
       TREEVIEW_QueueRefresh(hwnd);
     else
-      TREEVIEW_RefreshItem(hwnd,wineItem,FALSE);
+      TREEVIEW_RefreshItem(hwnd,wineItem,refreshFullLine);
   }
 
@@ -1686,4 +1685,8 @@
       KillTimer(hwnd,TV_ISEARCH_TIMER);
       infoPtr->Timer &= ~TV_ISEARCH_TIMER_SET;
+      return 0;
+
+    case TV_INFOTIP_TIMER:
+      TREEVIEW_CheckInfoTip(hwnd);
       return 0;
  }
@@ -3063,13 +3066,24 @@
     if (tvdi.item.mask & TVIF_DI_SETITEM)
     {
-      wineItem->pszText = tvdi.item.pszText;
       if (buf == tvdi.item.pszText)
       {
+        wineItem->pszText = tvdi.item.pszText;
         wineItem->cchTextMax = 128;
       } else
-      {
-        //user-supplied buffer
+      { //user-supplied buffer
+        INT len = lstrlenW(tvdi.item.pszText);
+
         COMCTL32_Free(buf);
-        wineItem->cchTextMax = 0;
+        if (len > 0)
+        {
+          len++;
+          wineItem->pszText = (WCHAR*)COMCTL32_Alloc(len*sizeof(WCHAR));
+          lstrcpyW(wineItem->pszText,tvdi.item.pszText);
+          wineItem->cchTextMax = len;
+        } else
+        {
+          wineItem->pszText = NULL;
+          wineItem->cchTextMax = len;
+        }
       }
       *mustFree = FALSE;
@@ -3095,8 +3109,19 @@
         COMCTL32_Free(buf);
       } else
-      {
-        //user-supplied buffer
+      { //user-supplied buffer
+        INT len = lstrlenA((CHAR*)tvdi.item.pszText);
+
         COMCTL32_Free(buf);
-        wineItem->cchTextMax = 0;
+        if (len > 0)
+        {
+          len++;
+          wineItem->pszText = (WCHAR*)COMCTL32_Alloc(len*sizeof(WCHAR));
+          lstrcpyAtoW(wineItem->pszText,(CHAR*)tvdi.item.pszText);
+          wineItem->cchTextMax = len;
+        } else
+        {
+          wineItem->pszText = NULL;
+          wineItem->cchTextMax = len;
+        }
       }
       *mustFree = FALSE;
@@ -3354,5 +3379,5 @@
 }
 
-static LRESULT TREEVIEW_HitTest(HWND hwnd,LPTVHITTESTINFO lpht)
+static LRESULT TREEVIEW_HitTest(HWND hwnd,LPTVHITTESTINFO lpht,BOOL ignoreClientRect)
 {
   TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
@@ -3363,19 +3388,25 @@
 
   if (!lpht) return 0;
-  GetClientRect (hwnd, &rect);
+
   status = 0;
   x = lpht->pt.x;
   y = lpht->pt.y;
-  if (x < rect.left)  status |= TVHT_TOLEFT;
-  if (x > rect.right) status |= TVHT_TORIGHT;
-  if (y < rect.top )  status |= TVHT_ABOVE;
-  if (y > rect.bottom) status |= TVHT_BELOW;
-
-  if (status)
-  {
-    lpht->flags = status;
-    lpht->hItem = 0;
-
-    return 0;
+
+  if (!ignoreClientRect)
+  {
+    GetClientRect (hwnd, &rect);
+
+    if (x < rect.left)  status |= TVHT_TOLEFT;
+    if (x > rect.right) status |= TVHT_TORIGHT;
+    if (y < rect.top )  status |= TVHT_ABOVE;
+    if (y > rect.bottom) status |= TVHT_BELOW;
+
+    if (status)
+    {
+      lpht->flags = status;
+      lpht->hItem = 0;
+
+      return 0;
+    }
   }
 
@@ -3597,9 +3628,9 @@
         {
           tvdi.item.pszText     = textW;
-          tvdi.item.cchTextMax  = lstrlenW(textW);
+          tvdi.item.cchTextMax  = lstrlenW(textW)+1;
         } else
         {
           tvdi.item.pszText     = (LPWSTR)textA;
-          tvdi.item.cchTextMax  = lstrlenA(textA);
+          tvdi.item.cchTextMax  = lstrlenA(textA)+1;
         }
 
@@ -3713,5 +3744,5 @@
   }
 
-  if (!TREEVIEW_HitTest(hwnd,&hitinfo) || !(hitinfo.flags & TVHT_ONITEM)) return FALSE;
+  if (!TREEVIEW_HitTest(hwnd,&hitinfo,FALSE) || !(hitinfo.flags & TVHT_ONITEM)) return FALSE;
   wineItem = &infoPtr->items [(INT)hitinfo.hItem];
 
@@ -3723,4 +3754,91 @@
 }
 
+VOID TREEVIEW_ShowInfoTip(HWND hwnd,TREEVIEW_INFO *infoPtr,TREEVIEW_ITEM *item)
+{
+  LPWSTR text;
+  BOOL mustFree = FALSE;
+  TTTOOLINFOW ti;
+  POINT pt;
+  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
+
+  if(dwStyle & TVS_INFOTIP)
+  {
+    NMTVGETINFOTIPW tvgit;
+    WCHAR* buf = (WCHAR*)COMCTL32_Alloc(isUnicodeNotify(&infoPtr->header) ? INFOTIPSIZE*sizeof(WCHAR):INFOTIPSIZE*sizeof(CHAR));
+
+    tvgit.pszText    = buf;
+    tvgit.cchTextMax = INFOTIPSIZE;
+    tvgit.hItem      = item->hItem;
+    tvgit.lParam     = item->lParam;
+
+    sendNotify(hwnd,isUnicodeNotify(&infoPtr->header) ? TVN_GETINFOTIPW:TVN_GETINFOTIPA,&tvgit.hdr);
+    if (isUnicodeNotify(&infoPtr->header))
+    {
+      if (buf != tvgit.pszText) COMCTL32_Free(buf); else mustFree = TRUE;
+      text = tvgit.pszText;
+    } else
+    {
+      text = (WCHAR*)COMCTL32_Alloc(tvgit.cchTextMax*sizeof(WCHAR));
+      lstrcpyAtoW(text,(LPSTR)tvgit.pszText);
+      COMCTL32_Free(buf);
+    }
+  } else
+  {
+    if (item->pszText == LPSTR_TEXTCALLBACKW)
+      text = TREEVIEW_CallbackText(hwnd,item,&mustFree);
+    else
+      text = item->pszText;
+  }
+
+  infoPtr->tipItem = item->hItem;
+  SetTimer(hwnd,TV_INFOTIP_TIMER,TV_INFOTIP_DELAY,0);
+  infoPtr->Timer |= TV_INFOTIP_TIMER_SET;
+
+  ti.cbSize   = sizeof(ti);
+  ti.uId      = 0;
+  ti.hwnd     = hwnd;
+  ti.hinst    = 0;
+  ti.lpszText = text;
+  pt.x = item->text.left;
+  pt.y = item->text.top;
+  ClientToScreen(hwnd,&pt);
+  SendMessageA(infoPtr->hwndToolTip,TTM_TRACKPOSITION,0,(LPARAM)MAKELPARAM(pt.x,pt.y));
+  SendMessageA(infoPtr->hwndToolTip,TTM_UPDATETIPTEXTW,0,(LPARAM)&ti);
+  SendMessageA(infoPtr->hwndToolTip,TTM_TRACKACTIVATE,(WPARAM)TRUE,(LPARAM)&ti);
+
+  if (mustFree) COMCTL32_Free(text);
+}
+
+VOID TREEVIEW_HideInfoTip(HWND hwnd,TREEVIEW_INFO *infoPtr)
+{
+  if (infoPtr->tipItem)
+  {
+    TTTOOLINFOA ti;
+
+    infoPtr->tipItem = 0;
+    KillTimer(hwnd,TV_INFOTIP_TIMER);
+    infoPtr->Timer &= ~TV_INFOTIP_TIMER_SET;
+
+    ti.cbSize   = sizeof(TTTOOLINFOA);
+    ti.uId      = 0;
+    ti.hwnd     = (UINT)hwnd;
+
+    SendMessageA(infoPtr->hwndToolTip,TTM_TRACKACTIVATE,(WPARAM)FALSE,(LPARAM)&ti);
+  }
+}
+
+static VOID TREEVIEW_CheckInfoTip(HWND hwnd)
+{
+  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
+  TVHITTESTINFO ht;
+
+  GetCursorPos(&ht.pt);
+  ScreenToClient(hwnd,&ht.pt);
+  TREEVIEW_HitTest(hwnd,&ht,TRUE);
+
+  if ((ht.hItem != infoPtr->tipItem) || !(ht.flags & TVHT_ONITEMLABEL))
+    TREEVIEW_HideInfoTip(hwnd,infoPtr);
+}
+
 static LRESULT TREEVIEW_MouseMove(HWND hwnd,WPARAM wParam,LPARAM lParam)
 {
@@ -3732,5 +3850,5 @@
   ht.pt.y = (INT)HIWORD(lParam);
 
-  TREEVIEW_HitTest(hwnd,&ht);
+  TREEVIEW_HitTest(hwnd,&ht,FALSE);
 
   if (ht.hItem)
@@ -3740,56 +3858,10 @@
     item = &infoPtr->items[(INT)ht.hItem];
 
-    if (infoPtr->hwndToolTip && ((item->text.left < 0) || (item->text.right > infoPtr->uVisibleWidth)) && (infoPtr->tipItem != item->hItem))
-    {
-      DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
-      LPWSTR text;
-      BOOL mustFree = FALSE;
-      TTTOOLINFOW ti;
-      POINT pt;
-
-      if(dwStyle & TVS_INFOTIP)
-      {
-        NMTVGETINFOTIPW tvgit;
-        WCHAR* buf = (WCHAR*)COMCTL32_Alloc(isUnicodeNotify(&infoPtr->header) ? INFOTIPSIZE*sizeof(WCHAR):INFOTIPSIZE*sizeof(CHAR));
-
-        tvgit.pszText    = buf;
-        tvgit.cchTextMax = INFOTIPSIZE;
-        tvgit.hItem      = item->hItem;
-        tvgit.lParam     = item->lParam;
-
-        sendNotify(hwnd,isUnicodeNotify(&infoPtr->header) ? TVN_GETINFOTIPW:TVN_GETINFOTIPA,&tvgit.hdr);
-        if (isUnicodeNotify(&infoPtr->header))
-        {
-          if (buf != tvgit.pszText) COMCTL32_Free(buf); else mustFree = TRUE;
-          text = tvgit.pszText;
-        } else
-        {
-          text = (WCHAR*)COMCTL32_Alloc(tvgit.cchTextMax*sizeof(WCHAR));
-          lstrcpyAtoW(text,(LPSTR)tvgit.pszText);
-          COMCTL32_Free(buf);
-        }
-      } else
-      {
-        if (item->pszText == LPSTR_TEXTCALLBACKW)
-          text = TREEVIEW_CallbackText(hwnd,item,&mustFree);
-        else
-          text = item->pszText;
-      }
-#if 0 //CB: not yet
-      infoPtr->tipItem = item->hItem;
-      ti.cbSize   = sizeof(ti);
-      ti.uId      = 0;
-      ti.hwnd     = hwnd;
-      ti.hinst    = 0;
-      ti.lpszText = text;
-      pt.x = ti.rect.left;
-      pt.y = ti.rect.top;
-      ClientToScreen(hwnd,&pt);
-      SendMessageA(infoPtr->hwndToolTip,TTM_TRACKPOSITION,0,(LPARAM)MAKELPARAM(pt.x,pt.y));
-      SendMessageA(infoPtr->hwndToolTip,TTM_UPDATETIPTEXTW,0,(LPARAM)&ti);
-      SendMessageA(infoPtr->hwndToolTip,TTM_TRACKACTIVATE,(WPARAM)TRUE,(LPARAM)&ti);
-#endif
-      if (mustFree) COMCTL32_Free(text);
-    }
+    if (infoPtr->hwndToolTip && (ht.flags & TVHT_ONITEMLABEL) &&
+        ((item->text.left < 0) || (item->text.right > infoPtr->uVisibleWidth) || (item->text.top < 0) || (item->text.bottom > infoPtr->uVisibleHeight)) &&
+        (infoPtr->tipItem != item->hItem))
+      TREEVIEW_ShowInfoTip(hwnd,infoPtr,item);
+    else
+      TREEVIEW_HideInfoTip(hwnd,infoPtr);
 
     if (dwStyle & TVS_TRACKSELECT)
@@ -3824,5 +3896,5 @@
   ht.pt.y = (INT)HIWORD(lParam);
 
-  TREEVIEW_HitTest (hwnd,&ht);
+  TREEVIEW_HitTest (hwnd,&ht,FALSE);
 
   bTrack = (ht.flags & TVHT_ONITEM) && !(dwStyle & TVS_DISABLEDRAGDROP);
@@ -3907,5 +3979,5 @@
    ht.pt.y = (INT)HIWORD(lParam);
 
-   TREEVIEW_HitTest(hwnd,&ht);
+   TREEVIEW_HitTest(hwnd,&ht,FALSE);
 
    if (TREEVIEW_TrackMouse(hwnd, ht.pt))
@@ -4731,4 +4803,32 @@
 }
 
+static LRESULT TREEVIEW_Notify(HWND hwnd,WPARAM wParam,LPARAM lParam)
+{
+  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
+  LPNMHDR hdr = (LPNMHDR)lParam;
+
+  if (hdr->hwndFrom == infoPtr->hwndToolTip)
+  {
+    LPARAM lp = (LPARAM)GetMessagePos();
+    POINT pt;
+
+    pt.x = (INT)LOWORD(lp);
+    pt.y = (INT)HIWORD(lp);
+    ScreenToClient(hwnd,&pt);
+    lp = MAKELONG(pt.x,pt.y);
+
+    if (hdr->code == (UINT)NM_CLICK)
+      TREEVIEW_LButtonDown(hwnd,0,lp);
+    else if (hdr->code == (UINT)NM_RCLICK)
+      TREEVIEW_RButtonDown(hwnd,0,lp);
+    else if (hdr->code == (UINT)NM_DBLCLK)
+      TREEVIEW_LButtonDoubleClick(hwnd,0,lp);
+    else if (hdr->code == (UINT)NM_RDBLCLK)
+      TREEVIEW_RButtonDoubleClick(hwnd,0,lp);
+  }
+
+  return 0;
+}
+
 static LRESULT WINAPI
 TREEVIEW_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -4803,5 +4903,5 @@
 
         case TVM_HITTEST:
-          return TREEVIEW_HitTest(hwnd,(LPTVHITTESTINFO)lParam);
+          return TREEVIEW_HitTest(hwnd,(LPTVHITTESTINFO)lParam,FALSE);
 
         case TVM_CREATEDRAGIMAGE:
@@ -4924,4 +5024,7 @@
         case WM_RBUTTONDBLCLK:
           return TREEVIEW_RButtonDoubleClick(hwnd,wParam,lParam);
+
+        case WM_NOTIFY:
+          return TREEVIEW_Notify(hwnd,wParam,lParam);
 
         case WM_STYLECHANGED:
