ScrollWindowEx fixes.

Rein Klazes rklazes at xs4all.nl
Sat Aug 21 08:48:02 CDT 2004


Hi,

This fixes a serious display problem in the declaration programs of the
Dutch tax office.

Changelog:
	windows	: scroll.c
	When there are no pixels to scroll, ScrollWindowEx must still
	scroll children and update the hrgnUpdate and rcUpdate
	arguments.
	
Rein.
-- 
Rein Klazes
rklazes at xs4all.nl
-------------- next part --------------
--- wine/windows/scroll.c	2004-06-16 08:47:50.000000000 +0200
+++ mywine/windows/scroll.c	2004-08-21 15:25:17.000000000 +0200
@@ -61,30 +61,33 @@
 }
 
 /*************************************************************************
- *		scroll_window
+ *		ScrollWindowEx (USER32.@)
  *
  * Note: contrary to what the doc says, pixels that are scrolled from the
  *      outside of clipRect to the inside are NOT painted.
  *
- * Parameter are the same as in ScrollWindowEx, with the additional
- * requirement that rect and clipRect are _valid_ pointers, to
- * rectangles _within_ the client are. Moreover, there is something
- * to scroll.
  */
-static INT scroll_window( HWND hwnd, INT dx, INT dy, const RECT *rect,
-                          const RECT *clipRect, HRGN hrgnUpdate, LPRECT rcUpdate, UINT flags )
+INT WINAPI ScrollWindowEx( HWND hwnd, INT dx, INT dy,
+                               const RECT *rect, const RECT *clipRect,
+                               HRGN hrgnUpdate, LPRECT rcUpdate,
+                               UINT flags )
 {
-    INT   retVal;
+    INT   retVal = NULLREGION;
     BOOL  bOwnRgn = TRUE;
     BOOL  bUpdate = (rcUpdate || hrgnUpdate || flags & (SW_INVALIDATE | SW_ERASE));
     HRGN  hrgnTemp;
     HDC   hDC;
     RECT  rc, cliprc;
+    RECT caretrc;
+    HWND hwndCaret = NULL;
 
     TRACE( "%p, %d,%d hrgnUpdate=%p rcUpdate = %p %s %04x\n",
            hwnd, dx, dy, hrgnUpdate, rcUpdate, wine_dbgstr_rect(rect), flags );
     TRACE( "clipRect = %s\n", wine_dbgstr_rect(clipRect));
 
+    if (!WIN_IsWindowDrawable( hwnd, TRUE )) return ERROR;
+    hwnd = WIN_GetFullHandle( hwnd );
+
     GetClientRect(hwnd, &rc);
     if (rect) IntersectRect(&rc, &rc, rect);
 
@@ -94,29 +97,40 @@
     if( hrgnUpdate ) bOwnRgn = FALSE;
     else if( bUpdate ) hrgnUpdate = CreateRectRgn( 0, 0, 0, 0 );
 
-    hDC = GetDCEx( hwnd, 0, DCX_CACHE | DCX_USESTYLE );
-    if (hDC)
-    {
-        ScrollDC( hDC, dx, dy, &rc, &cliprc, hrgnUpdate, rcUpdate );
+    if( !IsRectEmpty(&cliprc) && (dx || dy)) {
+        caretrc = rc;
+        hwndCaret = fix_caret(hwnd, &caretrc, flags);
 
-        ReleaseDC( hwnd, hDC );
+        hDC = GetDCEx( hwnd, 0, DCX_CACHE | DCX_USESTYLE );
+        if (hDC)
+        {
+            ScrollDC( hDC, dx, dy, &rc, &cliprc, hrgnUpdate, rcUpdate );
 
-        if (!bUpdate)
-            RedrawWindow( hwnd, NULL, hrgnUpdate, RDW_INVALIDATE | RDW_ERASE );
-    }
+            ReleaseDC( hwnd, hDC );
 
-    /* Take into account the fact that some damage may have occurred during the scroll */
-    hrgnTemp = CreateRectRgn( 0, 0, 0, 0 );
-    retVal = GetUpdateRgn( hwnd, hrgnTemp, FALSE );
-    if (retVal != NULLREGION)
-    {
-        HRGN hrgnClip = CreateRectRgnIndirect(&cliprc);
-        OffsetRgn( hrgnTemp, dx, dy );
-        CombineRgn( hrgnTemp, hrgnTemp, hrgnClip, RGN_AND );
-        RedrawWindow( hwnd, NULL, hrgnTemp, RDW_INVALIDATE | RDW_ERASE );
-        DeleteObject( hrgnClip );
+            if (!bUpdate)
+                RedrawWindow( hwnd, NULL, hrgnUpdate, RDW_INVALIDATE | RDW_ERASE );
+        }
+
+        /* Take into account the fact that some damage may have occurred during
+         * the scroll */
+        hrgnTemp = CreateRectRgn( 0, 0, 0, 0 );
+        retVal = GetUpdateRgn( hwnd, hrgnTemp, FALSE );
+        if (retVal != NULLREGION)
+        {
+            HRGN hrgnClip = CreateRectRgnIndirect(&cliprc);
+            OffsetRgn( hrgnTemp, dx, dy );
+            CombineRgn( hrgnTemp, hrgnTemp, hrgnClip, RGN_AND );
+            RedrawWindow( hwnd, NULL, hrgnTemp, RDW_INVALIDATE | RDW_ERASE );
+            DeleteObject( hrgnClip );
+        }
+        DeleteObject( hrgnTemp );
+    } else {
+        /* nothing was scrolled */
+        if( !bOwnRgn) 
+            SetRectRgn( hrgnUpdate, 0, 0, 0, 0 );
+        SetRectEmpty( rcUpdate);
     }
-    DeleteObject( hrgnTemp );
 
     if( flags & SW_SCROLLCHILDREN )
     {
@@ -129,7 +143,7 @@
             {
                 GetWindowRect( list[i], &r );
                 MapWindowPoints( 0, hwnd, (POINT *)&r, 2 );
-                if (!rect || IntersectRect(&dummy, &r, &rc))
+                if (!rect || IntersectRect(&dummy, &r, rect))
                     SetWindowPos( list[i], 0, r.left + dx, r.top  + dy, 0, 0,
                                   SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE |
                                   SWP_NOREDRAW | SWP_DEFERERASE );
@@ -143,6 +157,11 @@
                       ((flags & SW_ERASE) ? RDW_ERASENOW : 0) |
                       ((flags & SW_SCROLLCHILDREN) ? RDW_ALLCHILDREN : 0 ) );
 
+    if( hwndCaret ) {
+        SetCaretPos( caretrc.left + dx, caretrc.top + dy );
+        ShowCaret(hwndCaret);
+    }
+    
     if( bOwnRgn && hrgnUpdate ) DeleteObject( hrgnUpdate );
 
     return retVal;
@@ -249,46 +268,3 @@
     }
     return TRUE;
 }
-
-
-/*************************************************************************
- *		ScrollWindowEx (USER32.@)
- *
- * NOTE: Use this function instead of ScrollWindow32
- */
-INT WINAPI ScrollWindowEx( HWND hwnd, INT dx, INT dy,
-                               const RECT *rect, const RECT *clipRect,
-                               HRGN hrgnUpdate, LPRECT rcUpdate,
-                               UINT flags )
-{
-    RECT rc, cliprc;
-    INT result;
-    
-    if (!WIN_IsWindowDrawable( hwnd, TRUE )) return ERROR;
-    hwnd = WIN_GetFullHandle( hwnd );
-
-    GetClientRect(hwnd, &rc);
-    if (rect) IntersectRect(&rc, &rc, rect);
-
-    if (clipRect) IntersectRect(&cliprc,&rc,clipRect);
-    else cliprc = rc;
-
-    if (!IsRectEmpty(&cliprc) && (dx || dy))
-    {
-        RECT caretrc = rc;
-        HWND hwndCaret = fix_caret(hwnd, &caretrc, flags);
-
-        result = scroll_window( hwnd, dx, dy, rect, clipRect,
-                hrgnUpdate, rcUpdate, flags );
-
-        if( hwndCaret )
-        {
-            SetCaretPos( caretrc.left + dx, caretrc.top + dy );
-            ShowCaret(hwndCaret);
-        }
-    }
-    else 
-	result = NULLREGION;
-    
-    return result;
-}


More information about the wine-patches mailing list