2 * Window painting functions
4 * Copyright 1993, 1994, 1995, 2001, 2004 Alexandre Julliard
5 * Copyright 1999 Alex Korobka
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/port.h"
33 #include "wine/server.h"
35 #include "user_private.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(win
);
41 /***********************************************************************
44 static void dump_rdw_flags(UINT flags
)
47 if (flags
& RDW_INVALIDATE
) TRACE(" RDW_INVALIDATE");
48 if (flags
& RDW_INTERNALPAINT
) TRACE(" RDW_INTERNALPAINT");
49 if (flags
& RDW_ERASE
) TRACE(" RDW_ERASE");
50 if (flags
& RDW_VALIDATE
) TRACE(" RDW_VALIDATE");
51 if (flags
& RDW_NOINTERNALPAINT
) TRACE(" RDW_NOINTERNALPAINT");
52 if (flags
& RDW_NOERASE
) TRACE(" RDW_NOERASE");
53 if (flags
& RDW_NOCHILDREN
) TRACE(" RDW_NOCHILDREN");
54 if (flags
& RDW_ALLCHILDREN
) TRACE(" RDW_ALLCHILDREN");
55 if (flags
& RDW_UPDATENOW
) TRACE(" RDW_UPDATENOW");
56 if (flags
& RDW_ERASENOW
) TRACE(" RDW_ERASENOW");
57 if (flags
& RDW_FRAME
) TRACE(" RDW_FRAME");
58 if (flags
& RDW_NOFRAME
) TRACE(" RDW_NOFRAME");
65 RDW_NOINTERNALPAINT | \
74 if (flags
& ~RDW_FLAGS
) TRACE(" %04x", flags
& ~RDW_FLAGS
);
80 /***********************************************************************
83 * Return update region (in screen coordinates) for a window.
85 static HRGN
get_update_region( HWND hwnd
, UINT
*flags
, HWND
*child
)
94 if (!(data
= HeapAlloc( GetProcessHeap(), 0, sizeof(*data
) + size
- 1 )))
96 SetLastError( ERROR_OUTOFMEMORY
);
100 SERVER_START_REQ( get_update_region
)
104 wine_server_set_reply( req
, data
->Buffer
, size
);
105 if (!(status
= wine_server_call( req
)))
107 size_t reply_size
= wine_server_reply_size( reply
);
108 data
->rdh
.dwSize
= sizeof(data
->rdh
);
109 data
->rdh
.iType
= RDH_RECTANGLES
;
110 data
->rdh
.nCount
= reply_size
/ sizeof(RECT
);
111 data
->rdh
.nRgnSize
= reply_size
;
112 hrgn
= ExtCreateRegion( NULL
, size
, data
);
113 if (child
) *child
= reply
->child
;
114 *flags
= reply
->flags
;
116 else size
= reply
->total_size
;
119 HeapFree( GetProcessHeap(), 0, data
);
120 } while (status
== STATUS_BUFFER_OVERFLOW
);
122 if (status
) SetLastError( RtlNtStatusToDosError(status
) );
127 /***********************************************************************
130 * Get only the update flags, not the update region.
132 static BOOL
get_update_flags( HWND hwnd
, HWND
*child
, UINT
*flags
)
136 SERVER_START_REQ( get_update_region
)
139 req
->flags
= *flags
| UPDATE_NOREGION
;
140 if ((ret
= !wine_server_call_err( req
)))
142 if (child
) *child
= reply
->child
;
143 *flags
= reply
->flags
;
151 /***********************************************************************
152 * redraw_window_rects
154 * Redraw part of a window.
156 static BOOL
redraw_window_rects( HWND hwnd
, UINT flags
, const RECT
*rects
, UINT count
)
160 SERVER_START_REQ( redraw_window
)
164 wine_server_add_data( req
, rects
, count
* sizeof(RECT
) );
165 ret
= !wine_server_call_err( req
);
172 /***********************************************************************
175 * Send a WM_NCPAINT message if needed, and return the resulting update region (in screen coords).
176 * Helper for erase_now and BeginPaint.
178 static HRGN
send_ncpaint( HWND hwnd
, HWND
*child
, UINT
*flags
)
180 HRGN whole_rgn
= get_update_region( hwnd
, flags
, child
);
183 if (child
) hwnd
= *child
;
190 /* check if update rgn overlaps with nonclient area */
191 type
= GetRgnBox( whole_rgn
, &update
);
192 GetClientRect( hwnd
, &client
);
193 MapWindowPoints( hwnd
, 0, (POINT
*)&client
, 2 );
195 if ((*flags
& UPDATE_NONCLIENT
) ||
196 update
.left
< client
.left
|| update
.top
< client
.top
||
197 update
.right
> client
.right
|| update
.bottom
> client
.bottom
)
199 client_rgn
= CreateRectRgnIndirect( &client
);
200 CombineRgn( client_rgn
, client_rgn
, whole_rgn
, RGN_AND
);
202 /* check if update rgn contains complete nonclient area */
203 if (type
== SIMPLEREGION
)
206 GetWindowRect( hwnd
, &window
);
207 if (EqualRect( &window
, &update
))
209 DeleteObject( whole_rgn
);
216 client_rgn
= whole_rgn
;
220 if (whole_rgn
) /* NOTE: WM_NCPAINT allows wParam to be 1 */
222 if (*flags
& UPDATE_NONCLIENT
) SendMessageW( hwnd
, WM_NCPAINT
, (WPARAM
)whole_rgn
, 0 );
223 if (whole_rgn
> (HRGN
)1) DeleteObject( whole_rgn
);
230 /***********************************************************************
233 * Send a WM_ERASEBKGND message if needed, and optionally return the DC for painting.
234 * If a DC is requested, the region is selected into it. In all cases the region is deleted.
235 * Helper for erase_now and BeginPaint.
237 static BOOL
send_erase( HWND hwnd
, UINT flags
, HRGN client_rgn
,
238 RECT
*clip_rect
, HDC
*hdc_ret
)
240 BOOL need_erase
= FALSE
;
244 if (!clip_rect
) clip_rect
= &dummy
;
245 if (hdc_ret
|| (flags
& UPDATE_ERASE
))
247 UINT dcx_flags
= DCX_INTERSECTRGN
| DCX_USESTYLE
;
248 if (IsIconic(hwnd
)) dcx_flags
|= DCX_WINDOW
;
250 if ((hdc
= GetDCEx( hwnd
, client_rgn
, dcx_flags
)))
252 INT type
= GetClipBox( hdc
, clip_rect
);
254 if (flags
& UPDATE_ERASE
)
256 /* don't erase if the clip box is empty */
257 if (type
!= NULLREGION
)
258 need_erase
= !SendMessageW( hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0 );
262 if (need_erase
&& hwnd
!= GetDesktopWindow()) /* FIXME: mark it as needing erase again */
263 RedrawWindow( hwnd
, clip_rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_NOCHILDREN
);
264 ReleaseDC( hwnd
, hdc
);
268 if (hdc_ret
) *hdc_ret
= hdc
;
270 if (!hdc
) DeleteObject( client_rgn
);
275 /***********************************************************************
278 * Implementation of RDW_ERASENOW behavior.
280 static void erase_now( HWND hwnd
, UINT rdw_flags
)
285 /* loop while we find a child to repaint */
288 UINT flags
= UPDATE_NONCLIENT
| UPDATE_ERASE
;
290 if (rdw_flags
& RDW_NOCHILDREN
) flags
|= UPDATE_NOCHILDREN
;
291 else if (rdw_flags
& RDW_ALLCHILDREN
) flags
|= UPDATE_ALLCHILDREN
;
293 if (!(hrgn
= send_ncpaint( hwnd
, &child
, &flags
))) break;
294 send_erase( child
, flags
, hrgn
, NULL
, NULL
);
296 if (!flags
) break; /* nothing more to do */
297 if (rdw_flags
& RDW_NOCHILDREN
) break;
302 /***********************************************************************
305 * Implementation of RDW_UPDATENOW behavior.
307 * FIXME: Windows uses WM_SYNCPAINT to cut down the number of intertask
308 * SendMessage() calls. This is a comment inside DefWindowProc() source
311 * This message avoids lots of inter-app message traffic
312 * by switching to the other task and continuing the
316 * LOWORD(lParam) = hrgnClip
317 * HIWORD(lParam) = hwndSkip (not used; always NULL)
320 static void update_now( HWND hwnd
, UINT rdw_flags
)
322 HWND prev
= 0, child
;
324 /* desktop window never gets WM_PAINT, only WM_ERASEBKGND */
325 if (hwnd
== GetDesktopWindow()) erase_now( hwnd
, rdw_flags
| RDW_NOCHILDREN
);
327 /* loop while we find a child to repaint */
330 UINT flags
= UPDATE_PAINT
| UPDATE_INTERNALPAINT
;
332 if (rdw_flags
& RDW_NOCHILDREN
) flags
|= UPDATE_NOCHILDREN
;
333 else if (rdw_flags
& RDW_ALLCHILDREN
) flags
|= UPDATE_ALLCHILDREN
;
335 if (!get_update_flags( hwnd
, &child
, &flags
)) break;
336 if (!flags
) break; /* nothing more to do */
338 if (child
== prev
) /* same window again, didn't get repainted properly */
340 UINT erase_flags
= UPDATE_NONCLIENT
| UPDATE_ERASE
| UPDATE_NOCHILDREN
;
343 TRACE( "%p not repainted properly, erasing\n", child
);
344 if ((hrgn
= send_ncpaint( child
, NULL
, &erase_flags
)))
345 send_erase( child
, erase_flags
, hrgn
, NULL
, NULL
);
352 SendMessageW( child
, WM_PAINT
, 0, 0 );
354 if (rdw_flags
& RDW_NOCHILDREN
) break;
359 /*************************************************************************
362 * Helper for ScrollWindowEx.
364 static HWND
fix_caret(HWND hWnd
, LPRECT lprc
, UINT flags
)
368 if (!GetGUIThreadInfo( GetCurrentThreadId(), &info
)) return 0;
369 if (!info
.hwndCaret
) return 0;
370 if (info
.hwndCaret
== hWnd
||
371 ((flags
& SW_SCROLLCHILDREN
) && IsChild(hWnd
, info
.hwndCaret
)))
374 pt
.x
= info
.rcCaret
.left
;
375 pt
.y
= info
.rcCaret
.top
;
376 MapWindowPoints( info
.hwndCaret
, hWnd
, (LPPOINT
)&info
.rcCaret
, 2 );
377 if( IntersectRect(lprc
, lprc
, &info
.rcCaret
) )
382 return info
.hwndCaret
;
389 /***********************************************************************
390 * BeginPaint (USER32.@)
392 HDC WINAPI
BeginPaint( HWND hwnd
, PAINTSTRUCT
*lps
)
396 UINT flags
= UPDATE_NONCLIENT
| UPDATE_ERASE
| UPDATE_PAINT
| UPDATE_INTERNALPAINT
| UPDATE_NOCHILDREN
;
400 if (!(full_handle
= WIN_IsCurrentThread( hwnd
)))
403 FIXME( "window %p belongs to other thread\n", hwnd
);
410 if (!(hrgn
= send_ncpaint( hwnd
, NULL
, &flags
))) return 0;
412 lps
->fErase
= send_erase( hwnd
, flags
, hrgn
, &lps
->rcPaint
, &lps
->hdc
);
414 TRACE("hdc = %p box = (%ld,%ld - %ld,%ld), fErase = %d\n",
415 lps
->hdc
, lps
->rcPaint
.left
, lps
->rcPaint
.top
, lps
->rcPaint
.right
, lps
->rcPaint
.bottom
,
422 /***********************************************************************
423 * EndPaint (USER32.@)
425 BOOL WINAPI
EndPaint( HWND hwnd
, const PAINTSTRUCT
*lps
)
427 if (!lps
) return FALSE
;
428 if (USER_Driver
.pReleaseDC
) USER_Driver
.pReleaseDC( hwnd
, lps
->hdc
, TRUE
);
434 /***********************************************************************
437 HDC WINAPI
GetDCEx( HWND hwnd
, HRGN hrgnClip
, DWORD flags
)
439 if (!hwnd
) hwnd
= GetDesktopWindow();
440 else hwnd
= WIN_GetFullHandle( hwnd
);
442 if (USER_Driver
.pGetDCEx
) return USER_Driver
.pGetDCEx( hwnd
, hrgnClip
, flags
);
447 /***********************************************************************
450 * Get a device context.
453 * Success: Handle to the device context
456 HDC WINAPI
GetDC( HWND hwnd
)
458 if (!hwnd
) return GetDCEx( 0, 0, DCX_CACHE
| DCX_WINDOW
);
459 return GetDCEx( hwnd
, 0, DCX_USESTYLE
);
463 /***********************************************************************
464 * GetWindowDC (USER32.@)
466 HDC WINAPI
GetWindowDC( HWND hwnd
)
468 return GetDCEx( hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
);
472 /***********************************************************************
473 * ReleaseDC (USER32.@)
475 * Release a device context.
478 * Success: Non-zero. Resources used by hdc are released.
481 INT WINAPI
ReleaseDC( HWND hwnd
, HDC hdc
)
483 if (USER_Driver
.pReleaseDC
) return USER_Driver
.pReleaseDC( hwnd
, hdc
, FALSE
);
488 /**********************************************************************
489 * WindowFromDC (USER32.@)
491 HWND WINAPI
WindowFromDC( HDC hDC
)
493 if (USER_Driver
.pWindowFromDC
) return USER_Driver
.pWindowFromDC( hDC
);
498 /***********************************************************************
499 * LockWindowUpdate (USER32.@)
501 BOOL WINAPI
LockWindowUpdate( HWND hwnd
)
503 static HWND lockedWnd
;
505 /* This function is fully implemented by the following patch:
507 * http://www.winehq.org/hypermail/wine-patches/2004/01/0142.html
509 * but in order to work properly, it needs the ability to invalidate
510 * DCEs in other processes when the lock window is changed, which
511 * isn't possible yet.
515 FIXME("(%p), partial stub!\n",hwnd
);
522 /* Unlock lockedWnd */
523 /* FIXME: Do something */
527 /* Attempted to lock a second window */
528 /* Return FALSE and do nothing */
539 /***********************************************************************
540 * RedrawWindow (USER32.@)
542 BOOL WINAPI
RedrawWindow( HWND hwnd
, const RECT
*rect
, HRGN hrgn
, UINT flags
)
546 if (!hwnd
) hwnd
= GetDesktopWindow();
553 GetRgnBox( hrgn
, &r
);
554 TRACE( "%p region %p box %s ", hwnd
, hrgn
, wine_dbgstr_rect(&r
) );
557 TRACE( "%p rect %s ", hwnd
, wine_dbgstr_rect(rect
) );
559 TRACE( "%p whole window ", hwnd
);
561 dump_rdw_flags(flags
);
564 /* process pending expose events before painting */
565 if (flags
& RDW_UPDATENOW
) MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 0, QS_PAINT
);
569 ret
= redraw_window_rects( hwnd
, flags
, rect
, 1 );
573 ret
= redraw_window_rects( hwnd
, flags
, NULL
, 0 );
575 else /* need to build a list of the region rectangles */
578 RGNDATA
*data
= NULL
;
579 static const RECT empty
;
581 if (!(size
= GetRegionData( hrgn
, 0, NULL
))) return FALSE
;
582 if (!(data
= HeapAlloc( GetProcessHeap(), 0, size
))) return FALSE
;
583 GetRegionData( hrgn
, size
, data
);
584 if (!data
->rdh
.nCount
) /* empty region -> use a single all-zero rectangle */
585 ret
= redraw_window_rects( hwnd
, flags
, &empty
, 1 );
587 ret
= redraw_window_rects( hwnd
, flags
, (const RECT
*)data
->Buffer
, data
->rdh
.nCount
);
588 HeapFree( GetProcessHeap(), 0, data
);
591 if (flags
& RDW_UPDATENOW
) update_now( hwnd
, flags
);
592 else if (flags
& RDW_ERASENOW
) erase_now( hwnd
, flags
);
598 /***********************************************************************
599 * UpdateWindow (USER32.@)
601 BOOL WINAPI
UpdateWindow( HWND hwnd
)
603 return RedrawWindow( hwnd
, NULL
, 0, RDW_UPDATENOW
| RDW_ALLCHILDREN
);
607 /***********************************************************************
608 * InvalidateRgn (USER32.@)
610 BOOL WINAPI
InvalidateRgn( HWND hwnd
, HRGN hrgn
, BOOL erase
)
612 return RedrawWindow(hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| (erase
? RDW_ERASE
: 0) );
616 /***********************************************************************
617 * InvalidateRect (USER32.@)
619 BOOL WINAPI
InvalidateRect( HWND hwnd
, const RECT
*rect
, BOOL erase
)
621 return RedrawWindow( hwnd
, rect
, 0, RDW_INVALIDATE
| (erase
? RDW_ERASE
: 0) );
625 /***********************************************************************
626 * ValidateRgn (USER32.@)
628 BOOL WINAPI
ValidateRgn( HWND hwnd
, HRGN hrgn
)
630 return RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
);
634 /***********************************************************************
635 * ValidateRect (USER32.@)
637 BOOL WINAPI
ValidateRect( HWND hwnd
, const RECT
*rect
)
639 return RedrawWindow( hwnd
, rect
, 0, RDW_VALIDATE
);
643 /***********************************************************************
644 * GetUpdateRgn (USER32.@)
646 INT WINAPI
GetUpdateRgn( HWND hwnd
, HRGN hrgn
, BOOL erase
)
649 UINT flags
= UPDATE_NOCHILDREN
;
652 if (erase
) flags
|= UPDATE_NONCLIENT
| UPDATE_ERASE
;
654 if ((update_rgn
= send_ncpaint( hwnd
, NULL
, &flags
)))
658 retval
= CombineRgn( hrgn
, update_rgn
, 0, RGN_COPY
);
659 send_erase( hwnd
, flags
, update_rgn
, NULL
, NULL
);
660 /* map region to client coordinates */
661 offset
.x
= offset
.y
= 0;
662 ScreenToClient( hwnd
, &offset
);
663 OffsetRgn( hrgn
, offset
.x
, offset
.y
);
669 /***********************************************************************
670 * GetUpdateRect (USER32.@)
672 BOOL WINAPI
GetUpdateRect( HWND hwnd
, LPRECT rect
, BOOL erase
)
674 UINT flags
= UPDATE_NOCHILDREN
;
677 if (erase
) flags
|= UPDATE_NONCLIENT
| UPDATE_ERASE
;
679 if (!(update_rgn
= send_ncpaint( hwnd
, NULL
, &flags
))) return FALSE
;
683 if (GetRgnBox( update_rgn
, rect
) != NULLREGION
)
685 HDC hdc
= GetDCEx( hwnd
, 0, DCX_USESTYLE
);
686 MapWindowPoints( 0, hwnd
, (LPPOINT
)rect
, 2 );
687 DPtoLP( hdc
, (LPPOINT
)rect
, 2 );
688 ReleaseDC( hwnd
, hdc
);
691 send_erase( hwnd
, flags
, update_rgn
, NULL
, NULL
);
693 /* check if we still have an update region */
694 flags
= UPDATE_PAINT
| UPDATE_NOCHILDREN
;
695 return (get_update_flags( hwnd
, NULL
, &flags
) && (flags
& UPDATE_PAINT
));
699 /***********************************************************************
700 * ExcludeUpdateRgn (USER32.@)
702 INT WINAPI
ExcludeUpdateRgn( HDC hdc
, HWND hwnd
)
704 HRGN update_rgn
= CreateRectRgn( 0, 0, 0, 0 );
705 INT ret
= GetUpdateRgn( hwnd
, update_rgn
, FALSE
);
711 GetDCOrgEx( hdc
, &pt
);
712 MapWindowPoints( 0, hwnd
, &pt
, 1 );
713 OffsetRgn( update_rgn
, -pt
.x
, -pt
.y
);
714 ret
= ExtSelectClipRgn( hdc
, update_rgn
, RGN_DIFF
);
715 DeleteObject( update_rgn
);
721 /*************************************************************************
722 * ScrollWindowEx (USER32.@)
724 * Note: contrary to what the doc says, pixels that are scrolled from the
725 * outside of clipRect to the inside are NOT painted.
728 INT WINAPI
ScrollWindowEx( HWND hwnd
, INT dx
, INT dy
,
729 const RECT
*rect
, const RECT
*clipRect
,
730 HRGN hrgnUpdate
, LPRECT rcUpdate
,
733 INT retVal
= NULLREGION
;
735 BOOL bUpdate
= (rcUpdate
|| hrgnUpdate
|| flags
& (SW_INVALIDATE
| SW_ERASE
));
742 HWND hwndCaret
= NULL
;
744 TRACE( "%p, %d,%d hrgnUpdate=%p rcUpdate = %p %s %04x\n",
745 hwnd
, dx
, dy
, hrgnUpdate
, rcUpdate
, wine_dbgstr_rect(rect
), flags
);
746 TRACE( "clipRect = %s\n", wine_dbgstr_rect(clipRect
));
747 if( flags
& ~( SW_SCROLLCHILDREN
| SW_INVALIDATE
| SW_ERASE
))
748 FIXME("some flags (%04x) are unhandled\n", flags
);
750 rdw_flags
= (flags
& SW_ERASE
) && (flags
& SW_INVALIDATE
) ?
751 RDW_INVALIDATE
| RDW_ERASE
: RDW_INVALIDATE
;
753 if (!WIN_IsWindowDrawable( hwnd
, TRUE
)) return ERROR
;
754 hwnd
= WIN_GetFullHandle( hwnd
);
756 GetClientRect(hwnd
, &rc
);
757 if (rect
) IntersectRect(&rc
, &rc
, rect
);
759 if (clipRect
) IntersectRect(&cliprc
,&rc
,clipRect
);
762 if( hrgnUpdate
) bOwnRgn
= FALSE
;
763 else if( bUpdate
) hrgnUpdate
= CreateRectRgn( 0, 0, 0, 0 );
765 if( !IsRectEmpty(&cliprc
) && (dx
|| dy
)) {
766 DWORD dcxflags
= DCX_CACHE
;
767 DWORD style
= GetWindowLongW( hwnd
, GWL_STYLE
);
769 hwndCaret
= fix_caret(hwnd
, &caretrc
, flags
);
771 if( style
& WS_CLIPSIBLINGS
) dcxflags
|= DCX_CLIPSIBLINGS
;
772 if( GetClassLongW( hwnd
, GCL_STYLE
) & CS_PARENTDC
)
773 dcxflags
|= DCX_PARENTCLIP
;
774 if( !(flags
& SW_SCROLLCHILDREN
) && (style
& WS_CLIPCHILDREN
))
775 dcxflags
|= DCX_CLIPCHILDREN
;
776 hDC
= GetDCEx( hwnd
, 0, dcxflags
);
779 ScrollDC( hDC
, dx
, dy
, &rc
, &cliprc
, hrgnUpdate
, rcUpdate
);
781 ReleaseDC( hwnd
, hDC
);
784 RedrawWindow( hwnd
, NULL
, hrgnUpdate
, rdw_flags
);
787 /* If the windows has an update region, this must be
788 * scrolled as well. Keep a copy in hrgnWinupd
789 * to be added to hrngUpdate at the end. */
790 hrgnTemp
= CreateRectRgn( 0, 0, 0, 0 );
791 retVal
= GetUpdateRgn( hwnd
, hrgnTemp
, FALSE
);
792 if (retVal
!= NULLREGION
)
794 HRGN hrgnClip
= CreateRectRgnIndirect(&cliprc
);
796 hrgnWinupd
= CreateRectRgn( 0, 0, 0, 0);
797 CombineRgn( hrgnWinupd
, hrgnTemp
, 0, RGN_COPY
);
799 OffsetRgn( hrgnTemp
, dx
, dy
);
800 CombineRgn( hrgnTemp
, hrgnTemp
, hrgnClip
, RGN_AND
);
802 CombineRgn( hrgnWinupd
, hrgnWinupd
, hrgnTemp
, RGN_OR
);
803 RedrawWindow( hwnd
, NULL
, hrgnTemp
, rdw_flags
);
804 DeleteObject( hrgnClip
);
806 DeleteObject( hrgnTemp
);
808 /* nothing was scrolled */
810 SetRectRgn( hrgnUpdate
, 0, 0, 0, 0 );
811 SetRectEmpty( rcUpdate
);
814 if( flags
& SW_SCROLLCHILDREN
)
816 HWND
*list
= WIN_ListChildren( hwnd
);
821 for (i
= 0; list
[i
]; i
++)
823 GetWindowRect( list
[i
], &r
);
824 MapWindowPoints( 0, hwnd
, (POINT
*)&r
, 2 );
825 if (!rect
|| IntersectRect(&dummy
, &r
, rect
))
826 SetWindowPos( list
[i
], 0, r
.left
+ dx
, r
.top
+ dy
, 0, 0,
827 SWP_NOZORDER
| SWP_NOSIZE
| SWP_NOACTIVATE
|
828 SWP_NOREDRAW
| SWP_DEFERERASE
);
830 HeapFree( GetProcessHeap(), 0, list
);
834 if( flags
& (SW_INVALIDATE
| SW_ERASE
) )
835 RedrawWindow( hwnd
, NULL
, hrgnUpdate
, rdw_flags
|
836 ((flags
& SW_SCROLLCHILDREN
) ? RDW_ALLCHILDREN
: 0 ) );
839 CombineRgn( hrgnUpdate
, hrgnUpdate
, hrgnWinupd
, RGN_OR
);
840 DeleteObject( hrgnWinupd
);
844 SetCaretPos( caretrc
.left
+ dx
, caretrc
.top
+ dy
);
845 ShowCaret(hwndCaret
);
848 if( bOwnRgn
&& hrgnUpdate
) DeleteObject( hrgnUpdate
);
854 /*************************************************************************
855 * ScrollWindow (USER32.@)
858 BOOL WINAPI
ScrollWindow( HWND hwnd
, INT dx
, INT dy
,
859 const RECT
*rect
, const RECT
*clipRect
)
861 return (ERROR
!= ScrollWindowEx( hwnd
, dx
, dy
, rect
, clipRect
, 0, NULL
,
862 (rect
? 0 : SW_SCROLLCHILDREN
) |
863 SW_INVALIDATE
| SW_ERASE
));
867 /*************************************************************************
868 * ScrollDC (USER32.@)
870 * dx, dy, lprcScroll and lprcClip are all in logical coordinates (msdn is
871 * wrong) hrgnUpdate is returned in device coordinates with rcUpdate in
872 * logical coordinates.
874 BOOL WINAPI
ScrollDC( HDC hdc
, INT dx
, INT dy
, const RECT
*lprcScroll
,
875 const RECT
*lprcClip
, HRGN hrgnUpdate
, LPRECT lprcUpdate
)
878 if (USER_Driver
.pScrollDC
)
879 return USER_Driver
.pScrollDC( hdc
, dx
, dy
, lprcScroll
, lprcClip
, hrgnUpdate
, lprcUpdate
);