2 * Window painting functions
4 * Copyright 1993, 1994, 1995 Alexandre Julliard
15 #include "wine/winuser16.h"
17 DECLARE_DEBUG_CHANNEL(nonclient)
18 DECLARE_DEBUG_CHANNEL(win)
20 /* client rect in window coordinates */
22 #define GETCLIENTRECTW( wnd, r ) (r).left = (wnd)->rectClient.left - (wnd)->rectWindow.left; \
23 (r).top = (wnd)->rectClient.top - (wnd)->rectWindow.top; \
24 (r).right = (wnd)->rectClient.right - (wnd)->rectWindow.left; \
25 (r).bottom = (wnd)->rectClient.bottom - (wnd)->rectWindow.top
27 /* Last CTLCOLOR id */
28 #define CTLCOLOR_MAX CTLCOLOR_STATIC
31 /***********************************************************************
34 * NOTE: Caller is responsible for the returned region.
36 HRGN WIN_UpdateNCRgn(WND* wnd, BOOL bUpdate, BOOL bForceEntire )
40 TRACE(nonclient,"hwnd %04x, hrgnUpdate %04x, ncf %i\n",
41 wnd->hwndSelf, wnd->hrgnUpdate, (wnd->flags & WIN_NEEDS_NCPAINT)!=0 );
43 /* desktop window doesn't have nonclient area */
44 if(wnd == WIN_GetDesktop())
46 wnd->flags &= ~WIN_NEEDS_NCPAINT;
52 if ((wnd->hwndSelf == GetActiveWindow()) &&
53 !(wnd->flags & WIN_NCACTIVATED) )
55 wnd->flags |= WIN_NCACTIVATED;
59 if( (wnd->flags & WIN_NEEDS_NCPAINT) && wnd->hrgnUpdate )
63 GETCLIENTRECTW( wnd, r );
65 TRACE(nonclient, "\tclient box (%i,%i-%i,%i)\n", r.left, r.top, r.right, r.bottom );
67 if( wnd->hrgnUpdate > 1 )
69 GetRgnBox( wnd->hrgnUpdate, &r2 );
70 UnionRect( &r3, &r2, &r );
71 if( r3.left != r.left || r3.top != r.top ||
72 r3.right != r.right || r3.bottom != r.bottom )
74 hClip = CreateRectRgn( 0, 0, 0, 0 );
75 CombineRgn( hClip, wnd->hrgnUpdate, 0, RGN_COPY );
79 hClip = wnd->hrgnUpdate;
81 if( wnd->hrgnUpdate > 1 )
83 REGION_CropRgn( wnd->hrgnUpdate, wnd->hrgnUpdate, &r, NULL );
87 GetRgnBox( wnd->hrgnUpdate, &r3 );
88 if( IsRectEmpty( &r3 ) )
90 /* delete update region since all invalid
91 * parts were in the nonclient area */
93 DeleteObject( wnd->hrgnUpdate );
95 if(!(wnd->flags & WIN_INTERNAL_PAINT))
96 QUEUE_DecPaintCount( wnd->hmemTaskQ );
97 wnd->flags &= ~WIN_NEEDS_ERASEBKGND;
101 else /* entire client rect */
102 wnd->hrgnUpdate = CreateRectRgnIndirect( &r );
105 if(!hClip && bForceEntire ) hClip = 1;
106 wnd->flags &= ~WIN_NEEDS_NCPAINT;
109 SendMessageA( wnd->hwndSelf, WM_NCPAINT, hClip, 0L );
115 /***********************************************************************
116 * BeginPaint16 (USER.39)
118 HDC16 WINAPI BeginPaint16( HWND16 hwnd, LPPAINTSTRUCT16 lps )
122 WND *wndPtr = WIN_FindWndPtr( hwnd );
123 if (!wndPtr) return 0;
125 bIcon = (wndPtr->dwStyle & WS_MINIMIZE && wndPtr->class->hIcon);
127 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
129 if( (hrgnUpdate = WIN_UpdateNCRgn( wndPtr, FALSE, FALSE )) > 1 )
130 DeleteObject( hrgnUpdate );
132 if( ((hrgnUpdate = wndPtr->hrgnUpdate) != 0) || (wndPtr->flags & WIN_INTERNAL_PAINT))
133 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
135 wndPtr->hrgnUpdate = 0;
136 wndPtr->flags &= ~WIN_INTERNAL_PAINT;
140 TRACE(win,"hrgnUpdate = %04x, \n", hrgnUpdate);
142 if (wndPtr->class->style & CS_PARENTDC)
144 /* Don't clip the output to the update region for CS_PARENTDC window */
146 DeleteObject(hrgnUpdate);
147 lps->hdc = GetDCEx16( hwnd, 0, DCX_WINDOWPAINT | DCX_USESTYLE |
148 (bIcon ? DCX_WINDOW : 0) );
153 OffsetRgn( hrgnUpdate, wndPtr->rectWindow.left - wndPtr->rectClient.left,
154 wndPtr->rectWindow.top - wndPtr->rectClient.top );
155 lps->hdc = GetDCEx16(hwnd, hrgnUpdate, DCX_INTERSECTRGN |
156 DCX_WINDOWPAINT | DCX_USESTYLE |
157 (bIcon ? DCX_WINDOW : 0) );
160 TRACE(win,"hdc = %04x\n", lps->hdc);
164 WARN(win, "GetDCEx() failed in BeginPaint(), hwnd=%04x\n", hwnd);
165 WIN_ReleaseWndPtr(wndPtr);
169 GetClipBox16( lps->hdc, &lps->rcPaint );
171 TRACE(win,"box = (%i,%i - %i,%i)\n", lps->rcPaint.left, lps->rcPaint.top,
172 lps->rcPaint.right, lps->rcPaint.bottom );
174 if (wndPtr->flags & WIN_NEEDS_ERASEBKGND)
176 wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
177 lps->fErase = !SendMessage16(hwnd, (bIcon) ? WM_ICONERASEBKGND
179 (WPARAM16)lps->hdc, 0 );
181 else lps->fErase = TRUE;
183 WIN_ReleaseWndPtr(wndPtr);
188 /***********************************************************************
189 * BeginPaint32 (USER32.10)
191 HDC WINAPI BeginPaint( HWND hwnd, PAINTSTRUCT *lps )
195 BeginPaint16( hwnd, &ps );
196 lps->hdc = (HDC)ps.hdc;
197 lps->fErase = ps.fErase;
198 lps->rcPaint.top = ps.rcPaint.top;
199 lps->rcPaint.left = ps.rcPaint.left;
200 lps->rcPaint.right = ps.rcPaint.right;
201 lps->rcPaint.bottom = ps.rcPaint.bottom;
202 lps->fRestore = ps.fRestore;
203 lps->fIncUpdate = ps.fIncUpdate;
208 /***********************************************************************
209 * EndPaint16 (USER.40)
211 BOOL16 WINAPI EndPaint16( HWND16 hwnd, const PAINTSTRUCT16* lps )
213 ReleaseDC16( hwnd, lps->hdc );
219 /***********************************************************************
220 * EndPaint32 (USER32.176)
222 BOOL WINAPI EndPaint( HWND hwnd, const PAINTSTRUCT *lps )
224 ReleaseDC( hwnd, lps->hdc );
230 /***********************************************************************
231 * FillWindow (USER.324)
233 void WINAPI FillWindow16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc, HBRUSH16 hbrush )
236 GetClientRect16( hwnd, &rect );
237 DPtoLP16( hdc, (LPPOINT16)&rect, 2 );
238 PaintRect16( hwndParent, hwnd, hdc, hbrush, &rect );
242 /***********************************************************************
243 * PAINT_GetControlBrush
245 static HBRUSH16 PAINT_GetControlBrush( HWND hParent, HWND hWnd, HDC16 hDC, UINT16 ctlType )
247 HBRUSH16 bkgBrush = (HBRUSH16)SendMessageA( hParent, WM_CTLCOLORMSGBOX + ctlType,
248 (WPARAM)hDC, (LPARAM)hWnd );
249 if( !IsGDIObject16(bkgBrush) )
250 bkgBrush = DEFWND_ControlColor( hDC, ctlType );
255 /***********************************************************************
256 * PaintRect (USER.325)
258 void WINAPI PaintRect16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc,
259 HBRUSH16 hbrush, const RECT16 *rect)
261 if( hbrush <= CTLCOLOR_MAX )
264 hbrush = PAINT_GetControlBrush( hwndParent, hwnd, hdc, (UINT16)hbrush );
269 FillRect16( hdc, rect, hbrush );
273 /***********************************************************************
274 * GetControlBrush (USER.326)
276 HBRUSH16 WINAPI GetControlBrush16( HWND16 hwnd, HDC16 hdc, UINT16 ctlType )
278 WND* wndPtr = WIN_FindWndPtr( hwnd );
281 if((ctlType <= CTLCOLOR_MAX) && wndPtr )
284 if( wndPtr->dwStyle & WS_POPUP ) parent = WIN_LockWndPtr(wndPtr->owner);
285 else parent = WIN_LockWndPtr(wndPtr->parent);
286 if( !parent ) parent = wndPtr;
287 retvalue = (HBRUSH16)PAINT_GetControlBrush( parent->hwndSelf, hwnd, hdc, ctlType );
288 WIN_ReleaseWndPtr(parent);
291 retvalue = (HBRUSH16)0;
293 WIN_ReleaseWndPtr(wndPtr);
298 /***********************************************************************
301 * FIXME: Windows uses WM_SYNCPAINT to cut down the number of intertask
302 * SendMessage() calls. This is a comment inside DefWindowProc() source
305 * This message avoids lots of inter-app message traffic
306 * by switching to the other task and continuing the
310 * LOWORD(lParam) = hrgnClip
311 * HIWORD(lParam) = hwndSkip (not used; always NULL)
314 BOOL PAINT_RedrawWindow( HWND hwnd, const RECT *rectUpdate,
315 HRGN hrgnUpdate, UINT flags, UINT ex )
318 HRGN hrgn = 0, hrgn2 = 0;
324 if (!hwnd) hwnd = GetDesktopWindow();
325 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
326 if (!WIN_IsWindowDrawable( wndPtr, !(flags & RDW_FRAME) ) )
328 WIN_ReleaseWndPtr(wndPtr);
329 return TRUE; /* No redraw needed */
332 bIcon = (wndPtr->dwStyle & WS_MINIMIZE && wndPtr->class->hIcon);
335 TRACE(win, "%04x (%04x) %d,%d-%d,%d %04x flags=%04x, exflags=%04x\n",
336 hwnd, wndPtr->hrgnUpdate, rectUpdate->left, rectUpdate->top,
337 rectUpdate->right, rectUpdate->bottom, hrgnUpdate, flags, ex );
341 if( hrgnUpdate ) GetRgnBox( hrgnUpdate, &r );
342 else SetRectEmpty( &r );
343 TRACE(win, "%04x (%04x) NULL %04x box (%i,%i-%i,%i) flags=%04x, exflags=%04x\n",
344 hwnd, wndPtr->hrgnUpdate, hrgnUpdate, r.left, r.top, r.right, r.bottom, flags, ex);
347 if( flags & RDW_FRAME )
348 r = wndPtr->rectWindow;
350 r = wndPtr->rectClient;
351 if( ex & RDW_EX_XYWINDOW )
352 OffsetRect( &r, -wndPtr->rectWindow.left, -wndPtr->rectWindow.top );
354 OffsetRect( &r, -wndPtr->rectClient.left, -wndPtr->rectClient.top );
356 /* r is the rectangle we crop the supplied update rgn/rect with */
358 GETCLIENTRECTW( wndPtr, r2 );
359 pt.x = r2.left; pt.y = r2.top;
361 if (flags & RDW_INVALIDATE) /* ------------------------- Invalidate */
363 BOOL bHasUpdateRgn = (BOOL)wndPtr->hrgnUpdate;
365 /* wndPtr->hrgnUpdate is in window coordinates, parameters are
366 * in client coordinates unless RDW_EX_XYWINDOW is set.
371 hrgn = REGION_CropRgn( 0, hrgnUpdate, &r, (ex & RDW_EX_XYWINDOW) ? NULL : &pt );
372 GetRgnBox( hrgn, &r2 );
373 if( IsRectEmpty( &r2 ) )
376 if( wndPtr->hrgnUpdate == 0 )
378 wndPtr->hrgnUpdate = CreateRectRgn( 0, 0, 0, 0 );
379 CombineRgn( wndPtr->hrgnUpdate, hrgn, 0, RGN_COPY );
382 if( wndPtr->hrgnUpdate > 1 )
383 CombineRgn( wndPtr->hrgnUpdate, wndPtr->hrgnUpdate, hrgn, RGN_OR );
385 else if( rectUpdate )
387 if( !IntersectRect( &r2, &r, rectUpdate ) )
389 if( !(ex & RDW_EX_XYWINDOW) )
390 OffsetRect( &r2, pt.x, pt.y );
392 rect2i: /* r2 contains a rect to add to the update region */
394 hrgn = CreateRectRgnIndirect( &r2 );
395 if( wndPtr->hrgnUpdate == 0 )
396 wndPtr->hrgnUpdate = CreateRectRgnIndirect( &r2 );
398 if( wndPtr->hrgnUpdate > 1 )
399 REGION_UnionRectWithRgn( wndPtr->hrgnUpdate, &r2 );
401 else /* entire window or client depending on RDW_FRAME */
404 if( flags & RDW_FRAME )
406 if( wndPtr->hrgnUpdate )
407 DeleteObject( wndPtr->hrgnUpdate );
408 wndPtr->hrgnUpdate = 1;
410 else /* by default r2 contains client rect in window coordinates */
414 if( !bHasUpdateRgn && wndPtr->hrgnUpdate && !(wndPtr->flags & WIN_INTERNAL_PAINT))
415 QUEUE_IncPaintCount( wndPtr->hmemTaskQ );
417 if (flags & RDW_FRAME) wndPtr->flags |= WIN_NEEDS_NCPAINT;
418 if (flags & RDW_ERASE) wndPtr->flags |= WIN_NEEDS_ERASEBKGND;
419 flags |= RDW_FRAME; /* Force children frame invalidation */
421 else if (flags & RDW_VALIDATE) /* ------------------------- Validate */
423 if (wndPtr->hrgnUpdate) /* need an update region in order to validate anything */
425 if( hrgnUpdate || rectUpdate )
429 hrgn = REGION_CropRgn( hrgn, hrgnUpdate, &r, (ex & RDW_EX_XYWINDOW) ? NULL : &pt );
430 GetRgnBox( hrgn, &r2 );
431 if( IsRectEmpty( &r2 ) )
436 if( !IntersectRect( &r2, &r, rectUpdate ) )
438 if( !(ex & RDW_EX_XYWINDOW) )
439 OffsetRect( &r2, pt.x, pt.y );
441 hrgn = CreateRectRgnIndirect( &r2 );
444 if( wndPtr->hrgnUpdate == 1 )
446 wndPtr->hrgnUpdate = CreateRectRgn( 0, 0,
447 wndPtr->rectWindow.right - wndPtr->rectWindow.left,
448 wndPtr->rectWindow.bottom - wndPtr->rectWindow.top );
451 if( CombineRgn( wndPtr->hrgnUpdate,
452 wndPtr->hrgnUpdate, hrgn, RGN_DIFF ) == NULLREGION )
454 DeleteObject( wndPtr->hrgnUpdate );
455 wndPtr->hrgnUpdate = 0;
458 else /* entire window or client depending on RDW_FRAME */
460 wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
463 if( flags & RDW_FRAME )
465 if( wndPtr->hrgnUpdate != 1 )
466 DeleteObject( wndPtr->hrgnUpdate );
467 wndPtr->hrgnUpdate = 0;
469 else /* by default r2 contains client rect in window coordinates */
473 if (!wndPtr->hrgnUpdate && /* No more update region */
474 !(wndPtr->flags & WIN_INTERNAL_PAINT) )
475 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
477 if (flags & RDW_NOFRAME) wndPtr->flags &= ~WIN_NEEDS_NCPAINT;
478 if (flags & RDW_NOERASE) wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
481 /* At this point hrgn contains new update region in window coordinates */
483 /* Set/clear internal paint flag */
485 if (flags & RDW_INTERNALPAINT)
487 if ( !wndPtr->hrgnUpdate && !(wndPtr->flags & WIN_INTERNAL_PAINT))
488 QUEUE_IncPaintCount( wndPtr->hmemTaskQ );
489 wndPtr->flags |= WIN_INTERNAL_PAINT;
491 else if (flags & RDW_NOINTERNALPAINT)
493 if ( !wndPtr->hrgnUpdate && (wndPtr->flags & WIN_INTERNAL_PAINT))
494 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
495 wndPtr->flags &= ~WIN_INTERNAL_PAINT;
498 /* Erase/update window */
500 if (flags & RDW_UPDATENOW)
502 if (wndPtr->hrgnUpdate) /* wm_painticon wparam is 1 */
503 SendMessage16( hwnd, (bIcon) ? WM_PAINTICON : WM_PAINT, bIcon, 0 );
505 else if ((flags & RDW_ERASENOW) || (ex & RDW_EX_TOPFRAME))
507 hrgn2 = WIN_UpdateNCRgn( wndPtr, TRUE, (ex & RDW_EX_TOPFRAME) );
509 if( wndPtr->flags & WIN_NEEDS_ERASEBKGND )
515 OffsetRgn( hrgn2, -pt.x, -pt.y );
516 GetRgnBox( hrgn2, &r2 );
520 hrgn2 = CreateRectRgn( 0, 0, 0, 0 );
521 CombineRgn( hrgn2, wndPtr->hrgnUpdate, 0, RGN_COPY );
522 OffsetRgn( hrgn2, -pt.x, -pt.y );
524 hdc = GetDCEx( hwnd, hrgn2,
525 DCX_INTERSECTRGN | DCX_USESTYLE |
526 DCX_KEEPCLIPRGN | DCX_WINDOWPAINT |
527 (bIcon ? DCX_WINDOW : 0) );
530 if (SendMessage16( hwnd, (bIcon) ? WM_ICONERASEBKGND
533 wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
534 ReleaseDC( hwnd, hdc );
539 if ( !IsWindow( hwnd ) )
541 WIN_ReleaseWndPtr(wndPtr);
545 /* Recursively process children */
547 if (!(flags & RDW_NOCHILDREN) &&
548 ((flags & RDW_ALLCHILDREN) || !(wndPtr->dwStyle & WS_CLIPCHILDREN)) &&
549 !(wndPtr->dwStyle & WS_MINIMIZE) )
551 if( hrgnUpdate || rectUpdate )
554 hrgn2 = (ex & RDW_EX_USEHRGN) ? hrgnUpdate : 0;
556 if( (list = WIN_BuildWinArray( wndPtr, 0, NULL )) )
560 for (ppWnd = list; *ppWnd; ppWnd++)
562 WIN_UpdateWndPtr(&wndPtr,*ppWnd);
563 if (!IsWindow(wndPtr->hwndSelf)) continue;
564 if (wndPtr->dwStyle & WS_VISIBLE)
566 r.left = wndPtr->rectWindow.left + delta.x;
567 r.top = wndPtr->rectWindow.top + delta.y;
568 r.right = wndPtr->rectWindow.right + delta.x;
569 r.bottom = wndPtr->rectWindow.bottom + delta.y;
571 pt.x = -r.left; pt.y = -r.top;
573 hrgn2 = REGION_CropRgn( hrgn2, hrgn, &r, &pt );
575 GetRgnBox( hrgn2, &r2 );
576 if( !IsRectEmpty( &r2 ) )
578 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, hrgn2, flags,
579 RDW_EX_USEHRGN | RDW_EX_XYWINDOW );
583 WIN_ReleaseWinArray(list);
588 if( (list = WIN_BuildWinArray( wndPtr, 0, NULL )) )
590 for (ppWnd = list; *ppWnd; ppWnd++)
592 WIN_UpdateWndPtr(&wndPtr,*ppWnd);
593 if (IsWindow( wndPtr->hwndSelf ))
594 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0, flags, 0 );
596 WIN_ReleaseWinArray(list);
603 if( hrgn2 > 1 && (hrgn2 != hrgnUpdate) )
604 DeleteObject( hrgn2 );
605 if( hrgn > 1 && (hrgn != hrgnUpdate) )
606 DeleteObject( hrgn );
607 WIN_ReleaseWndPtr(wndPtr);
612 /***********************************************************************
613 * RedrawWindow32 (USER32.426)
615 BOOL WINAPI RedrawWindow( HWND hwnd, const RECT *rectUpdate,
616 HRGN hrgnUpdate, UINT flags )
618 return PAINT_RedrawWindow( hwnd, rectUpdate, hrgnUpdate, flags, 0 );
622 /***********************************************************************
623 * RedrawWindow16 (USER.290)
625 BOOL16 WINAPI RedrawWindow16( HWND16 hwnd, const RECT16 *rectUpdate,
626 HRGN16 hrgnUpdate, UINT16 flags )
631 CONV_RECT16TO32( rectUpdate, &r );
632 return (BOOL16)RedrawWindow( (HWND)hwnd, &r, hrgnUpdate, flags );
634 return (BOOL16)PAINT_RedrawWindow( (HWND)hwnd, NULL,
635 (HRGN)hrgnUpdate, flags, 0 );
639 /***********************************************************************
640 * UpdateWindow16 (USER.124)
642 void WINAPI UpdateWindow16( HWND16 hwnd )
644 PAINT_RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_NOCHILDREN, 0 );
647 /***********************************************************************
648 * UpdateWindow32 (USER32.567)
650 void WINAPI UpdateWindow( HWND hwnd )
652 PAINT_RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_NOCHILDREN, 0 );
655 /***********************************************************************
656 * InvalidateRgn16 (USER.126)
658 void WINAPI InvalidateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
660 PAINT_RedrawWindow((HWND)hwnd, NULL, (HRGN)hrgn,
661 RDW_INVALIDATE | (erase ? RDW_ERASE : 0), 0 );
665 /***********************************************************************
666 * InvalidateRgn32 (USER32.329)
668 BOOL WINAPI InvalidateRgn( HWND hwnd, HRGN hrgn, BOOL erase )
670 return PAINT_RedrawWindow(hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0), 0 );
674 /***********************************************************************
675 * InvalidateRect16 (USER.125)
677 void WINAPI InvalidateRect16( HWND16 hwnd, const RECT16 *rect, BOOL16 erase )
679 RedrawWindow16( hwnd, rect, 0, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
683 /***********************************************************************
684 * InvalidateRect32 (USER32.328)
686 BOOL WINAPI InvalidateRect( HWND hwnd, const RECT *rect, BOOL erase )
688 return PAINT_RedrawWindow( hwnd, rect, 0,
689 RDW_INVALIDATE | (erase ? RDW_ERASE : 0), 0 );
693 /***********************************************************************
694 * ValidateRgn16 (USER.128)
696 void WINAPI ValidateRgn16( HWND16 hwnd, HRGN16 hrgn )
698 PAINT_RedrawWindow( (HWND)hwnd, NULL, (HRGN)hrgn,
699 RDW_VALIDATE | RDW_NOCHILDREN, 0 );
703 /***********************************************************************
704 * ValidateRgn32 (USER32.572)
706 void WINAPI ValidateRgn( HWND hwnd, HRGN hrgn )
708 PAINT_RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOCHILDREN, 0 );
712 /***********************************************************************
713 * ValidateRect16 (USER.127)
715 void WINAPI ValidateRect16( HWND16 hwnd, const RECT16 *rect )
717 RedrawWindow16( hwnd, rect, 0, RDW_VALIDATE | RDW_NOCHILDREN );
721 /***********************************************************************
722 * ValidateRect32 (USER32.571)
724 void WINAPI ValidateRect( HWND hwnd, const RECT *rect )
726 PAINT_RedrawWindow( hwnd, rect, 0, RDW_VALIDATE | RDW_NOCHILDREN, 0 );
730 /***********************************************************************
731 * GetUpdateRect16 (USER.190)
733 BOOL16 WINAPI GetUpdateRect16( HWND16 hwnd, LPRECT16 rect, BOOL16 erase )
738 if (!rect) return GetUpdateRect( hwnd, NULL, erase );
739 ret = GetUpdateRect( hwnd, &r, erase );
740 CONV_RECT32TO16( &r, rect );
745 /***********************************************************************
746 * GetUpdateRect32 (USER32.297)
748 BOOL WINAPI GetUpdateRect( HWND hwnd, LPRECT rect, BOOL erase )
751 WND * wndPtr = WIN_FindWndPtr( hwnd );
752 if (!wndPtr) return FALSE;
756 if (wndPtr->hrgnUpdate > 1)
758 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
759 if (GetUpdateRgn( hwnd, hrgn, erase ) == ERROR)
764 GetRgnBox( hrgn, rect );
765 DeleteObject( hrgn );
766 if (wndPtr->class->style & CS_OWNDC)
768 if (GetMapMode(wndPtr->dce->hDC) != MM_TEXT)
770 DPtoLP (wndPtr->dce->hDC, (LPPOINT)rect, 2);
775 if( wndPtr->hrgnUpdate == 1 )
777 GetClientRect( hwnd, rect );
778 if (erase) RedrawWindow( hwnd, NULL, 0, RDW_FRAME | RDW_ERASENOW | RDW_NOCHILDREN );
781 SetRectEmpty( rect );
783 retvalue = (wndPtr->hrgnUpdate >= 1);
785 WIN_ReleaseWndPtr(wndPtr);
790 /***********************************************************************
791 * GetUpdateRgn16 (USER.237)
793 INT16 WINAPI GetUpdateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
795 return GetUpdateRgn( hwnd, hrgn, erase );
799 /***********************************************************************
800 * GetUpdateRgn (USER32.298)
802 INT WINAPI GetUpdateRgn( HWND hwnd, HRGN hrgn, BOOL erase )
805 WND * wndPtr = WIN_FindWndPtr( hwnd );
806 if (!wndPtr) return ERROR;
808 if (wndPtr->hrgnUpdate == 0)
810 SetRectRgn( hrgn, 0, 0, 0, 0 );
815 if (wndPtr->hrgnUpdate == 1)
817 SetRectRgn( hrgn, 0, 0, wndPtr->rectClient.right - wndPtr->rectClient.left,
818 wndPtr->rectClient.bottom - wndPtr->rectClient.top );
819 retval = SIMPLEREGION;
823 retval = CombineRgn( hrgn, wndPtr->hrgnUpdate, 0, RGN_COPY );
824 OffsetRgn( hrgn, wndPtr->rectWindow.left - wndPtr->rectClient.left,
825 wndPtr->rectWindow.top - wndPtr->rectClient.top );
827 if (erase) RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW | RDW_NOCHILDREN );
829 WIN_ReleaseWndPtr(wndPtr);
834 /***********************************************************************
835 * ExcludeUpdateRgn16 (USER.238)
837 INT16 WINAPI ExcludeUpdateRgn16( HDC16 hdc, HWND16 hwnd )
839 return ExcludeUpdateRgn( hdc, hwnd );
843 /***********************************************************************
844 * ExcludeUpdateRgn32 (USER32.195)
846 INT WINAPI ExcludeUpdateRgn( HDC hdc, HWND hwnd )
851 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return ERROR;
853 if (wndPtr->hrgnUpdate)
856 HRGN hrgn = CreateRectRgn(wndPtr->rectWindow.left - wndPtr->rectClient.left,
857 wndPtr->rectWindow.top - wndPtr->rectClient.top,
858 wndPtr->rectWindow.right - wndPtr->rectClient.left,
859 wndPtr->rectWindow.bottom - wndPtr->rectClient.top);
860 if( wndPtr->hrgnUpdate > 1 )
862 CombineRgn(hrgn, wndPtr->hrgnUpdate, 0, RGN_COPY);
863 OffsetRgn(hrgn, wndPtr->rectWindow.left - wndPtr->rectClient.left,
864 wndPtr->rectWindow.top - wndPtr->rectClient.top );
867 /* do ugly coordinate translations in dce.c */
869 ret = DCE_ExcludeRgn( hdc, wndPtr, hrgn );
870 DeleteObject( hrgn );
871 WIN_ReleaseWndPtr(wndPtr);
874 WIN_ReleaseWndPtr(wndPtr);
875 return GetClipBox( hdc, &rect );