ugfixes for IPX code and preliminary groundwork for other address
[wine.git] / windows / painting.c
bloba2dab04b722676648ee06eb41977c49aa438ca09
1 /*
2 * Window painting functions
4 * Copyright 1993, 1994, 1995 Alexandre Julliard
6 * FIXME: Do not repaint full nonclient area all the time. Instead, compute
7 * intersection with hrgnUpdate (which should be moved from client to
8 * window coords as well, lookup 'the pain' comment in the winpos.c).
9 */
11 #include "win.h"
12 #include "queue.h"
13 #include "gdi.h"
14 #include "dce.h"
15 #include "heap.h"
16 #include "debug.h"
18 /* Last CTLCOLOR id */
19 #define CTLCOLOR_MAX CTLCOLOR_STATIC
21 /***********************************************************************
22 * WIN_UpdateNCArea
25 void WIN_UpdateNCArea(WND* wnd, BOOL32 bUpdate)
27 POINT16 pt = {0, 0};
28 HRGN32 hClip = 1;
30 TRACE(nonclient,"hwnd %04x, hrgnUpdate %04x\n",
31 wnd->hwndSelf, wnd->hrgnUpdate );
33 /* desktop window doesn't have nonclient area */
34 if(wnd == WIN_GetDesktop())
36 wnd->flags &= ~WIN_NEEDS_NCPAINT;
37 return;
40 if( wnd->hrgnUpdate > 1 )
42 ClientToScreen16(wnd->hwndSelf, &pt);
44 hClip = CreateRectRgn32( 0, 0, 0, 0 );
45 if (!CombineRgn32( hClip, wnd->hrgnUpdate, 0, RGN_COPY ))
47 DeleteObject32(hClip);
48 hClip = 1;
50 else
51 OffsetRgn32( hClip, pt.x, pt.y );
53 if (bUpdate)
55 /* exclude non-client area from update region */
56 HRGN32 hrgn = CreateRectRgn32( 0, 0,
57 wnd->rectClient.right - wnd->rectClient.left,
58 wnd->rectClient.bottom - wnd->rectClient.top);
60 if (hrgn && (CombineRgn32( wnd->hrgnUpdate, wnd->hrgnUpdate,
61 hrgn, RGN_AND) == NULLREGION))
63 DeleteObject32( wnd->hrgnUpdate );
64 wnd->hrgnUpdate = 1;
67 DeleteObject32( hrgn );
71 wnd->flags &= ~WIN_NEEDS_NCPAINT;
73 if ((wnd->hwndSelf == GetActiveWindow32()) &&
74 !(wnd->flags & WIN_NCACTIVATED))
76 wnd->flags |= WIN_NCACTIVATED;
77 if( hClip > 1) DeleteObject32( hClip );
78 hClip = 1;
81 if (hClip) SendMessage16( wnd->hwndSelf, WM_NCPAINT, hClip, 0L );
83 if (hClip > 1) DeleteObject32( hClip );
87 /***********************************************************************
88 * BeginPaint16 (USER.39)
90 HDC16 WINAPI BeginPaint16( HWND16 hwnd, LPPAINTSTRUCT16 lps )
92 BOOL32 bIcon;
93 HRGN32 hrgnUpdate;
94 WND *wndPtr = WIN_FindWndPtr( hwnd );
95 if (!wndPtr) return 0;
97 bIcon = (wndPtr->dwStyle & WS_MINIMIZE && wndPtr->class->hIcon);
99 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
101 if (wndPtr->flags & WIN_NEEDS_NCPAINT) WIN_UpdateNCArea( wndPtr, TRUE );
103 if (((hrgnUpdate = wndPtr->hrgnUpdate) != 0) ||
104 (wndPtr->flags & WIN_INTERNAL_PAINT))
105 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
107 wndPtr->hrgnUpdate = 0;
108 wndPtr->flags &= ~WIN_INTERNAL_PAINT;
110 HideCaret32( hwnd );
112 TRACE(win,"hrgnUpdate = %04x, \n", hrgnUpdate);
114 /* When bIcon is TRUE hrgnUpdate is automatically in window coordinates
115 * (because rectClient == rectWindow for WS_MINIMIZE windows).
118 if (wndPtr->class->style & CS_PARENTDC)
120 /* Don't clip the output to the update region for CS_PARENTDC window */
121 if(hrgnUpdate > 1)
122 DeleteObject32(hrgnUpdate);
123 lps->hdc = GetDCEx16( hwnd, 0, DCX_WINDOWPAINT | DCX_USESTYLE |
124 (bIcon ? DCX_WINDOW : 0) );
126 else
128 lps->hdc = GetDCEx16(hwnd, hrgnUpdate, DCX_INTERSECTRGN |
129 DCX_WINDOWPAINT | DCX_USESTYLE |
130 (bIcon ? DCX_WINDOW : 0) );
133 TRACE(win,"hdc = %04x\n", lps->hdc);
135 if (!lps->hdc)
137 WARN(win, "GetDCEx() failed in BeginPaint(), hwnd=%04x\n", hwnd);
138 return 0;
141 GetClipBox16( lps->hdc, &lps->rcPaint );
143 TRACE(win,"box = (%i,%i - %i,%i)\n", lps->rcPaint.left, lps->rcPaint.top,
144 lps->rcPaint.right, lps->rcPaint.bottom );
146 if (wndPtr->flags & WIN_NEEDS_ERASEBKGND)
148 wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
149 lps->fErase = !SendMessage16(hwnd, (bIcon) ? WM_ICONERASEBKGND
150 : WM_ERASEBKGND,
151 (WPARAM16)lps->hdc, 0 );
153 else lps->fErase = TRUE;
155 return lps->hdc;
159 /***********************************************************************
160 * BeginPaint32 (USER32.10)
162 HDC32 WINAPI BeginPaint32( HWND32 hwnd, PAINTSTRUCT32 *lps )
164 PAINTSTRUCT16 ps;
166 BeginPaint16( hwnd, &ps );
167 lps->hdc = (HDC32)ps.hdc;
168 lps->fErase = ps.fErase;
169 lps->rcPaint.top = ps.rcPaint.top;
170 lps->rcPaint.left = ps.rcPaint.left;
171 lps->rcPaint.right = ps.rcPaint.right;
172 lps->rcPaint.bottom = ps.rcPaint.bottom;
173 lps->fRestore = ps.fRestore;
174 lps->fIncUpdate = ps.fIncUpdate;
175 return lps->hdc;
179 /***********************************************************************
180 * EndPaint16 (USER.40)
182 BOOL16 WINAPI EndPaint16( HWND16 hwnd, const PAINTSTRUCT16* lps )
184 ReleaseDC16( hwnd, lps->hdc );
185 ShowCaret32( hwnd );
186 return TRUE;
190 /***********************************************************************
191 * EndPaint32 (USER32.176)
193 BOOL32 WINAPI EndPaint32( HWND32 hwnd, const PAINTSTRUCT32 *lps )
195 ReleaseDC32( hwnd, lps->hdc );
196 ShowCaret32( hwnd );
197 return TRUE;
201 /***********************************************************************
202 * FillWindow (USER.324)
204 void WINAPI FillWindow( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc, HBRUSH16 hbrush )
206 RECT16 rect;
207 GetClientRect16( hwnd, &rect );
208 DPtoLP16( hdc, (LPPOINT16)&rect, 2 );
209 PaintRect( hwndParent, hwnd, hdc, hbrush, &rect );
213 /***********************************************************************
214 * PAINT_GetControlBrush
216 static HBRUSH16 PAINT_GetControlBrush( HWND32 hParent, HWND32 hWnd, HDC16 hDC, UINT16 ctlType )
218 HBRUSH16 bkgBrush = (HBRUSH16)SendMessage32A( hParent, WM_CTLCOLORMSGBOX + ctlType,
219 (WPARAM32)hDC, (LPARAM)hWnd );
220 if( !IsGDIObject(bkgBrush) )
221 bkgBrush = DEFWND_ControlColor( hDC, ctlType );
222 return bkgBrush;
226 /***********************************************************************
227 * PaintRect (USER.325)
229 void WINAPI PaintRect( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc,
230 HBRUSH16 hbrush, const RECT16 *rect)
232 if( hbrush <= CTLCOLOR_MAX )
234 if( hwndParent )
235 hbrush = PAINT_GetControlBrush( hwndParent, hwnd, hdc, (UINT16)hbrush );
236 else
237 return;
239 if( hbrush )
240 FillRect16( hdc, rect, hbrush );
244 /***********************************************************************
245 * GetControlBrush (USER.326)
247 HBRUSH16 WINAPI GetControlBrush( HWND16 hwnd, HDC16 hdc, UINT16 ctlType )
249 WND* wndPtr = WIN_FindWndPtr( hwnd );
251 if((ctlType <= CTLCOLOR_MAX) && wndPtr )
253 WND* parent;
254 if( wndPtr->dwStyle & WS_POPUP ) parent = wndPtr->owner;
255 else parent = wndPtr->parent;
256 if( !parent ) parent = wndPtr;
257 return (HBRUSH16)PAINT_GetControlBrush( parent->hwndSelf, hwnd, hdc, ctlType );
259 return (HBRUSH16)0;
263 /***********************************************************************
264 * PAINT_RedrawWindow
266 * FIXME: Windows uses WM_SYNCPAINT to cut down the number of intertask
267 * SendMessage() calls. This is a comment inside DefWindowProc() source
268 * from 16-bit SDK:
270 * This message avoids lots of inter-app message traffic
271 * by switching to the other task and continuing the
272 * recursion there.
274 * wParam = flags
275 * LOWORD(lParam) = hrgnClip
276 * HIWORD(lParam) = hwndSkip (not used; always NULL)
278 * All in all, a prime candidate for a rewrite.
280 BOOL32 PAINT_RedrawWindow( HWND32 hwnd, const RECT32 *rectUpdate,
281 HRGN32 hrgnUpdate, UINT32 flags, UINT32 control )
283 BOOL32 bIcon;
284 HRGN32 hrgn;
285 RECT32 rectClient;
286 WND* wndPtr;
287 WND **list, **ppWnd;
289 if (!hwnd) hwnd = GetDesktopWindow32();
290 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
291 if (!WIN_IsWindowDrawable( wndPtr, !(flags & RDW_FRAME) ) )
292 return TRUE; /* No redraw needed */
294 bIcon = (wndPtr->dwStyle & WS_MINIMIZE && wndPtr->class->hIcon);
295 if (rectUpdate)
297 TRACE(win, "%04x %d,%d-%d,%d %04x flags=%04x\n",
298 hwnd, rectUpdate->left, rectUpdate->top,
299 rectUpdate->right, rectUpdate->bottom, hrgnUpdate, flags );
301 else
303 TRACE(win, "%04x NULL %04x flags=%04x\n", hwnd, hrgnUpdate, flags);
306 GetClientRect32( hwnd, &rectClient );
308 if (flags & RDW_INVALIDATE) /* Invalidate */
310 int rgnNotEmpty = COMPLEXREGION;
312 if (wndPtr->hrgnUpdate > 1) /* Is there already an update region? */
314 if ((hrgn = hrgnUpdate) == 0)
315 hrgn = CreateRectRgnIndirect32( rectUpdate ? rectUpdate :
316 &rectClient );
317 rgnNotEmpty = CombineRgn32( wndPtr->hrgnUpdate, wndPtr->hrgnUpdate,
318 hrgn, RGN_OR );
319 if (!hrgnUpdate) DeleteObject32( hrgn );
321 else /* No update region yet */
323 if (!(wndPtr->flags & WIN_INTERNAL_PAINT))
324 QUEUE_IncPaintCount( wndPtr->hmemTaskQ );
325 if (hrgnUpdate)
327 wndPtr->hrgnUpdate = CreateRectRgn32( 0, 0, 0, 0 );
328 rgnNotEmpty = CombineRgn32( wndPtr->hrgnUpdate, hrgnUpdate,
329 0, RGN_COPY );
331 else wndPtr->hrgnUpdate = CreateRectRgnIndirect32( rectUpdate ?
332 rectUpdate : &rectClient );
335 if (flags & RDW_FRAME) wndPtr->flags |= WIN_NEEDS_NCPAINT;
337 /* restrict update region to client area (FIXME: correct?) */
338 if (wndPtr->hrgnUpdate)
340 HRGN32 clientRgn = CreateRectRgnIndirect32( &rectClient );
341 rgnNotEmpty = CombineRgn32( wndPtr->hrgnUpdate, clientRgn,
342 wndPtr->hrgnUpdate, RGN_AND );
343 DeleteObject32( clientRgn );
346 /* check for bogus update region */
347 if ( rgnNotEmpty == NULLREGION )
349 wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
350 DeleteObject32( wndPtr->hrgnUpdate );
351 wndPtr->hrgnUpdate=0;
352 if (!(wndPtr->flags & WIN_INTERNAL_PAINT))
353 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
355 else
356 if (flags & RDW_ERASE) wndPtr->flags |= WIN_NEEDS_ERASEBKGND;
357 flags |= RDW_FRAME; /* Force children frame invalidation */
359 else if (flags & RDW_VALIDATE) /* Validate */
361 /* We need an update region in order to validate anything */
362 if (wndPtr->hrgnUpdate > 1)
364 if (!hrgnUpdate && !rectUpdate)
366 /* Special case: validate everything */
367 DeleteObject32( wndPtr->hrgnUpdate );
368 wndPtr->hrgnUpdate = 0;
370 else
372 if ((hrgn = hrgnUpdate) == 0)
373 hrgn = CreateRectRgnIndirect32( rectUpdate );
374 if (CombineRgn32( wndPtr->hrgnUpdate, wndPtr->hrgnUpdate,
375 hrgn, RGN_DIFF ) == NULLREGION)
377 DeleteObject32( wndPtr->hrgnUpdate );
378 wndPtr->hrgnUpdate = 0;
380 if (!hrgnUpdate) DeleteObject32( hrgn );
382 if (!wndPtr->hrgnUpdate) /* No more update region */
383 if (!(wndPtr->flags & WIN_INTERNAL_PAINT))
384 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
386 if (flags & RDW_NOFRAME) wndPtr->flags &= ~WIN_NEEDS_NCPAINT;
387 if (flags & RDW_NOERASE) wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
390 /* Set/clear internal paint flag */
392 if (flags & RDW_INTERNALPAINT)
394 if ( wndPtr->hrgnUpdate <= 1 && !(wndPtr->flags & WIN_INTERNAL_PAINT))
395 QUEUE_IncPaintCount( wndPtr->hmemTaskQ );
396 wndPtr->flags |= WIN_INTERNAL_PAINT;
398 else if (flags & RDW_NOINTERNALPAINT)
400 if ( wndPtr->hrgnUpdate <= 1 && (wndPtr->flags & WIN_INTERNAL_PAINT))
401 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
402 wndPtr->flags &= ~WIN_INTERNAL_PAINT;
405 /* Erase/update window */
407 if (flags & RDW_UPDATENOW)
409 if (wndPtr->hrgnUpdate) /* wm_painticon wparam is 1 */
410 SendMessage16( hwnd, (bIcon) ? WM_PAINTICON : WM_PAINT, bIcon, 0 );
412 else if (flags & RDW_ERASENOW)
414 if (wndPtr->flags & WIN_NEEDS_NCPAINT)
415 WIN_UpdateNCArea( wndPtr, FALSE);
417 if (wndPtr->flags & WIN_NEEDS_ERASEBKGND)
419 HDC32 hdc = GetDCEx32( hwnd, wndPtr->hrgnUpdate,
420 DCX_INTERSECTRGN | DCX_USESTYLE |
421 DCX_KEEPCLIPRGN | DCX_WINDOWPAINT |
422 (bIcon ? DCX_WINDOW : 0) );
423 if (hdc)
425 if (SendMessage16( hwnd, (bIcon) ? WM_ICONERASEBKGND
426 : WM_ERASEBKGND,
427 (WPARAM16)hdc, 0 ))
428 wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
429 ReleaseDC32( hwnd, hdc );
434 /* Recursively process children */
436 if (!(flags & RDW_NOCHILDREN) &&
437 ((flags & RDW_ALLCHILDREN) || !(wndPtr->dwStyle & WS_CLIPCHILDREN)) &&
438 !(wndPtr->dwStyle & WS_MINIMIZE) )
440 if ( hrgnUpdate || rectUpdate )
442 if (!(hrgn = CreateRectRgn32( 0, 0, 0, 0 ))) return TRUE;
443 if( !hrgnUpdate )
445 control |= (RDW_C_DELETEHRGN | RDW_C_USEHRGN);
446 if( !(hrgnUpdate = CreateRectRgnIndirect32( rectUpdate )) )
448 DeleteObject32( hrgn );
449 return TRUE;
452 if( (list = WIN_BuildWinArray( wndPtr, 0, NULL )) )
454 for (ppWnd = list; *ppWnd; ppWnd++)
456 wndPtr = *ppWnd;
457 if (!IsWindow32(wndPtr->hwndSelf)) continue;
458 if (wndPtr->dwStyle & WS_VISIBLE)
460 SetRectRgn32( hrgn,
461 wndPtr->rectWindow.left, wndPtr->rectWindow.top,
462 wndPtr->rectWindow.right, wndPtr->rectWindow.bottom );
463 if (CombineRgn32( hrgn, hrgn, hrgnUpdate, RGN_AND ))
465 OffsetRgn32( hrgn, -wndPtr->rectClient.left,
466 -wndPtr->rectClient.top );
467 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, hrgn, flags,
468 RDW_C_USEHRGN );
472 HeapFree( SystemHeap, 0, list );
474 DeleteObject32( hrgn );
475 if (control & RDW_C_DELETEHRGN) DeleteObject32( hrgnUpdate );
477 else
479 if( (list = WIN_BuildWinArray( wndPtr, 0, NULL )) )
481 for (ppWnd = list; *ppWnd; ppWnd++)
483 wndPtr = *ppWnd;
484 if (IsWindow32( wndPtr->hwndSelf ))
485 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0, flags, 0 );
487 HeapFree( SystemHeap, 0, list );
492 return TRUE;
496 /***********************************************************************
497 * RedrawWindow32 (USER32.426)
499 BOOL32 WINAPI RedrawWindow32( HWND32 hwnd, const RECT32 *rectUpdate,
500 HRGN32 hrgnUpdate, UINT32 flags )
502 return PAINT_RedrawWindow( hwnd, rectUpdate, hrgnUpdate, flags, 0 );
506 /***********************************************************************
507 * RedrawWindow16 (USER.290)
509 BOOL16 WINAPI RedrawWindow16( HWND16 hwnd, const RECT16 *rectUpdate,
510 HRGN16 hrgnUpdate, UINT16 flags )
512 if (rectUpdate)
514 RECT32 r;
515 CONV_RECT16TO32( rectUpdate, &r );
516 return (BOOL16)RedrawWindow32( (HWND32)hwnd, &r, hrgnUpdate, flags );
518 return (BOOL16)PAINT_RedrawWindow( (HWND32)hwnd, NULL,
519 (HRGN32)hrgnUpdate, flags, 0 );
523 /***********************************************************************
524 * UpdateWindow16 (USER.124)
526 void WINAPI UpdateWindow16( HWND16 hwnd )
528 PAINT_RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_NOCHILDREN, 0 );
531 /***********************************************************************
532 * UpdateWindow32 (USER32.567)
534 void WINAPI UpdateWindow32( HWND32 hwnd )
536 PAINT_RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_NOCHILDREN, 0 );
539 /***********************************************************************
540 * InvalidateRgn16 (USER.126)
542 void WINAPI InvalidateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
544 PAINT_RedrawWindow((HWND32)hwnd, NULL, (HRGN32)hrgn,
545 RDW_INVALIDATE | (erase ? RDW_ERASE : 0), 0 );
549 /***********************************************************************
550 * InvalidateRgn32 (USER32.329)
552 void WINAPI InvalidateRgn32( HWND32 hwnd, HRGN32 hrgn, BOOL32 erase )
554 PAINT_RedrawWindow(hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0), 0 );
558 /***********************************************************************
559 * InvalidateRect16 (USER.125)
561 void WINAPI InvalidateRect16( HWND16 hwnd, const RECT16 *rect, BOOL16 erase )
563 RedrawWindow16( hwnd, rect, 0, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
567 /***********************************************************************
568 * InvalidateRect32 (USER32.328)
570 void WINAPI InvalidateRect32( HWND32 hwnd, const RECT32 *rect, BOOL32 erase )
572 PAINT_RedrawWindow( hwnd, rect, 0,
573 RDW_INVALIDATE | (erase ? RDW_ERASE : 0), 0 );
577 /***********************************************************************
578 * ValidateRgn16 (USER.128)
580 void WINAPI ValidateRgn16( HWND16 hwnd, HRGN16 hrgn )
582 PAINT_RedrawWindow( (HWND32)hwnd, NULL, (HRGN32)hrgn,
583 RDW_VALIDATE | RDW_NOCHILDREN, 0 );
587 /***********************************************************************
588 * ValidateRgn32 (USER32.572)
590 void WINAPI ValidateRgn32( HWND32 hwnd, HRGN32 hrgn )
592 PAINT_RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOCHILDREN, 0 );
596 /***********************************************************************
597 * ValidateRect16 (USER.127)
599 void WINAPI ValidateRect16( HWND16 hwnd, const RECT16 *rect )
601 RedrawWindow16( hwnd, rect, 0, RDW_VALIDATE | RDW_NOCHILDREN );
605 /***********************************************************************
606 * ValidateRect32 (USER32.571)
608 void WINAPI ValidateRect32( HWND32 hwnd, const RECT32 *rect )
610 PAINT_RedrawWindow( hwnd, rect, 0, RDW_VALIDATE | RDW_NOCHILDREN, 0 );
614 /***********************************************************************
615 * GetUpdateRect16 (USER.190)
617 BOOL16 WINAPI GetUpdateRect16( HWND16 hwnd, LPRECT16 rect, BOOL16 erase )
619 RECT32 r;
620 BOOL16 ret;
622 if (!rect) return GetUpdateRect32( hwnd, NULL, erase );
623 ret = GetUpdateRect32( hwnd, &r, erase );
624 CONV_RECT32TO16( &r, rect );
625 return ret;
629 /***********************************************************************
630 * GetUpdateRect32 (USER32.297)
632 BOOL32 WINAPI GetUpdateRect32( HWND32 hwnd, LPRECT32 rect, BOOL32 erase )
634 WND * wndPtr = WIN_FindWndPtr( hwnd );
635 if (!wndPtr) return FALSE;
637 if (rect)
639 if (wndPtr->hrgnUpdate > 1)
641 HRGN32 hrgn = CreateRectRgn32( 0, 0, 0, 0 );
642 if (GetUpdateRgn32( hwnd, hrgn, erase ) == ERROR) return FALSE;
643 GetRgnBox32( hrgn, rect );
644 DeleteObject32( hrgn );
646 else SetRectEmpty32( rect );
648 return (wndPtr->hrgnUpdate > 1);
652 /***********************************************************************
653 * GetUpdateRgn16 (USER.237)
655 INT16 WINAPI GetUpdateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
657 return GetUpdateRgn32( hwnd, hrgn, erase );
661 /***********************************************************************
662 * GetUpdateRgn32 (USER32.298)
664 INT32 WINAPI GetUpdateRgn32( HWND32 hwnd, HRGN32 hrgn, BOOL32 erase )
666 INT32 retval;
667 WND * wndPtr = WIN_FindWndPtr( hwnd );
668 if (!wndPtr) return ERROR;
670 if (wndPtr->hrgnUpdate <= 1)
672 SetRectRgn32( hrgn, 0, 0, 0, 0 );
673 return NULLREGION;
675 retval = CombineRgn32( hrgn, wndPtr->hrgnUpdate, 0, RGN_COPY );
676 if (erase) RedrawWindow32( hwnd, NULL, 0, RDW_ERASENOW | RDW_NOCHILDREN );
677 return retval;
681 /***********************************************************************
682 * ExcludeUpdateRgn16 (USER.238)
684 INT16 WINAPI ExcludeUpdateRgn16( HDC16 hdc, HWND16 hwnd )
686 return ExcludeUpdateRgn32( hdc, hwnd );
690 /***********************************************************************
691 * ExcludeUpdateRgn32 (USER32.195)
693 INT32 WINAPI ExcludeUpdateRgn32( HDC32 hdc, HWND32 hwnd )
695 RECT32 rect;
696 WND * wndPtr;
698 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return ERROR;
700 if (wndPtr->hrgnUpdate)
702 INT32 ret;
703 HRGN32 hrgn = CreateRectRgn32(wndPtr->rectWindow.left - wndPtr->rectClient.left,
704 wndPtr->rectWindow.top - wndPtr->rectClient.top,
705 wndPtr->rectClient.right - wndPtr->rectClient.left,
706 wndPtr->rectClient.bottom - wndPtr->rectClient.top);
707 if( wndPtr->hrgnUpdate > 1 )
708 CombineRgn32(hrgn, wndPtr->hrgnUpdate, 0, RGN_COPY);
710 /* do ugly coordinate translations in dce.c */
712 ret = DCE_ExcludeRgn( hdc, wndPtr, hrgn );
713 DeleteObject32( hrgn );
714 return ret;
716 return GetClipBox32( hdc, &rect );