diff win/dw.c @ 1400:ccd383e11ff8

Allow removing of tooltips by passing NULL or "" and prevent double tooltips on some platforms.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 27 Nov 2011 20:28:15 +0000
parents 8e569dd09d94
children 20c6d0c50c94
line wrap: on
line diff
--- a/win/dw.c	Sun Nov 27 12:08:05 2011 +0000
+++ b/win/dw.c	Sun Nov 27 20:28:15 2011 +0000
@@ -3529,16 +3529,22 @@
 
 void _create_tooltip(HWND handle, char *text)
 {
+    HWND hwndTT = 0;
+    HWND oldTT = (HWND)dw_window_get_data(handle, "_dw_tooltip");
+    
+    if(oldTT)
+        DestroyWindow(oldTT);
     if(text)
     {
+        TOOLINFO ti = { 0 };
+        
         /* Create a tooltip. */
-        HWND hwndTT = CreateWindowEx(WS_EX_TOPMOST,
+        hwndTT = CreateWindowEx(WS_EX_TOPMOST,
             TOOLTIPS_CLASS, NULL,
             WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
             CW_USEDEFAULT, CW_USEDEFAULT,
             CW_USEDEFAULT, CW_USEDEFAULT,
             handle, NULL, DWInstance,NULL);
-        TOOLINFO ti = { 0 };
 
         SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
 
@@ -3555,6 +3561,7 @@
         /* Associate the tooltip with the "tool" window. */
         SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
     }
+    dw_window_set_data(handle, "_dw_tooltip", (void *)hwndTT);
 }
 
 #ifndef GDIPLUS