[PATCH 1/7] win32u: Support undocumented SIF_RETURNPREV flag in set_scroll_info.

Jacek Caban wine at gitlab.winehq.org
Mon Jul 4 18:04:42 CDT 2022


From: Jacek Caban <jacek at codeweavers.com>

---
 dlls/user32/tests/scroll.c | 13 +++++++++++++
 dlls/win32u/scroll.c       |  9 ++++++---
 include/ntuser.h           |  3 +++
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/dlls/user32/tests/scroll.c b/dlls/user32/tests/scroll.c
index 20bb0dc111b..95782a47a6e 100644
--- a/dlls/user32/tests/scroll.c
+++ b/dlls/user32/tests/scroll.c
@@ -671,6 +671,19 @@ static void test_SetScrollInfo(void)
     ret = IsWindowEnabled(hScroll);
     ok(ret, "Unexpected enabled state.\n");
 
+    EnableScrollBar(mainwnd, SB_CTL, ESB_ENABLE_BOTH);
+
+    si.fMask = SIF_POS;
+    si.nPos = 3;
+    ret = SetScrollInfo(mainwnd, SB_HORZ, &si, FALSE);
+    ok(ret == 3, "SetScrollInfo returned %d\n", ret);
+
+    /* undocumented flag making SetScrollInfo return previous position */
+    si.fMask = SIF_POS | 0x1000;
+    si.nPos = 4;
+    ret = SetScrollInfo(mainwnd, SB_HORZ, &si, FALSE);
+    ok(ret == 3, "SetScrollInfo returned %d\n", ret);
+
     DestroyWindow(hScroll);
     DestroyWindow(mainwnd);
 }
diff --git a/dlls/win32u/scroll.c b/dlls/win32u/scroll.c
index a51c7d3cf93..d48755cec7c 100644
--- a/dlls/win32u/scroll.c
+++ b/dlls/win32u/scroll.c
@@ -824,7 +824,7 @@ void track_scroll_bar( HWND hwnd, int scrollbar, POINT pt )
  */
 static inline BOOL validate_scroll_info( const SCROLLINFO *info )
 {
-    return !(info->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL) ||
+    return !(info->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL | SIF_RETURNPREV) ||
              (info->cbSize != sizeof(*info) &&
               info->cbSize != sizeof(*info) - sizeof(info->nTrackPos)));
 }
@@ -862,7 +862,7 @@ static int set_scroll_info( HWND hwnd, int bar, const SCROLLINFO *info, BOOL red
 {
     struct scroll_info *scroll;
     UINT new_flags;
-    int action = 0, ret;
+    int action = 0, ret = 0;
 
     /* handle invalid data structure */
     if (!validate_scroll_info( info ) ||
@@ -878,6 +878,9 @@ static int set_scroll_info( HWND hwnd, int bar, const SCROLLINFO *info, BOOL red
         TRACE( "\n" );
     }
 
+    /* undocumented flag, return previous position instead of modified */
+    if (info->fMask & SIF_RETURNPREV) ret = scroll->curVal;
+
     /* Set the page size */
     if ((info->fMask & SIF_PAGE) && scroll->page != info->nPage)
     {
@@ -970,7 +973,7 @@ static int set_scroll_info( HWND hwnd, int bar, const SCROLLINFO *info, BOOL red
     }
 
 done:
-    ret = scroll->curVal;
+    if (!(info->fMask & SIF_RETURNPREV)) ret = scroll->curVal;
     release_scroll_info_ptr( scroll );
     if (action & SA_SSI_HIDE)
         show_scroll_bar( hwnd, bar, FALSE, FALSE );
diff --git a/include/ntuser.h b/include/ntuser.h
index fecdbbbe253..34701d21533 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -269,6 +269,9 @@ struct send_message_callback_params
 /* NtUserScrollWindowEx flag */
 #define SW_NODCCACHE  0x8000
 
+/* NtUserSetScrollInfo flag */
+#define SIF_RETURNPREV  0x1000
+
 /* NtUserInitializeClientPfnArrays parameter, not compatible with Windows */
 struct user_client_procs
 {
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/374



More information about the wine-devel mailing list