LB_ITEMFROMPOINT

Ken Belleau jamez at ivic.qc.ca
Fri Jan 27 10:38:57 CST 2006


Details included in the patch.

-------------- next part --------------
--- wine-0.9.6/dlls/user/listbox.c	2006-01-04 11:05:03.000000000 -0500
+++ listbox.c	2006-01-27 11:13:56.000000000 -0500
@@ -2726,18 +2726,28 @@
 
     case LB_ITEMFROMPOINT:
         {
-            POINT pt;
-            RECT rect;
-
-	    pt.x = LOWORD(lParam);
-	    pt.y = HIWORD(lParam);
-	    rect.left = 0;
-	    rect.top = 0;
-	    rect.right = descr->width;
-	    rect.bottom = descr->height;
-
-            return MAKELONG( LISTBOX_GetItemFromPoint(descr, pt.x, pt.y),
-                             !PtInRect( &rect, pt ) );
+            /*******************************************************
+              Here, MSDN is INCORRECT. The return value
+              has nothing to do with the client rect.
+
+              High word is 0 if it hit an item, 1 otherwise.
+              Low word is index of nearest item.
+
+              When the list is empty,
+                WinXP returns 0x0001FFFF
+                WinME returns 0x00010000
+
+              I couldn't test it on other versions, so I assumed
+              NTs were identical to XP, and others as ME.
+             ******************************************************/
+
+            INT hit, idx;
+
+            hit = LISTBOX_GetItemFromPoint(descr, LOWORD(lParam), HIWORD(lParam));
+            idx = descr->nb_items-1;
+            if ((idx == -1) && (GetVersion() & 0x80000000))
+              idx++;
+            return MAKELONG( (hit != -1) ? hit : idx, (hit == -1) );
         }
 
     case LB_SETCARETINDEX16:


More information about the wine-patches mailing list