[PATCH] setup: increase tooltip delay for larger tooltips

Igor Pechtchanski pechtcha@cs.nyu.edu
Thu Sep 8 03:37:00 GMT 2005


On Wed, 7 Sep 2005, Eric Blake wrote:

> > I have updated the Cygwin setup utility to version 2.510.2.1.
> [snip]
> Minor bugs I have noticed:
> [snip]
> The tooltip for the View button disappears before I have had a
> chance to finish reading it, since it contains so much text.

The attached patch increases tooltip limits for tooltips larger than 80
characters, proportionally to the extra size.  The delay calculation is
rather arbitrary -- I got about 20 seconds on the tooltip Eric complained
about.

Note: I think the maximum tooltip delay is 32768ms -- anything larger than
that was ignored (this is undocumented, but may be implied by
LPARAM==short).  That's the reason for the 0.5 factor in the delay
calculation.  To make the code more robust, we should probably test for
overflow and max out at some value.

As usual, the ChangeLog is below.
	Igor
==============================================================================
ChangeLog:
2005-09-07  Igor Pechtchanski  <pechtcha@cs.nyu.edu>

	* window.h (Window::TooltipDisplayHandler): New member function.
	* window.cc (Window::TooltipDisplayHandler): Set delay proportional
	to tooltip length.
	* proppage.cc (PropertyPage::DialogProc): Call TooltipDisplayHandler
	for TTN_SHOW notifications.

-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

If there's any real truth it's that the entire multidimensional infinity
of the Universe is almost certainly being run by a bunch of maniacs. /DA
-------------- next part --------------
Index: proppage.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/proppage.cc,v
retrieving revision 2.17
diff -u -p -r2.17 proppage.cc
--- proppage.cc	21 May 2005 23:04:03 -0000	2.17
+++ proppage.cc	8 Sep 2005 03:10:17 -0000
@@ -256,6 +256,10 @@ PropertyPage::DialogProc (UINT message, 
             {
               return TooltipNotificationHandler (lParam);
             }
+          case TTN_SHOW:
+            {
+              return TooltipDisplayHandler (wParam, lParam);
+            }
           default:
             {
               // Unrecognized notification
Index: window.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/window.cc,v
retrieving revision 2.13
diff -u -p -r2.13 window.cc
--- window.cc	7 May 2005 04:27:08 -0000	2.13
+++ window.cc	8 Sep 2005 03:10:17 -0000
@@ -483,3 +483,33 @@ Window::TooltipNotificationHandler (LPAR
   return FALSE;
 }
 
+BOOL
+Window::TooltipDisplayHandler (WPARAM wParam, LPARAM lParam)
+// this is the handler for TTN_SHOW notifications
+{
+  NMHDR *hdr = (NMHDR *)lParam;
+  int ctrlID = GetDlgCtrlID ((HWND)hdr->idFrom);
+  std::map<int, int>::iterator findID = TooltipStrings.find (ctrlID);
+  int len, delay;
+  
+  if (ctrlID != 0 && findID != TooltipStrings.end ()) {
+  
+    // reset timeout for tooltips
+    SendMessage(TooltipHandle, TTM_SETDELAYTIME, TTDT_AUTOPOP, -1);
+    
+    // Fetch the string resource
+    TCHAR buf[2048];
+    LoadString (GetInstance (), findID->second, (LPTSTR)buf,
+        (sizeof (buf) / sizeof (TCHAR)));
+
+    // increase timeout proportionally for longer tooltips
+    if ((len = strlen(buf)) > 80) {
+      delay = SendMessage(TooltipHandle, TTM_GETDELAYTIME, TTDT_AUTOPOP, 0);
+      delay = (int) (delay * (len + 80) * 0.5 / 80);
+      SendMessage(TooltipHandle, TTM_SETDELAYTIME, TTDT_AUTOPOP, delay);
+    }
+  }
+
+  return FALSE;
+}
+
Index: window.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/window.h,v
retrieving revision 2.11
diff -u -p -r2.11 window.h
--- window.h	7 May 2005 04:27:08 -0000	2.11
+++ window.h	8 Sep 2005 03:10:17 -0000
@@ -148,6 +148,7 @@ public:
   void AddTooltip (int id, const char *text);
   void AddTooltip (int id, int string_resource);
   BOOL TooltipNotificationHandler (LPARAM lParam);
+  BOOL TooltipDisplayHandler (WPARAM wParam, LPARAM lParam);
 };
 
 #endif /* SETUP_WINDOW_H */


More information about the Cygwin-apps mailing list