Two small scrollbar fixes

Rein Klazes wijn at wanadoo.nl
Mon Mar 28 07:35:21 CST 2005


On 28 Mar 2005 12:48:11 +0200, you wrote:

> Rein Klazes <wijn at wanadoo.nl> writes:
> 
> > dlls/user	: scroll.c
> > dlls/user/tests	: win.c
> > 
> > - GetScrollRange should return an empty range, both upper and lower
> > limit zero, if the window has no scrollbars (msdn);
> > - GetScrollInfo's return value is FALSE if the window has no scrollbars;
> 
> This breaks the message test:
> 
> msg.c:2761: Test failed: GetScrollInfo error 5
> msg.c:2761: Test failed: GetScrollInfo error 5

I see, SB_CTL is treated different. Attached is an upgraded patch.

Changelog:

dlls/user	: scroll.c
dlls/user/tests	: win.c

- GetScrollRange should return an empty range, both upper and lower
limit zero, if the window has no scrollbars (msdn);
- GetScrollInfo's return value is TRUE is nBar is SB_CTL or if anything
is filled in the SCROLLINFO structure, otherwise the return value is
FALSE. 

Rein.
-------------- next part --------------
--- wine/dlls/user/scroll.c	2005-03-25 20:52:36.000000000 +0100
+++ mywine/dlls/user/scroll.c	2005-03-28 15:08:45.000000000 +0200
@@ -1330,8 +1330,6 @@ static INT SCROLL_GetScrollPos(HWND hwnd
 static BOOL SCROLL_GetScrollRange(HWND hwnd, INT nBar, LPINT lpMin, LPINT lpMax)
 {
     LPSCROLLBAR_INFO infoPtr = SCROLL_GetInternalInfo(hwnd, nBar, FALSE);
-    if (!infoPtr)
-        return FALSE;
 
     if (lpMin) *lpMin = infoPtr ? infoPtr->minVal : 0;
     if (lpMax) *lpMax = infoPtr ? infoPtr->maxVal : 0;
@@ -1741,6 +1739,8 @@ done:
  *
  * RETURNS
  *  TRUE if SCROLLINFO is filled
+ *  ( if nBar is SB_CTL, GetScrollInfo returns TRUE even if nothing
+ *  is filled)
  */
 BOOL WINAPI GetScrollInfo(HWND hwnd, INT nBar, LPSCROLLINFO info)
 {
@@ -1748,11 +1748,11 @@ BOOL WINAPI GetScrollInfo(HWND hwnd, INT
 
     /* Refer SB_CTL requests to the window */
     if (nBar == SB_CTL)
+    {
         SendMessageW(hwnd, SBM_GETSCROLLINFO, (WPARAM)0, (LPARAM)info);
-    else
-        SCROLL_GetScrollInfo(hwnd, nBar, info);
-
-    return TRUE;
+        return TRUE;
+    }
+    return SCROLL_GetScrollInfo(hwnd, nBar, info);
 }
 
 
--- wine/dlls/user/tests/win.c	2005-03-26 08:11:50.000000000 +0100
+++ mywine/dlls/user/tests/win.c	2005-03-27 18:59:14.000000000 +0200
@@ -2650,6 +2650,43 @@ void test_scrollvalidate( HWND parent)
     DestroyWindow( hwnd2);
 }
 
+/* couple of tests of return values of scrollbar functions
+ * called on a scrollbarless window */ 
+void test_scroll()
+{
+    BOOL ret;
+    INT min, max;
+    SCROLLINFO si;
+    HWND hwnd = CreateWindowExA(0, "Static", "Wine test window",
+        WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP,
+        100, 100, 200, 200, 0, 0, 0, NULL);
+    /* horizontal */
+    ret = GetScrollRange( hwnd, SB_HORZ, &min, &max);
+    ok( ret, "GetScrollRange returns FALSE\n");
+    ok( min == 0, "minimum scroll pos is %d (should be zero)\n", min);
+    ok( max == 0, "maximum scroll pos is %d (should be zero)\n", min);
+    si.cbSize = sizeof( si);
+    si.fMask = SIF_PAGE;
+    si.nPage = 0xdeadbeef;
+    ret = GetScrollInfo( hwnd, SB_HORZ, &si);
+    ok( !ret, "GetScrollInfo returns %d (should be zero)\n", ret);
+    ok( si.nPage == 0xdeadbeef, "unexpected value for nPage is %d\n", si.nPage);
+    /* vertical */
+    ret = GetScrollRange( hwnd, SB_VERT, &min, &max);
+    ok( ret, "GetScrollRange returns FALSE\n");
+    ok( min == 0, "minimum scroll pos is %d (should be zero)\n", min);
+    ok( max == 0, "maximum scroll pos is %d (should be zero)\n", min);
+    si.cbSize = sizeof( si);
+    si.fMask = SIF_PAGE;
+    si.nPage = 0xdeadbeef;
+    ret = GetScrollInfo( hwnd, SB_VERT, &si);
+    ok( !ret, "GetScrollInfo returns %d (should be zero)\n", ret);
+    ok( si.nPage == 0xdeadbeef, "unexpected value for nPage is %d\n", si.nPage);
+    /* clean up */
+    DestroyWindow( hwnd);
+}
+
+
 START_TEST(win)
 {
     pGetAncestor = (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetAncestor" );
@@ -2709,6 +2746,7 @@ START_TEST(win)
     test_validatergn(hwndMain);
     test_nccalcscroll( hwndMain);
     test_scrollvalidate( hwndMain);
+    test_scroll();
 
     UnhookWindowsHookEx(hhook);
     


More information about the wine-devel mailing list