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
)
103 req
->from_child
= child
? *child
: 0;
105 wine_server_set_reply( req
, data
->Buffer
, size
);
106 if (!(status
= wine_server_call( req
)))
108 size_t reply_size
= wine_server_reply_size( reply
);
109 data
->rdh
.dwSize
= sizeof(data
->rdh
);
110 data
->rdh
.iType
= RDH_RECTANGLES
;
111 data
->rdh
.nCount
= reply_size
/ sizeof(RECT
);
112 data
->rdh
.nRgnSize
= reply_size
;
113 hrgn
= ExtCreateRegion( NULL
, size
, data
);
114 if (child
) *child
= reply
->child
;
115 *flags
= reply
->flags
;
117 else size
= reply
->total_size
;
120 HeapFree( GetProcessHeap(), 0, data
);
121 } while (status
== STATUS_BUFFER_OVERFLOW
);
123 if (status
) SetLastError( RtlNtStatusToDosError(status
) );
128 /***********************************************************************
131 * Get only the update flags, not the update region.
133 static BOOL
get_update_flags( HWND hwnd
, HWND
*child
, UINT
*flags
)
137 SERVER_START_REQ( get_update_region
)
140 req
->from_child
= child
? *child
: 0;
141 req
->flags
= *flags
| UPDATE_NOREGION
;
142 if ((ret
= !wine_server_call_err( req
)))
144 if (child
) *child
= reply
->child
;
145 *flags
= reply
->flags
;
153 /***********************************************************************
154 * redraw_window_rects
156 * Redraw part of a window.
158 static BOOL
redraw_window_rects( HWND hwnd
, UINT flags
, const RECT
*rects
, UINT count
)
162 SERVER_START_REQ( redraw_window
)
166 wine_server_add_data( req
, rects
, count
* sizeof(RECT
) );
167 ret
= !wine_server_call_err( req
);
174 /***********************************************************************
177 * Send a WM_NCPAINT message if needed, and return the resulting update region (in screen coords).
178 * Helper for erase_now and BeginPaint.
180 static HRGN
send_ncpaint( HWND hwnd
, HWND
*child
, UINT
*flags
)
182 HRGN whole_rgn
= get_update_region( hwnd
, flags
, child
);
185 if (child
) hwnd
= *child
;
192 /* check if update rgn overlaps with nonclient area */
193 type
= GetRgnBox( whole_rgn
, &update
);
194 GetClientRect( hwnd
, &client
);
195 MapWindowPoints( hwnd
, 0, (POINT
*)&client
, 2 );
197 if ((*flags
& UPDATE_NONCLIENT
) ||
198 update
.left
< client
.left
|| update
.top
< client
.top
||
199 update
.right
> client
.right
|| update
.bottom
> client
.bottom
)
201 client_rgn
= CreateRectRgnIndirect( &client
);
202 CombineRgn( client_rgn
, client_rgn
, whole_rgn
, RGN_AND
);
204 /* check if update rgn contains complete nonclient area */
205 if (type
== SIMPLEREGION
)
208 GetWindowRect( hwnd
, &window
);
209 if (EqualRect( &window
, &update
))
211 DeleteObject( whole_rgn
);
218 client_rgn
= whole_rgn
;
222 if (whole_rgn
) /* NOTE: WM_NCPAINT allows wParam to be 1 */
224 if (*flags
& UPDATE_NONCLIENT
) SendMessageW( hwnd
, WM_NCPAINT
, (WPARAM
)whole_rgn
, 0 );
225 if (whole_rgn
> (HRGN
)1) DeleteObject( whole_rgn
);
232 /***********************************************************************
235 * Send a WM_ERASEBKGND message if needed, and optionally return the DC for painting.
236 * If a DC is requested, the region is selected into it. In all cases the region is deleted.
237 * Helper for erase_now and BeginPaint.
239 static BOOL
send_erase( HWND hwnd
, UINT flags
, HRGN client_rgn
,
240 RECT
*clip_rect
, HDC
*hdc_ret
)
242 BOOL need_erase
= FALSE
;
246 if (!clip_rect
) clip_rect
= &dummy
;
247 if (hdc_ret
|| (flags
& UPDATE_ERASE
))
249 UINT dcx_flags
= DCX_INTERSECTRGN
| DCX_USESTYLE
;
250 if (IsIconic(hwnd
)) dcx_flags
|= DCX_WINDOW
;
252 if ((hdc
= GetDCEx( hwnd
, client_rgn
, dcx_flags
)))
254 INT type
= GetClipBox( hdc
, clip_rect
);
256 if (flags
& UPDATE_ERASE
)
258 /* don't erase if the clip box is empty */
259 if (type
!= NULLREGION
)
260 need_erase
= !SendMessageW( hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0 );
264 if (need_erase
&& hwnd
!= GetDesktopWindow()) /* FIXME: mark it as needing erase again */
265 RedrawWindow( hwnd
, clip_rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_NOCHILDREN
);
266 USER_Driver
->pReleaseDC( hwnd
, hdc
, TRUE
);
270 if (hdc_ret
) *hdc_ret
= hdc
;
272 if (!hdc
) DeleteObject( client_rgn
);
277 /***********************************************************************
280 * Implementation of RDW_ERASENOW behavior.
282 static void erase_now( HWND hwnd
, UINT rdw_flags
)
287 /* loop while we find a child to repaint */
290 UINT flags
= UPDATE_NONCLIENT
| UPDATE_ERASE
;
292 if (rdw_flags
& RDW_NOCHILDREN
) flags
|= UPDATE_NOCHILDREN
;
293 else if (rdw_flags
& RDW_ALLCHILDREN
) flags
|= UPDATE_ALLCHILDREN
;
295 if (!(hrgn
= send_ncpaint( hwnd
, &child
, &flags
))) break;
296 send_erase( child
, flags
, hrgn
, NULL
, NULL
);
298 if (!flags
) break; /* nothing more to do */
299 if (rdw_flags
& RDW_NOCHILDREN
) break;
304 /***********************************************************************
307 * Implementation of RDW_UPDATENOW behavior.
309 * FIXME: Windows uses WM_SYNCPAINT to cut down the number of intertask
310 * SendMessage() calls. This is a comment inside DefWindowProc() source
313 * This message avoids lots of inter-app message traffic
314 * by switching to the other task and continuing the
318 * LOWORD(lParam) = hrgnClip
319 * HIWORD(lParam) = hwndSkip (not used; always NULL)
322 static void update_now( HWND hwnd
, UINT rdw_flags
)
326 /* desktop window never gets WM_PAINT, only WM_ERASEBKGND */
327 if (hwnd
== GetDesktopWindow()) erase_now( hwnd
, rdw_flags
| RDW_NOCHILDREN
);
329 /* loop while we find a child to repaint */
332 UINT flags
= UPDATE_PAINT
| UPDATE_INTERNALPAINT
;
334 if (rdw_flags
& RDW_NOCHILDREN
) flags
|= UPDATE_NOCHILDREN
;
335 else if (rdw_flags
& RDW_ALLCHILDREN
) flags
|= UPDATE_ALLCHILDREN
;
337 if (!get_update_flags( hwnd
, &child
, &flags
)) break;
338 if (!flags
) break; /* nothing more to do */
340 SendMessageW( child
, WM_PAINT
, 0, 0 );
341 if (rdw_flags
& RDW_NOCHILDREN
) break;
346 /*************************************************************************
349 * Helper for ScrollWindowEx.
351 static HWND
fix_caret(HWND hWnd
, LPRECT lprc
, UINT flags
)
355 if (!GetGUIThreadInfo( GetCurrentThreadId(), &info
)) return 0;
356 if (!info
.hwndCaret
) return 0;
357 if (info
.hwndCaret
== hWnd
||
358 ((flags
& SW_SCROLLCHILDREN
) && IsChild(hWnd
, info
.hwndCaret
)))
361 pt
.x
= info
.rcCaret
.left
;
362 pt
.y
= info
.rcCaret
.top
;
363 MapWindowPoints( info
.hwndCaret
, hWnd
, (LPPOINT
)&info
.rcCaret
, 2 );
364 if( IntersectRect(lprc
, lprc
, &info
.rcCaret
) )
369 return info
.hwndCaret
;
376 /***********************************************************************
377 * BeginPaint (USER32.@)
379 HDC WINAPI
BeginPaint( HWND hwnd
, PAINTSTRUCT
*lps
)
383 UINT flags
= UPDATE_NONCLIENT
| UPDATE_ERASE
| UPDATE_PAINT
| UPDATE_INTERNALPAINT
| UPDATE_NOCHILDREN
;
387 if (!(full_handle
= WIN_IsCurrentThread( hwnd
)))
390 FIXME( "window %p belongs to other thread\n", hwnd
);
397 if (!(hrgn
= send_ncpaint( hwnd
, NULL
, &flags
))) return 0;
399 lps
->fErase
= send_erase( hwnd
, flags
, hrgn
, &lps
->rcPaint
, &lps
->hdc
);
401 TRACE("hdc = %p box = (%ld,%ld - %ld,%ld), fErase = %d\n",
402 lps
->hdc
, lps
->rcPaint
.left
, lps
->rcPaint
.top
, lps
->rcPaint
.right
, lps
->rcPaint
.bottom
,
409 /***********************************************************************
410 * EndPaint (USER32.@)
412 BOOL WINAPI
EndPaint( HWND hwnd
, const PAINTSTRUCT
*lps
)
414 if (!lps
) return FALSE
;
415 USER_Driver
->pReleaseDC( hwnd
, lps
->hdc
, TRUE
);
421 /***********************************************************************
424 HDC WINAPI
GetDCEx( HWND hwnd
, HRGN hrgnClip
, DWORD flags
)
426 if (!hwnd
) hwnd
= GetDesktopWindow();
427 else hwnd
= WIN_GetFullHandle( hwnd
);
429 return USER_Driver
->pGetDCEx( hwnd
, hrgnClip
, flags
);
433 /***********************************************************************
436 * Get a device context.
439 * Success: Handle to the device context
442 HDC WINAPI
GetDC( HWND hwnd
)
444 if (!hwnd
) return GetDCEx( 0, 0, DCX_CACHE
| DCX_WINDOW
);
445 return GetDCEx( hwnd
, 0, DCX_USESTYLE
);
449 /***********************************************************************
450 * GetWindowDC (USER32.@)
452 HDC WINAPI
GetWindowDC( HWND hwnd
)
454 return GetDCEx( hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
);
458 /***********************************************************************
459 * ReleaseDC (USER32.@)
461 * Release a device context.
464 * Success: Non-zero. Resources used by hdc are released.
467 INT WINAPI
ReleaseDC( HWND hwnd
, HDC hdc
)
469 return USER_Driver
->pReleaseDC( hwnd
, hdc
, FALSE
);
473 /**********************************************************************
474 * WindowFromDC (USER32.@)
476 HWND WINAPI
WindowFromDC( HDC hDC
)
478 return USER_Driver
->pWindowFromDC( hDC
);
482 /***********************************************************************
483 * LockWindowUpdate (USER32.@)
485 BOOL WINAPI
LockWindowUpdate( HWND hwnd
)
487 static HWND lockedWnd
;
489 /* This function is fully implemented by the following patch:
491 * http://www.winehq.org/hypermail/wine-patches/2004/01/0142.html
493 * but in order to work properly, it needs the ability to invalidate
494 * DCEs in other processes when the lock window is changed, which
495 * isn't possible yet.
499 FIXME("(%p), partial stub!\n",hwnd
);
506 /* Unlock lockedWnd */
507 /* FIXME: Do something */
511 /* Attempted to lock a second window */
512 /* Return FALSE and do nothing */
523 /***********************************************************************
524 * RedrawWindow (USER32.@)
526 BOOL WINAPI
RedrawWindow( HWND hwnd
, const RECT
*rect
, HRGN hrgn
, UINT flags
)
530 if (!hwnd
) hwnd
= GetDesktopWindow();
537 GetRgnBox( hrgn
, &r
);
538 TRACE( "%p region %p box %s ", hwnd
, hrgn
, wine_dbgstr_rect(&r
) );
541 TRACE( "%p rect %s ", hwnd
, wine_dbgstr_rect(rect
) );
543 TRACE( "%p whole window ", hwnd
);
545 dump_rdw_flags(flags
);
548 /* process pending expose events before painting */
549 if (flags
& RDW_UPDATENOW
) USER_Driver
->pMsgWaitForMultipleObjectsEx( 0, NULL
, 0, QS_PAINT
, 0 );
553 ret
= redraw_window_rects( hwnd
, flags
, rect
, 1 );
557 ret
= redraw_window_rects( hwnd
, flags
, NULL
, 0 );
559 else /* need to build a list of the region rectangles */
562 RGNDATA
*data
= NULL
;
563 static const RECT empty
;
565 if (!(size
= GetRegionData( hrgn
, 0, NULL
))) return FALSE
;
566 if (!(data
= HeapAlloc( GetProcessHeap(), 0, size
))) return FALSE
;
567 GetRegionData( hrgn
, size
, data
);
568 if (!data
->rdh
.nCount
) /* empty region -> use a single all-zero rectangle */
569 ret
= redraw_window_rects( hwnd
, flags
, &empty
, 1 );
571 ret
= redraw_window_rects( hwnd
, flags
, (const RECT
*)data
->Buffer
, data
->rdh
.nCount
);
572 HeapFree( GetProcessHeap(), 0, data
);
575 if (flags
& RDW_UPDATENOW
) update_now( hwnd
, flags
);
576 else if (flags
& RDW_ERASENOW
) erase_now( hwnd
, flags
);
582 /***********************************************************************
583 * UpdateWindow (USER32.@)
585 BOOL WINAPI
UpdateWindow( HWND hwnd
)
587 return RedrawWindow( hwnd
, NULL
, 0, RDW_UPDATENOW
| RDW_ALLCHILDREN
);
591 /***********************************************************************
592 * InvalidateRgn (USER32.@)
594 BOOL WINAPI
InvalidateRgn( HWND hwnd
, HRGN hrgn
, BOOL erase
)
596 return RedrawWindow(hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| (erase
? RDW_ERASE
: 0) );
600 /***********************************************************************
601 * InvalidateRect (USER32.@)
603 BOOL WINAPI
InvalidateRect( HWND hwnd
, const RECT
*rect
, BOOL erase
)
605 return RedrawWindow( hwnd
, rect
, 0, RDW_INVALIDATE
| (erase
? RDW_ERASE
: 0) );
609 /***********************************************************************
610 * ValidateRgn (USER32.@)
612 BOOL WINAPI
ValidateRgn( HWND hwnd
, HRGN hrgn
)
614 return RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
);
618 /***********************************************************************
619 * ValidateRect (USER32.@)
621 BOOL WINAPI
ValidateRect( HWND hwnd
, const RECT
*rect
)
623 return RedrawWindow( hwnd
, rect
, 0, RDW_VALIDATE
);
627 /***********************************************************************
628 * GetUpdateRgn (USER32.@)
630 INT WINAPI
GetUpdateRgn( HWND hwnd
, HRGN hrgn
, BOOL erase
)
633 UINT flags
= UPDATE_NOCHILDREN
;
636 if (erase
) flags
|= UPDATE_NONCLIENT
| UPDATE_ERASE
;
638 if ((update_rgn
= send_ncpaint( hwnd
, NULL
, &flags
)))
642 retval
= CombineRgn( hrgn
, update_rgn
, 0, RGN_COPY
);
643 send_erase( hwnd
, flags
, update_rgn
, NULL
, NULL
);
644 /* map region to client coordinates */
645 offset
.x
= offset
.y
= 0;
646 ScreenToClient( hwnd
, &offset
);
647 OffsetRgn( hrgn
, offset
.x
, offset
.y
);
653 /***********************************************************************
654 * GetUpdateRect (USER32.@)
656 BOOL WINAPI
GetUpdateRect( HWND hwnd
, LPRECT rect
, BOOL erase
)
658 UINT flags
= UPDATE_NOCHILDREN
;
661 if (erase
) flags
|= UPDATE_NONCLIENT
| UPDATE_ERASE
;
663 if (!(update_rgn
= send_ncpaint( hwnd
, NULL
, &flags
))) return FALSE
;
667 if (GetRgnBox( update_rgn
, rect
) != NULLREGION
)
669 HDC hdc
= GetDCEx( hwnd
, 0, DCX_USESTYLE
);
670 MapWindowPoints( 0, hwnd
, (LPPOINT
)rect
, 2 );
671 DPtoLP( hdc
, (LPPOINT
)rect
, 2 );
672 ReleaseDC( hwnd
, hdc
);
675 send_erase( hwnd
, flags
, update_rgn
, NULL
, NULL
);
677 /* check if we still have an update region */
678 flags
= UPDATE_PAINT
| UPDATE_NOCHILDREN
;
679 return (get_update_flags( hwnd
, NULL
, &flags
) && (flags
& UPDATE_PAINT
));
683 /***********************************************************************
684 * ExcludeUpdateRgn (USER32.@)
686 INT WINAPI
ExcludeUpdateRgn( HDC hdc
, HWND hwnd
)
688 HRGN update_rgn
= CreateRectRgn( 0, 0, 0, 0 );
689 INT ret
= GetUpdateRgn( hwnd
, update_rgn
, FALSE
);
695 GetDCOrgEx( hdc
, &pt
);
696 MapWindowPoints( 0, hwnd
, &pt
, 1 );
697 OffsetRgn( update_rgn
, -pt
.x
, -pt
.y
);
698 ret
= ExtSelectClipRgn( hdc
, update_rgn
, RGN_DIFF
);
699 DeleteObject( update_rgn
);
705 /*************************************************************************
706 * ScrollWindowEx (USER32.@)
708 * Note: contrary to what the doc says, pixels that are scrolled from the
709 * outside of clipRect to the inside are NOT painted.
712 INT WINAPI
ScrollWindowEx( HWND hwnd
, INT dx
, INT dy
,
713 const RECT
*rect
, const RECT
*clipRect
,
714 HRGN hrgnUpdate
, LPRECT rcUpdate
,
717 INT retVal
= NULLREGION
;
719 BOOL bUpdate
= (rcUpdate
|| hrgnUpdate
|| flags
& (SW_INVALIDATE
| SW_ERASE
));
726 HWND hwndCaret
= NULL
;
728 TRACE( "%p, %d,%d hrgnUpdate=%p rcUpdate = %p %s %04x\n",
729 hwnd
, dx
, dy
, hrgnUpdate
, rcUpdate
, wine_dbgstr_rect(rect
), flags
);
730 TRACE( "clipRect = %s\n", wine_dbgstr_rect(clipRect
));
731 if( flags
& ~( SW_SCROLLCHILDREN
| SW_INVALIDATE
| SW_ERASE
))
732 FIXME("some flags (%04x) are unhandled\n", flags
);
734 rdw_flags
= (flags
& SW_ERASE
) && (flags
& SW_INVALIDATE
) ?
735 RDW_INVALIDATE
| RDW_ERASE
: RDW_INVALIDATE
;
737 if (!WIN_IsWindowDrawable( hwnd
, TRUE
)) return ERROR
;
738 hwnd
= WIN_GetFullHandle( hwnd
);
740 GetClientRect(hwnd
, &rc
);
741 if (rect
) IntersectRect(&rc
, &rc
, rect
);
743 if (clipRect
) IntersectRect(&cliprc
,&rc
,clipRect
);
746 if( hrgnUpdate
) bOwnRgn
= FALSE
;
747 else if( bUpdate
) hrgnUpdate
= CreateRectRgn( 0, 0, 0, 0 );
749 if( !IsRectEmpty(&cliprc
) && (dx
|| dy
)) {
750 DWORD dcxflags
= DCX_CACHE
;
751 DWORD style
= GetWindowLongW( hwnd
, GWL_STYLE
);
753 hwndCaret
= fix_caret(hwnd
, &caretrc
, flags
);
755 if( style
& WS_CLIPSIBLINGS
) dcxflags
|= DCX_CLIPSIBLINGS
;
756 if( GetClassLongW( hwnd
, GCL_STYLE
) & CS_PARENTDC
)
757 dcxflags
|= DCX_PARENTCLIP
;
758 if( !(flags
& SW_SCROLLCHILDREN
) && (style
& WS_CLIPCHILDREN
))
759 dcxflags
|= DCX_CLIPCHILDREN
;
760 hDC
= GetDCEx( hwnd
, 0, dcxflags
);
763 ScrollDC( hDC
, dx
, dy
, &rc
, &cliprc
, hrgnUpdate
, rcUpdate
);
765 ReleaseDC( hwnd
, hDC
);
768 RedrawWindow( hwnd
, NULL
, hrgnUpdate
, rdw_flags
);
771 /* If the windows has an update region, this must be
772 * scrolled as well. Keep a copy in hrgnWinupd
773 * to be added to hrngUpdate at the end. */
774 hrgnTemp
= CreateRectRgn( 0, 0, 0, 0 );
775 retVal
= GetUpdateRgn( hwnd
, hrgnTemp
, FALSE
);
776 if (retVal
!= NULLREGION
)
778 HRGN hrgnClip
= CreateRectRgnIndirect(&cliprc
);
780 hrgnWinupd
= CreateRectRgn( 0, 0, 0, 0);
781 CombineRgn( hrgnWinupd
, hrgnTemp
, 0, RGN_COPY
);
783 OffsetRgn( hrgnTemp
, dx
, dy
);
784 CombineRgn( hrgnTemp
, hrgnTemp
, hrgnClip
, RGN_AND
);
786 CombineRgn( hrgnWinupd
, hrgnWinupd
, hrgnTemp
, RGN_OR
);
787 RedrawWindow( hwnd
, NULL
, hrgnTemp
, rdw_flags
);
788 DeleteObject( hrgnClip
);
790 DeleteObject( hrgnTemp
);
792 /* nothing was scrolled */
794 SetRectRgn( hrgnUpdate
, 0, 0, 0, 0 );
795 SetRectEmpty( rcUpdate
);
798 if( flags
& SW_SCROLLCHILDREN
)
800 HWND
*list
= WIN_ListChildren( hwnd
);
805 for (i
= 0; list
[i
]; i
++)
807 GetWindowRect( list
[i
], &r
);
808 MapWindowPoints( 0, hwnd
, (POINT
*)&r
, 2 );
809 if (!rect
|| IntersectRect(&dummy
, &r
, rect
))
810 SetWindowPos( list
[i
], 0, r
.left
+ dx
, r
.top
+ dy
, 0, 0,
811 SWP_NOZORDER
| SWP_NOSIZE
| SWP_NOACTIVATE
|
812 SWP_NOREDRAW
| SWP_DEFERERASE
);
814 HeapFree( GetProcessHeap(), 0, list
);
818 if( flags
& (SW_INVALIDATE
| SW_ERASE
) )
819 RedrawWindow( hwnd
, NULL
, hrgnUpdate
, rdw_flags
|
820 ((flags
& SW_SCROLLCHILDREN
) ? RDW_ALLCHILDREN
: 0 ) );
823 CombineRgn( hrgnUpdate
, hrgnUpdate
, hrgnWinupd
, RGN_OR
);
824 DeleteObject( hrgnWinupd
);
828 SetCaretPos( caretrc
.left
+ dx
, caretrc
.top
+ dy
);
829 ShowCaret(hwndCaret
);
832 if( bOwnRgn
&& hrgnUpdate
) DeleteObject( hrgnUpdate
);
838 /*************************************************************************
839 * ScrollWindow (USER32.@)
842 BOOL WINAPI
ScrollWindow( HWND hwnd
, INT dx
, INT dy
,
843 const RECT
*rect
, const RECT
*clipRect
)
845 return (ERROR
!= ScrollWindowEx( hwnd
, dx
, dy
, rect
, clipRect
, 0, NULL
,
846 (rect
? 0 : SW_SCROLLCHILDREN
) |
847 SW_INVALIDATE
| SW_ERASE
));
851 /*************************************************************************
852 * ScrollDC (USER32.@)
854 * dx, dy, lprcScroll and lprcClip are all in logical coordinates (msdn is
855 * wrong) hrgnUpdate is returned in device coordinates with rcUpdate in
856 * logical coordinates.
858 BOOL WINAPI
ScrollDC( HDC hdc
, INT dx
, INT dy
, const RECT
*lprcScroll
,
859 const RECT
*lprcClip
, HRGN hrgnUpdate
, LPRECT lprcUpdate
)
862 return USER_Driver
->pScrollDC( hdc
, dx
, dy
, lprcScroll
, lprcClip
, hrgnUpdate
, lprcUpdate
);