Fixed bug in CreateFileMapping when name is not NULL.
[wine/multimedia.git] / windows / painting.c
blobc099835c2625f52f8658bc3d71f5b0aaea97c57c
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"
17 #include "wine/winuser16.h"
19 /* Last CTLCOLOR id */
20 #define CTLCOLOR_MAX CTLCOLOR_STATIC
22 /***********************************************************************
23 * WIN_UpdateNCArea
26 void WIN_UpdateNCArea(WND* wnd, BOOL32 bUpdate)
28 POINT16 pt = {0, 0};
29 HRGN32 hClip = 1;
31 TRACE(nonclient,"hwnd %04x, hrgnUpdate %04x\n",
32 wnd->hwndSelf, wnd->hrgnUpdate );
34 /* desktop window doesn't have nonclient area */
35 if(wnd == WIN_GetDesktop())
37 wnd->flags &= ~WIN_NEEDS_NCPAINT;
38 return;
41 if( wnd->hrgnUpdate > 1 )
43 ClientToScreen16(wnd->hwndSelf, &pt);
45 hClip = CreateRectRgn32( 0, 0, 0, 0 );
46 if (!CombineRgn32( hClip, wnd->hrgnUpdate, 0, RGN_COPY ))
48 DeleteObject32(hClip);
49 hClip = 1;
51 else
52 OffsetRgn32( hClip, pt.x, pt.y );
54 if (bUpdate)
56 /* exclude non-client area from update region */
57 HRGN32 hrgn = CreateRectRgn32( 0, 0,
58 wnd->rectClient.right - wnd->rectClient.left,
59 wnd->rectClient.bottom - wnd->rectClient.top);
61 if (hrgn && (CombineRgn32( wnd->hrgnUpdate, wnd->hrgnUpdate,
62 hrgn, RGN_AND) == NULLREGION))
64 DeleteObject32( wnd->hrgnUpdate );
65 wnd->hrgnUpdate = 1;
68 DeleteObject32( hrgn );
72 wnd->flags &= ~WIN_NEEDS_NCPAINT;
74 if ((wnd->hwndSelf == GetActiveWindow32()) &&
75 !(wnd->flags & WIN_NCACTIVATED))
77 wnd->flags |= WIN_NCACTIVATED;
78 if( hClip > 1) DeleteObject32( hClip );
79 hClip = 1;
82 if (hClip) SendMessage16( wnd->hwndSelf, WM_NCPAINT, hClip, 0L );
84 if (hClip > 1) DeleteObject32( hClip );
88 /***********************************************************************
89 * BeginPaint16 (USER.39)
91 HDC16 WINAPI BeginPaint16( HWND16 hwnd, LPPAINTSTRUCT16 lps )
93 BOOL32 bIcon;
94 HRGN32 hrgnUpdate;
95 WND *wndPtr = WIN_FindWndPtr( hwnd );
96 if (!wndPtr) return 0;
98 bIcon = (wndPtr->dwStyle & WS_MINIMIZE && wndPtr->class->hIcon);
100 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
102 if (wndPtr->flags & WIN_NEEDS_NCPAINT) WIN_UpdateNCArea( wndPtr, TRUE );
104 if (((hrgnUpdate = wndPtr->hrgnUpdate) != 0) ||
105 (wndPtr->flags & WIN_INTERNAL_PAINT))
106 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
108 wndPtr->hrgnUpdate = 0;
109 wndPtr->flags &= ~WIN_INTERNAL_PAINT;
111 HideCaret32( hwnd );
113 TRACE(win,"hrgnUpdate = %04x, \n", hrgnUpdate);
115 /* When bIcon is TRUE hrgnUpdate is automatically in window coordinates
116 * (because rectClient == rectWindow for WS_MINIMIZE windows).
119 if (wndPtr->class->style & CS_PARENTDC)
121 /* Don't clip the output to the update region for CS_PARENTDC window */
122 if(hrgnUpdate > 1)
123 DeleteObject32(hrgnUpdate);
124 lps->hdc = GetDCEx16( hwnd, 0, DCX_WINDOWPAINT | DCX_USESTYLE |
125 (bIcon ? DCX_WINDOW : 0) );
127 else
129 lps->hdc = GetDCEx16(hwnd, hrgnUpdate, DCX_INTERSECTRGN |
130 DCX_WINDOWPAINT | DCX_USESTYLE |
131 (bIcon ? DCX_WINDOW : 0) );
134 TRACE(win,"hdc = %04x\n", lps->hdc);
136 if (!lps->hdc)
138 WARN(win, "GetDCEx() failed in BeginPaint(), hwnd=%04x\n", hwnd);
139 return 0;
142 GetClipBox16( lps->hdc, &lps->rcPaint );
144 TRACE(win,"box = (%i,%i - %i,%i)\n", lps->rcPaint.left, lps->rcPaint.top,
145 lps->rcPaint.right, lps->rcPaint.bottom );
147 if (wndPtr->flags & WIN_NEEDS_ERASEBKGND)
149 wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
150 lps->fErase = !SendMessage16(hwnd, (bIcon) ? WM_ICONERASEBKGND
151 : WM_ERASEBKGND,
152 (WPARAM16)lps->hdc, 0 );
154 else lps->fErase = TRUE;
156 return lps->hdc;
160 /***********************************************************************
161 * BeginPaint32 (USER32.10)
163 HDC32 WINAPI BeginPaint32( HWND32 hwnd, PAINTSTRUCT32 *lps )
165 PAINTSTRUCT16 ps;
167 BeginPaint16( hwnd, &ps );
168 lps->hdc = (HDC32)ps.hdc;
169 lps->fErase = ps.fErase;
170 lps->rcPaint.top = ps.rcPaint.top;
171 lps->rcPaint.left = ps.rcPaint.left;
172 lps->rcPaint.right = ps.rcPaint.right;
173 lps->rcPaint.bottom = ps.rcPaint.bottom;
174 lps->fRestore = ps.fRestore;
175 lps->fIncUpdate = ps.fIncUpdate;
176 return lps->hdc;
180 /***********************************************************************
181 * EndPaint16 (USER.40)
183 BOOL16 WINAPI EndPaint16( HWND16 hwnd, const PAINTSTRUCT16* lps )
185 ReleaseDC16( hwnd, lps->hdc );
186 ShowCaret32( hwnd );
187 return TRUE;
191 /***********************************************************************
192 * EndPaint32 (USER32.176)
194 BOOL32 WINAPI EndPaint32( HWND32 hwnd, const PAINTSTRUCT32 *lps )
196 ReleaseDC32( hwnd, lps->hdc );
197 ShowCaret32( hwnd );
198 return TRUE;
202 /***********************************************************************
203 * FillWindow (USER.324)
205 void WINAPI FillWindow( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc, HBRUSH16 hbrush )
207 RECT16 rect;
208 GetClientRect16( hwnd, &rect );
209 DPtoLP16( hdc, (LPPOINT16)&rect, 2 );
210 PaintRect( hwndParent, hwnd, hdc, hbrush, &rect );
214 /***********************************************************************
215 * PAINT_GetControlBrush
217 static HBRUSH16 PAINT_GetControlBrush( HWND32 hParent, HWND32 hWnd, HDC16 hDC, UINT16 ctlType )
219 HBRUSH16 bkgBrush = (HBRUSH16)SendMessage32A( hParent, WM_CTLCOLORMSGBOX + ctlType,
220 (WPARAM32)hDC, (LPARAM)hWnd );
221 if( !IsGDIObject(bkgBrush) )
222 bkgBrush = DEFWND_ControlColor( hDC, ctlType );
223 return bkgBrush;
227 /***********************************************************************
228 * PaintRect (USER.325)
230 void WINAPI PaintRect( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc,
231 HBRUSH16 hbrush, const RECT16 *rect)
233 if( hbrush <= CTLCOLOR_MAX )
235 if( hwndParent )
236 hbrush = PAINT_GetControlBrush( hwndParent, hwnd, hdc, (UINT16)hbrush );
237 else
238 return;
240 if( hbrush )
241 FillRect16( hdc, rect, hbrush );
245 /***********************************************************************
246 * GetControlBrush (USER.326)
248 HBRUSH16 WINAPI GetControlBrush( HWND16 hwnd, HDC16 hdc, UINT16 ctlType )
250 WND* wndPtr = WIN_FindWndPtr( hwnd );
252 if((ctlType <= CTLCOLOR_MAX) && wndPtr )
254 WND* parent;
255 if( wndPtr->dwStyle & WS_POPUP ) parent = wndPtr->owner;
256 else parent = wndPtr->parent;
257 if( !parent ) parent = wndPtr;
258 return (HBRUSH16)PAINT_GetControlBrush( parent->hwndSelf, hwnd, hdc, ctlType );
260 return (HBRUSH16)0;
264 /***********************************************************************
265 * PAINT_RedrawWindow
267 * FIXME: Windows uses WM_SYNCPAINT to cut down the number of intertask
268 * SendMessage() calls. This is a comment inside DefWindowProc() source
269 * from 16-bit SDK:
271 * This message avoids lots of inter-app message traffic
272 * by switching to the other task and continuing the
273 * recursion there.
275 * wParam = flags
276 * LOWORD(lParam) = hrgnClip
277 * HIWORD(lParam) = hwndSkip (not used; always NULL)
279 * All in all, a prime candidate for a rewrite.
281 BOOL32 PAINT_RedrawWindow( HWND32 hwnd, const RECT32 *rectUpdate,
282 HRGN32 hrgnUpdate, UINT32 flags, UINT32 control )
284 BOOL32 bIcon;
285 HRGN32 hrgn;
286 RECT32 rectClient;
287 WND* wndPtr;
288 WND **list, **ppWnd;
290 if (!hwnd) hwnd = GetDesktopWindow32();
291 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
292 if (!WIN_IsWindowDrawable( wndPtr, !(flags & RDW_FRAME) ) )
293 return TRUE; /* No redraw needed */
295 bIcon = (wndPtr->dwStyle & WS_MINIMIZE && wndPtr->class->hIcon);
296 if (rectUpdate)
298 TRACE(win, "%04x %d,%d-%d,%d %04x flags=%04x\n",
299 hwnd, rectUpdate->left, rectUpdate->top,
300 rectUpdate->right, rectUpdate->bottom, hrgnUpdate, flags );
302 else
304 TRACE(win, "%04x NULL %04x flags=%04x\n", hwnd, hrgnUpdate, flags);
307 GetClientRect32( hwnd, &rectClient );
309 if (flags & RDW_INVALIDATE) /* Invalidate */
311 int rgnNotEmpty = COMPLEXREGION;
313 if (wndPtr->hrgnUpdate > 1) /* Is there already an update region? */
315 if ((hrgn = hrgnUpdate) == 0)
316 hrgn = CreateRectRgnIndirect32( rectUpdate ? rectUpdate :
317 &rectClient );
318 rgnNotEmpty = CombineRgn32( wndPtr->hrgnUpdate, wndPtr->hrgnUpdate,
319 hrgn, RGN_OR );
320 if (!hrgnUpdate) DeleteObject32( hrgn );
322 else /* No update region yet */
324 if (!(wndPtr->flags & WIN_INTERNAL_PAINT))
325 QUEUE_IncPaintCount( wndPtr->hmemTaskQ );
326 if (hrgnUpdate)
328 wndPtr->hrgnUpdate = CreateRectRgn32( 0, 0, 0, 0 );
329 rgnNotEmpty = CombineRgn32( wndPtr->hrgnUpdate, hrgnUpdate,
330 0, RGN_COPY );
332 else wndPtr->hrgnUpdate = CreateRectRgnIndirect32( rectUpdate ?
333 rectUpdate : &rectClient );
336 if (flags & RDW_FRAME) wndPtr->flags |= WIN_NEEDS_NCPAINT;
338 /* restrict update region to client area (FIXME: correct?) */
339 if (wndPtr->hrgnUpdate)
341 HRGN32 clientRgn = CreateRectRgnIndirect32( &rectClient );
342 rgnNotEmpty = CombineRgn32( wndPtr->hrgnUpdate, clientRgn,
343 wndPtr->hrgnUpdate, RGN_AND );
344 DeleteObject32( clientRgn );
347 /* check for bogus update region */
348 if ( rgnNotEmpty == NULLREGION )
350 wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
351 DeleteObject32( wndPtr->hrgnUpdate );
352 wndPtr->hrgnUpdate=0;
353 if (!(wndPtr->flags & WIN_INTERNAL_PAINT))
354 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
356 else
357 if (flags & RDW_ERASE) wndPtr->flags |= WIN_NEEDS_ERASEBKGND;
358 flags |= RDW_FRAME; /* Force children frame invalidation */
360 else if (flags & RDW_VALIDATE) /* Validate */
362 /* We need an update region in order to validate anything */
363 if (wndPtr->hrgnUpdate > 1)
365 if (!hrgnUpdate && !rectUpdate)
367 /* Special case: validate everything */
368 DeleteObject32( wndPtr->hrgnUpdate );
369 wndPtr->hrgnUpdate = 0;
371 else
373 if ((hrgn = hrgnUpdate) == 0)
374 hrgn = CreateRectRgnIndirect32( rectUpdate );
375 if (CombineRgn32( wndPtr->hrgnUpdate, wndPtr->hrgnUpdate,
376 hrgn, RGN_DIFF ) == NULLREGION)
378 DeleteObject32( wndPtr->hrgnUpdate );
379 wndPtr->hrgnUpdate = 0;
381 if (!hrgnUpdate) DeleteObject32( hrgn );
383 if (!wndPtr->hrgnUpdate) /* No more update region */
384 if (!(wndPtr->flags & WIN_INTERNAL_PAINT))
385 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
387 if (flags & RDW_NOFRAME) wndPtr->flags &= ~WIN_NEEDS_NCPAINT;
388 if (flags & RDW_NOERASE) wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
391 /* Set/clear internal paint flag */
393 if (flags & RDW_INTERNALPAINT)
395 if ( wndPtr->hrgnUpdate <= 1 && !(wndPtr->flags & WIN_INTERNAL_PAINT))
396 QUEUE_IncPaintCount( wndPtr->hmemTaskQ );
397 wndPtr->flags |= WIN_INTERNAL_PAINT;
399 else if (flags & RDW_NOINTERNALPAINT)
401 if ( wndPtr->hrgnUpdate <= 1 && (wndPtr->flags & WIN_INTERNAL_PAINT))
402 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
403 wndPtr->flags &= ~WIN_INTERNAL_PAINT;
406 /* Erase/update window */
408 if (flags & RDW_UPDATENOW)
410 if (wndPtr->hrgnUpdate) /* wm_painticon wparam is 1 */
411 SendMessage16( hwnd, (bIcon) ? WM_PAINTICON : WM_PAINT, bIcon, 0 );
413 else if (flags & RDW_ERASENOW)
415 if (wndPtr->flags & WIN_NEEDS_NCPAINT)
416 WIN_UpdateNCArea( wndPtr, FALSE);
418 if (wndPtr->flags & WIN_NEEDS_ERASEBKGND)
420 HDC32 hdc = GetDCEx32( hwnd, wndPtr->hrgnUpdate,
421 DCX_INTERSECTRGN | DCX_USESTYLE |
422 DCX_KEEPCLIPRGN | DCX_WINDOWPAINT |
423 (bIcon ? DCX_WINDOW : 0) );
424 if (hdc)
426 if (SendMessage16( hwnd, (bIcon) ? WM_ICONERASEBKGND
427 : WM_ERASEBKGND,
428 (WPARAM16)hdc, 0 ))
429 wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
430 ReleaseDC32( hwnd, hdc );
435 /* Recursively process children */
437 if (!(flags & RDW_NOCHILDREN) &&
438 ((flags & RDW_ALLCHILDREN) || !(wndPtr->dwStyle & WS_CLIPCHILDREN)) &&
439 !(wndPtr->dwStyle & WS_MINIMIZE) )
441 if ( hrgnUpdate || rectUpdate )
443 if (!(hrgn = CreateRectRgn32( 0, 0, 0, 0 ))) return TRUE;
444 if( !hrgnUpdate )
446 control |= (RDW_C_DELETEHRGN | RDW_C_USEHRGN);
447 if( !(hrgnUpdate = CreateRectRgnIndirect32( rectUpdate )) )
449 DeleteObject32( hrgn );
450 return TRUE;
453 if( (list = WIN_BuildWinArray( wndPtr, 0, NULL )) )
455 for (ppWnd = list; *ppWnd; ppWnd++)
457 wndPtr = *ppWnd;
458 if (!IsWindow32(wndPtr->hwndSelf)) continue;
459 if (wndPtr->dwStyle & WS_VISIBLE)
461 SetRectRgn32( hrgn,
462 wndPtr->rectWindow.left, wndPtr->rectWindow.top,
463 wndPtr->rectWindow.right, wndPtr->rectWindow.bottom );
464 if (CombineRgn32( hrgn, hrgn, hrgnUpdate, RGN_AND ))
466 OffsetRgn32( hrgn, -wndPtr->rectClient.left,
467 -wndPtr->rectClient.top );
468 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, hrgn, flags,
469 RDW_C_USEHRGN );
473 HeapFree( SystemHeap, 0, list );
475 DeleteObject32( hrgn );
476 if (control & RDW_C_DELETEHRGN) DeleteObject32( hrgnUpdate );
478 else
480 if( (list = WIN_BuildWinArray( wndPtr, 0, NULL )) )
482 for (ppWnd = list; *ppWnd; ppWnd++)
484 wndPtr = *ppWnd;
485 if (IsWindow32( wndPtr->hwndSelf ))
486 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0, flags, 0 );
488 HeapFree( SystemHeap, 0, list );
493 return TRUE;
497 /***********************************************************************
498 * RedrawWindow32 (USER32.426)
500 BOOL32 WINAPI RedrawWindow32( HWND32 hwnd, const RECT32 *rectUpdate,
501 HRGN32 hrgnUpdate, UINT32 flags )
503 return PAINT_RedrawWindow( hwnd, rectUpdate, hrgnUpdate, flags, 0 );
507 /***********************************************************************
508 * RedrawWindow16 (USER.290)
510 BOOL16 WINAPI RedrawWindow16( HWND16 hwnd, const RECT16 *rectUpdate,
511 HRGN16 hrgnUpdate, UINT16 flags )
513 if (rectUpdate)
515 RECT32 r;
516 CONV_RECT16TO32( rectUpdate, &r );
517 return (BOOL16)RedrawWindow32( (HWND32)hwnd, &r, hrgnUpdate, flags );
519 return (BOOL16)PAINT_RedrawWindow( (HWND32)hwnd, NULL,
520 (HRGN32)hrgnUpdate, flags, 0 );
524 /***********************************************************************
525 * UpdateWindow16 (USER.124)
527 void WINAPI UpdateWindow16( HWND16 hwnd )
529 PAINT_RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_NOCHILDREN, 0 );
532 /***********************************************************************
533 * UpdateWindow32 (USER32.567)
535 void WINAPI UpdateWindow32( HWND32 hwnd )
537 PAINT_RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_NOCHILDREN, 0 );
540 /***********************************************************************
541 * InvalidateRgn16 (USER.126)
543 void WINAPI InvalidateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
545 PAINT_RedrawWindow((HWND32)hwnd, NULL, (HRGN32)hrgn,
546 RDW_INVALIDATE | (erase ? RDW_ERASE : 0), 0 );
550 /***********************************************************************
551 * InvalidateRgn32 (USER32.329)
553 void WINAPI InvalidateRgn32( HWND32 hwnd, HRGN32 hrgn, BOOL32 erase )
555 PAINT_RedrawWindow(hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0), 0 );
559 /***********************************************************************
560 * InvalidateRect16 (USER.125)
562 void WINAPI InvalidateRect16( HWND16 hwnd, const RECT16 *rect, BOOL16 erase )
564 RedrawWindow16( hwnd, rect, 0, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
568 /***********************************************************************
569 * InvalidateRect32 (USER32.328)
571 void WINAPI InvalidateRect32( HWND32 hwnd, const RECT32 *rect, BOOL32 erase )
573 PAINT_RedrawWindow( hwnd, rect, 0,
574 RDW_INVALIDATE | (erase ? RDW_ERASE : 0), 0 );
578 /***********************************************************************
579 * ValidateRgn16 (USER.128)
581 void WINAPI ValidateRgn16( HWND16 hwnd, HRGN16 hrgn )
583 PAINT_RedrawWindow( (HWND32)hwnd, NULL, (HRGN32)hrgn,
584 RDW_VALIDATE | RDW_NOCHILDREN, 0 );
588 /***********************************************************************
589 * ValidateRgn32 (USER32.572)
591 void WINAPI ValidateRgn32( HWND32 hwnd, HRGN32 hrgn )
593 PAINT_RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOCHILDREN, 0 );
597 /***********************************************************************
598 * ValidateRect16 (USER.127)
600 void WINAPI ValidateRect16( HWND16 hwnd, const RECT16 *rect )
602 RedrawWindow16( hwnd, rect, 0, RDW_VALIDATE | RDW_NOCHILDREN );
606 /***********************************************************************
607 * ValidateRect32 (USER32.571)
609 void WINAPI ValidateRect32( HWND32 hwnd, const RECT32 *rect )
611 PAINT_RedrawWindow( hwnd, rect, 0, RDW_VALIDATE | RDW_NOCHILDREN, 0 );
615 /***********************************************************************
616 * GetUpdateRect16 (USER.190)
618 BOOL16 WINAPI GetUpdateRect16( HWND16 hwnd, LPRECT16 rect, BOOL16 erase )
620 RECT32 r;
621 BOOL16 ret;
623 if (!rect) return GetUpdateRect32( hwnd, NULL, erase );
624 ret = GetUpdateRect32( hwnd, &r, erase );
625 CONV_RECT32TO16( &r, rect );
626 return ret;
630 /***********************************************************************
631 * GetUpdateRect32 (USER32.297)
633 BOOL32 WINAPI GetUpdateRect32( HWND32 hwnd, LPRECT32 rect, BOOL32 erase )
635 WND * wndPtr = WIN_FindWndPtr( hwnd );
636 if (!wndPtr) return FALSE;
638 if (rect)
640 if (wndPtr->hrgnUpdate > 1)
642 HRGN32 hrgn = CreateRectRgn32( 0, 0, 0, 0 );
643 if (GetUpdateRgn32( hwnd, hrgn, erase ) == ERROR) return FALSE;
644 GetRgnBox32( hrgn, rect );
645 DeleteObject32( hrgn );
647 else SetRectEmpty32( rect );
649 return (wndPtr->hrgnUpdate > 1);
653 /***********************************************************************
654 * GetUpdateRgn16 (USER.237)
656 INT16 WINAPI GetUpdateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
658 return GetUpdateRgn32( hwnd, hrgn, erase );
662 /***********************************************************************
663 * GetUpdateRgn32 (USER32.298)
665 INT32 WINAPI GetUpdateRgn32( HWND32 hwnd, HRGN32 hrgn, BOOL32 erase )
667 INT32 retval;
668 WND * wndPtr = WIN_FindWndPtr( hwnd );
669 if (!wndPtr) return ERROR;
671 if (wndPtr->hrgnUpdate <= 1)
673 SetRectRgn32( hrgn, 0, 0, 0, 0 );
674 return NULLREGION;
676 retval = CombineRgn32( hrgn, wndPtr->hrgnUpdate, 0, RGN_COPY );
677 if (erase) RedrawWindow32( hwnd, NULL, 0, RDW_ERASENOW | RDW_NOCHILDREN );
678 return retval;
682 /***********************************************************************
683 * ExcludeUpdateRgn16 (USER.238)
685 INT16 WINAPI ExcludeUpdateRgn16( HDC16 hdc, HWND16 hwnd )
687 return ExcludeUpdateRgn32( hdc, hwnd );
691 /***********************************************************************
692 * ExcludeUpdateRgn32 (USER32.195)
694 INT32 WINAPI ExcludeUpdateRgn32( HDC32 hdc, HWND32 hwnd )
696 RECT32 rect;
697 WND * wndPtr;
699 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return ERROR;
701 if (wndPtr->hrgnUpdate)
703 INT32 ret;
704 HRGN32 hrgn = CreateRectRgn32(wndPtr->rectWindow.left - wndPtr->rectClient.left,
705 wndPtr->rectWindow.top - wndPtr->rectClient.top,
706 wndPtr->rectClient.right - wndPtr->rectClient.left,
707 wndPtr->rectClient.bottom - wndPtr->rectClient.top);
708 if( wndPtr->hrgnUpdate > 1 )
709 CombineRgn32(hrgn, wndPtr->hrgnUpdate, 0, RGN_COPY);
711 /* do ugly coordinate translations in dce.c */
713 ret = DCE_ExcludeRgn( hdc, wndPtr, hrgn );
714 DeleteObject32( hrgn );
715 return ret;
717 return GetClipBox32( hdc, &rect );