[PATCH resend 2/6] user32/listbox: Handle Mouse Wheel scrolling for multi-column listboxes properly

Gabriel Ivăncescu gabrielopcode at gmail.com
Mon Dec 10 04:34:23 CST 2018


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=22253
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
 dlls/user32/listbox.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c
index 594c956..26d5410 100644
--- a/dlls/user32/listbox.c
+++ b/dlls/user32/listbox.c
@@ -2025,9 +2025,11 @@ static LRESULT LISTBOX_HandleHScroll( LB_DESCR *descr, WORD scrollReq, WORD pos
 
 static LRESULT LISTBOX_HandleMouseWheel(LB_DESCR *descr, SHORT delta )
 {
-    UINT pulScrollLines = 3;
+    INT pulScrollLines;
+    UINT tmp = 3;
 
-    SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
+    SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &tmp, 0);
+    pulScrollLines = tmp;
 
     /* if scrolling changes direction, ignore left overs */
     if ((delta < 0 && descr->wheel_remain < 0) ||
@@ -2038,10 +2040,21 @@ static LRESULT LISTBOX_HandleMouseWheel(LB_DESCR *descr, SHORT delta )
 
     if (descr->wheel_remain && pulScrollLines)
     {
-        int cLineScroll;
-        pulScrollLines = min((UINT) descr->page_size, pulScrollLines);
-        cLineScroll = pulScrollLines * (float)descr->wheel_remain / WHEEL_DELTA;
-        descr->wheel_remain -= WHEEL_DELTA * cLineScroll / (int)pulScrollLines;
+        INT cLineScroll;
+        if (descr->style & LBS_MULTICOLUMN)
+        {
+            pulScrollLines = min((UINT)descr->width / descr->column_width, pulScrollLines);
+            pulScrollLines = max(1U, pulScrollLines);
+            cLineScroll = (pulScrollLines * descr->wheel_remain) / WHEEL_DELTA;
+            descr->wheel_remain -= (cLineScroll * WHEEL_DELTA) / pulScrollLines;
+            cLineScroll *= descr->page_size;
+        }
+        else
+        {
+            pulScrollLines = min((UINT)descr->page_size, pulScrollLines);
+            cLineScroll = (pulScrollLines * descr->wheel_remain) / WHEEL_DELTA;
+            descr->wheel_remain -= (cLineScroll * WHEEL_DELTA) / pulScrollLines;
+        }
         LISTBOX_SetTopItem( descr, descr->top_item - cLineScroll, TRUE );
     }
     return 0;
-- 
2.19.1




More information about the wine-devel mailing list