Release 980215
[wine.git] / windows / painting.c
blob9baba58eb4da9ea9ffc60cdddbe543ed698557b6
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 <stdio.h>
12 #include "win.h"
13 #include "queue.h"
14 #include "gdi.h"
15 #include "dce.h"
16 #include "heap.h"
17 #include "stddebug.h"
18 /* #define DEBUG_WIN */
19 #include "debug.h"
21 /* Last CTLCOLOR id */
22 #define CTLCOLOR_MAX CTLCOLOR_STATIC
24 /***********************************************************************
25 * WIN_UpdateNCArea
28 void WIN_UpdateNCArea(WND* wnd, BOOL32 bUpdate)
30 POINT16 pt = {0, 0};
31 HRGN32 hClip = 1;
33 dprintf_nonclient(stddeb,"NCUpdate: hwnd %04x, hrgnUpdate %04x\n",
34 wnd->hwndSelf, wnd->hrgnUpdate );
36 /* desktop window doesn't have nonclient area */
37 if(wnd == WIN_GetDesktop())
39 wnd->flags &= ~WIN_NEEDS_NCPAINT;
40 return;
43 if( wnd->hrgnUpdate > 1 )
45 ClientToScreen16(wnd->hwndSelf, &pt);
47 hClip = CreateRectRgn32( 0, 0, 0, 0 );
48 if (!CombineRgn32( hClip, wnd->hrgnUpdate, 0, RGN_COPY ))
50 DeleteObject32(hClip);
51 hClip = 1;
53 else
54 OffsetRgn32( hClip, pt.x, pt.y );
56 if (bUpdate)
58 /* exclude non-client area from update region */
59 HRGN32 hrgn = CreateRectRgn32( 0, 0,
60 wnd->rectClient.right - wnd->rectClient.left,
61 wnd->rectClient.bottom - wnd->rectClient.top);
63 if (hrgn && (CombineRgn32( wnd->hrgnUpdate, wnd->hrgnUpdate,
64 hrgn, RGN_AND) == NULLREGION))
66 DeleteObject32( wnd->hrgnUpdate );
67 wnd->hrgnUpdate = 1;
70 DeleteObject32( hrgn );
74 wnd->flags &= ~WIN_NEEDS_NCPAINT;
76 if ((wnd->hwndSelf == GetActiveWindow32()) &&
77 !(wnd->flags & WIN_NCACTIVATED))
79 wnd->flags |= WIN_NCACTIVATED;
80 if( hClip > 1) DeleteObject32( hClip );
81 hClip = 1;
84 if (hClip) SendMessage16( wnd->hwndSelf, WM_NCPAINT, hClip, 0L );
86 if (hClip > 1) DeleteObject32( hClip );
90 /***********************************************************************
91 * BeginPaint16 (USER.39)
93 HDC16 WINAPI BeginPaint16( HWND16 hwnd, LPPAINTSTRUCT16 lps )
95 BOOL32 bIcon;
96 HRGN32 hrgnUpdate;
97 WND *wndPtr = WIN_FindWndPtr( hwnd );
98 if (!wndPtr) return 0;
100 bIcon = (wndPtr->dwStyle & WS_MINIMIZE && wndPtr->class->hIcon);
102 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
104 if (wndPtr->flags & WIN_NEEDS_NCPAINT) WIN_UpdateNCArea( wndPtr, TRUE );
106 if (((hrgnUpdate = wndPtr->hrgnUpdate) != 0) ||
107 (wndPtr->flags & WIN_INTERNAL_PAINT))
108 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
110 wndPtr->hrgnUpdate = 0;
111 wndPtr->flags &= ~WIN_INTERNAL_PAINT;
113 HideCaret32( hwnd );
115 dprintf_win(stddeb,"hrgnUpdate = %04x, ", hrgnUpdate);
117 /* When bIcon is TRUE hrgnUpdate is automatically in window coordinates
118 * (because rectClient == rectWindow for WS_MINIMIZE windows).
121 if (wndPtr->class->style & CS_PARENTDC)
123 /* Don't clip the output to the update region for CS_PARENTDC window */
124 if(hrgnUpdate > 1)
125 DeleteObject32(hrgnUpdate);
126 lps->hdc = GetDCEx16( hwnd, 0, DCX_WINDOWPAINT | DCX_USESTYLE |
127 (bIcon ? DCX_WINDOW : 0) );
129 else
131 lps->hdc = GetDCEx16(hwnd, hrgnUpdate, DCX_INTERSECTRGN |
132 DCX_WINDOWPAINT | DCX_USESTYLE |
133 (bIcon ? DCX_WINDOW : 0) );
136 dprintf_win(stddeb,"hdc = %04x\n", lps->hdc);
138 if (!lps->hdc)
140 fprintf(stderr, "GetDCEx() failed in BeginPaint(), hwnd=%04x\n", hwnd);
141 return 0;
144 GetRgnBox16( InquireVisRgn(lps->hdc), &lps->rcPaint );
146 dprintf_win(stddeb,"box = (%i,%i - %i,%i)\n", lps->rcPaint.left, lps->rcPaint.top,
147 lps->rcPaint.right, lps->rcPaint.bottom );
149 DPtoLP16( lps->hdc, (LPPOINT16)&lps->rcPaint, 2 );
151 if (wndPtr->flags & WIN_NEEDS_ERASEBKGND)
153 wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
154 lps->fErase = !SendMessage16(hwnd, (bIcon) ? WM_ICONERASEBKGND
155 : WM_ERASEBKGND,
156 (WPARAM16)lps->hdc, 0 );
158 else lps->fErase = TRUE;
160 return lps->hdc;
164 /***********************************************************************
165 * BeginPaint32 (USER32.9)
167 HDC32 WINAPI BeginPaint32( HWND32 hwnd, PAINTSTRUCT32 *lps )
169 PAINTSTRUCT16 ps;
171 BeginPaint16( hwnd, &ps );
172 lps->hdc = (HDC32)ps.hdc;
173 lps->fErase = ps.fErase;
174 lps->rcPaint.top = ps.rcPaint.top;
175 lps->rcPaint.left = ps.rcPaint.left;
176 lps->rcPaint.right = ps.rcPaint.right;
177 lps->rcPaint.bottom = ps.rcPaint.bottom;
178 lps->fRestore = ps.fRestore;
179 lps->fIncUpdate = ps.fIncUpdate;
180 return lps->hdc;
184 /***********************************************************************
185 * EndPaint16 (USER.40)
187 BOOL16 WINAPI EndPaint16( HWND16 hwnd, const PAINTSTRUCT16* lps )
189 ReleaseDC16( hwnd, lps->hdc );
190 ShowCaret32( hwnd );
191 return TRUE;
195 /***********************************************************************
196 * EndPaint32 (USER32.175)
198 BOOL32 WINAPI EndPaint32( HWND32 hwnd, const PAINTSTRUCT32 *lps )
200 ReleaseDC32( hwnd, lps->hdc );
201 ShowCaret32( hwnd );
202 return TRUE;
206 /***********************************************************************
207 * FillWindow (USER.324)
209 void WINAPI FillWindow( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc, HBRUSH16 hbrush )
211 RECT16 rect;
212 GetClientRect16( hwnd, &rect );
213 DPtoLP16( hdc, (LPPOINT16)&rect, 2 );
214 PaintRect( hwndParent, hwnd, hdc, hbrush, &rect );
218 /***********************************************************************
219 * PAINT_GetControlBrush
221 static HBRUSH16 PAINT_GetControlBrush( HWND32 hParent, HWND32 hWnd, HDC16 hDC, UINT16 ctlType )
223 HBRUSH16 bkgBrush = (HBRUSH16)SendMessage32A( hParent, WM_CTLCOLORMSGBOX + ctlType,
224 (WPARAM32)hDC, (LPARAM)hWnd );
225 if( !IsGDIObject(bkgBrush) )
226 bkgBrush = DEFWND_ControlColor( hDC, ctlType );
227 return bkgBrush;
231 /***********************************************************************
232 * PaintRect (USER.325)
234 void WINAPI PaintRect( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc,
235 HBRUSH16 hbrush, const RECT16 *rect)
237 if( hbrush <= CTLCOLOR_MAX )
238 if( hwndParent )
239 hbrush = PAINT_GetControlBrush( hwndParent, hwnd, hdc, (UINT16)hbrush );
240 else
241 return;
242 if( hbrush )
243 FillRect16( hdc, rect, hbrush );
247 /***********************************************************************
248 * GetControlBrush (USER.326)
250 HBRUSH16 WINAPI GetControlBrush( HWND16 hwnd, HDC16 hdc, UINT16 ctlType )
252 WND* wndPtr = WIN_FindWndPtr( hwnd );
254 if((ctlType <= CTLCOLOR_MAX) && wndPtr )
256 WND* parent;
257 if( wndPtr->dwStyle & WS_POPUP ) parent = wndPtr->owner;
258 else parent = wndPtr->parent;
259 if( !parent ) parent = wndPtr;
260 return (HBRUSH16)PAINT_GetControlBrush( parent->hwndSelf, hwnd, hdc, ctlType );
262 return (HBRUSH16)0;
266 /***********************************************************************
267 * PAINT_RedrawWindow
269 * FIXME: Windows uses WM_SYNCPAINT to cut down the number of intertask
270 * SendMessage() calls. This is a comment inside DefWindowProc() source
271 * from 16-bit SDK:
273 * This message avoids lots of inter-app message traffic
274 * by switching to the other task and continuing the
275 * recursion there.
277 * wParam = flags
278 * LOWORD(lParam) = hrgnClip
279 * HIWORD(lParam) = hwndSkip (not used; always NULL)
281 * All in all, a prime candidate for a rewrite.
283 BOOL32 PAINT_RedrawWindow( HWND32 hwnd, const RECT32 *rectUpdate,
284 HRGN32 hrgnUpdate, UINT32 flags, UINT32 control )
286 BOOL32 bIcon;
287 HRGN32 hrgn;
288 RECT32 rectClient;
289 WND* wndPtr;
290 WND **list, **ppWnd;
292 if (!hwnd) hwnd = GetDesktopWindow32();
293 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
294 if (!WIN_IsWindowDrawable( wndPtr, !(flags & RDW_FRAME) ) )
295 return TRUE; /* No redraw needed */
297 bIcon = (wndPtr->dwStyle & WS_MINIMIZE && wndPtr->class->hIcon);
298 if (rectUpdate)
300 dprintf_win(stddeb, "RedrawWindow: %04x %d,%d-%d,%d %04x flags=%04x\n",
301 hwnd, rectUpdate->left, rectUpdate->top,
302 rectUpdate->right, rectUpdate->bottom, hrgnUpdate, flags );
304 else
306 dprintf_win(stddeb, "RedrawWindow: %04x NULL %04x flags=%04x\n",
307 hwnd, hrgnUpdate, flags);
310 GetClientRect32( hwnd, &rectClient );
312 if (flags & RDW_INVALIDATE) /* Invalidate */
314 int rgnNotEmpty = COMPLEXREGION;
316 if (wndPtr->hrgnUpdate > 1) /* Is there already an update region? */
318 if ((hrgn = hrgnUpdate) == 0)
319 hrgn = CreateRectRgnIndirect32( rectUpdate ? rectUpdate :
320 &rectClient );
321 rgnNotEmpty = CombineRgn32( wndPtr->hrgnUpdate, wndPtr->hrgnUpdate,
322 hrgn, RGN_OR );
323 if (!hrgnUpdate) DeleteObject32( hrgn );
325 else /* No update region yet */
327 if (!(wndPtr->flags & WIN_INTERNAL_PAINT))
328 QUEUE_IncPaintCount( wndPtr->hmemTaskQ );
329 if (hrgnUpdate)
331 wndPtr->hrgnUpdate = CreateRectRgn32( 0, 0, 0, 0 );
332 rgnNotEmpty = CombineRgn32( wndPtr->hrgnUpdate, hrgnUpdate,
333 0, RGN_COPY );
335 else wndPtr->hrgnUpdate = CreateRectRgnIndirect32( rectUpdate ?
336 rectUpdate : &rectClient );
339 if (flags & RDW_FRAME) wndPtr->flags |= WIN_NEEDS_NCPAINT;
341 /* restrict update region to client area (FIXME: correct?) */
342 if (wndPtr->hrgnUpdate)
344 HRGN32 clientRgn = CreateRectRgnIndirect32( &rectClient );
345 rgnNotEmpty = CombineRgn32( wndPtr->hrgnUpdate, clientRgn,
346 wndPtr->hrgnUpdate, RGN_AND );
347 DeleteObject32( clientRgn );
350 /* check for bogus update region */
351 if ( rgnNotEmpty == NULLREGION )
353 wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
354 DeleteObject32( wndPtr->hrgnUpdate );
355 wndPtr->hrgnUpdate=0;
356 if (!(wndPtr->flags & WIN_INTERNAL_PAINT))
357 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
359 else
360 if (flags & RDW_ERASE) wndPtr->flags |= WIN_NEEDS_ERASEBKGND;
361 flags |= RDW_FRAME; /* Force children frame invalidation */
363 else if (flags & RDW_VALIDATE) /* Validate */
365 /* We need an update region in order to validate anything */
366 if (wndPtr->hrgnUpdate > 1)
368 if (!hrgnUpdate && !rectUpdate)
370 /* Special case: validate everything */
371 DeleteObject32( wndPtr->hrgnUpdate );
372 wndPtr->hrgnUpdate = 0;
374 else
376 if ((hrgn = hrgnUpdate) == 0)
377 hrgn = CreateRectRgnIndirect32( rectUpdate );
378 if (CombineRgn32( wndPtr->hrgnUpdate, wndPtr->hrgnUpdate,
379 hrgn, RGN_DIFF ) == NULLREGION)
381 DeleteObject32( wndPtr->hrgnUpdate );
382 wndPtr->hrgnUpdate = 0;
384 if (!hrgnUpdate) DeleteObject32( hrgn );
386 if (!wndPtr->hrgnUpdate) /* No more update region */
387 if (!(wndPtr->flags & WIN_INTERNAL_PAINT))
388 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
390 if (flags & RDW_NOFRAME) wndPtr->flags &= ~WIN_NEEDS_NCPAINT;
391 if (flags & RDW_NOERASE) wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
394 /* Set/clear internal paint flag */
396 if (flags & RDW_INTERNALPAINT)
398 if ( wndPtr->hrgnUpdate <= 1 && !(wndPtr->flags & WIN_INTERNAL_PAINT))
399 QUEUE_IncPaintCount( wndPtr->hmemTaskQ );
400 wndPtr->flags |= WIN_INTERNAL_PAINT;
402 else if (flags & RDW_NOINTERNALPAINT)
404 if ( wndPtr->hrgnUpdate <= 1 && (wndPtr->flags & WIN_INTERNAL_PAINT))
405 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
406 wndPtr->flags &= ~WIN_INTERNAL_PAINT;
409 /* Erase/update window */
411 if (flags & RDW_UPDATENOW)
413 if (wndPtr->hrgnUpdate) /* wm_painticon wparam is 1 */
414 SendMessage16( hwnd, (bIcon) ? WM_PAINTICON : WM_PAINT, bIcon, 0 );
416 else if (flags & RDW_ERASENOW)
418 if (wndPtr->flags & WIN_NEEDS_NCPAINT)
419 WIN_UpdateNCArea( wndPtr, FALSE);
421 if (wndPtr->flags & WIN_NEEDS_ERASEBKGND)
423 HDC32 hdc = GetDCEx32( hwnd, wndPtr->hrgnUpdate,
424 DCX_INTERSECTRGN | DCX_USESTYLE |
425 DCX_KEEPCLIPRGN | DCX_WINDOWPAINT |
426 (bIcon ? DCX_WINDOW : 0) );
427 if (hdc)
429 if (SendMessage16( hwnd, (bIcon) ? WM_ICONERASEBKGND
430 : WM_ERASEBKGND,
431 (WPARAM16)hdc, 0 ))
432 wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
433 ReleaseDC32( hwnd, hdc );
438 /* Recursively process children */
440 if (!(flags & RDW_NOCHILDREN) &&
441 ((flags & RDW_ALLCHILDREN) || !(wndPtr->dwStyle & WS_CLIPCHILDREN)) &&
442 !(wndPtr->dwStyle & WS_MINIMIZE) )
444 if ( hrgnUpdate || rectUpdate )
446 if (!(hrgn = CreateRectRgn32( 0, 0, 0, 0 ))) return TRUE;
447 if( !hrgnUpdate )
449 control |= (RDW_C_DELETEHRGN | RDW_C_USEHRGN);
450 if( !(hrgnUpdate = CreateRectRgnIndirect32( rectUpdate )) )
452 DeleteObject32( hrgn );
453 return TRUE;
456 if( (list = WIN_BuildWinArray( wndPtr, 0, NULL )) )
458 for (ppWnd = list; *ppWnd; ppWnd++)
460 wndPtr = *ppWnd;
461 if (!IsWindow32(wndPtr->hwndSelf)) continue;
462 if (wndPtr->dwStyle & WS_VISIBLE)
464 SetRectRgn32( hrgn,
465 wndPtr->rectWindow.left, wndPtr->rectWindow.top,
466 wndPtr->rectWindow.right, wndPtr->rectWindow.bottom );
467 if (CombineRgn32( hrgn, hrgn, hrgnUpdate, RGN_AND ))
469 OffsetRgn32( hrgn, -wndPtr->rectClient.left,
470 -wndPtr->rectClient.top );
471 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, hrgn, flags,
472 RDW_C_USEHRGN );
476 HeapFree( SystemHeap, 0, list );
478 DeleteObject32( hrgn );
479 if (control & RDW_C_DELETEHRGN) DeleteObject32( hrgnUpdate );
481 else
483 if( (list = WIN_BuildWinArray( wndPtr, 0, NULL )) )
485 for (ppWnd = list; *ppWnd; ppWnd++)
487 wndPtr = *ppWnd;
488 if (IsWindow32( wndPtr->hwndSelf ))
489 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0, flags, 0 );
491 HeapFree( SystemHeap, 0, list );
496 return TRUE;
500 /***********************************************************************
501 * RedrawWindow32 (USER32.425)
503 BOOL32 WINAPI RedrawWindow32( HWND32 hwnd, const RECT32 *rectUpdate,
504 HRGN32 hrgnUpdate, UINT32 flags )
506 return PAINT_RedrawWindow( hwnd, rectUpdate, hrgnUpdate, flags, 0 );
510 /***********************************************************************
511 * RedrawWindow16 (USER.290)
513 BOOL16 WINAPI RedrawWindow16( HWND16 hwnd, const RECT16 *rectUpdate,
514 HRGN16 hrgnUpdate, UINT16 flags )
516 if (rectUpdate)
518 RECT32 r;
519 CONV_RECT16TO32( rectUpdate, &r );
520 return (BOOL16)RedrawWindow32( (HWND32)hwnd, &r, hrgnUpdate, flags );
522 return (BOOL16)PAINT_RedrawWindow( (HWND32)hwnd, NULL,
523 (HRGN32)hrgnUpdate, flags, 0 );
527 /***********************************************************************
528 * UpdateWindow16 (USER.124)
530 void WINAPI UpdateWindow16( HWND16 hwnd )
532 PAINT_RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_NOCHILDREN, 0 );
535 /***********************************************************************
536 * UpdateWindow32 (USER32.566)
538 void WINAPI UpdateWindow32( HWND32 hwnd )
540 PAINT_RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_NOCHILDREN, 0 );
543 /***********************************************************************
544 * InvalidateRgn16 (USER.126)
546 void WINAPI InvalidateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
548 PAINT_RedrawWindow((HWND32)hwnd, NULL, (HRGN32)hrgn,
549 RDW_INVALIDATE | (erase ? RDW_ERASE : 0), 0 );
553 /***********************************************************************
554 * InvalidateRgn32 (USER32.328)
556 void WINAPI InvalidateRgn32( HWND32 hwnd, HRGN32 hrgn, BOOL32 erase )
558 PAINT_RedrawWindow(hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0), 0 );
562 /***********************************************************************
563 * InvalidateRect16 (USER.125)
565 void WINAPI InvalidateRect16( HWND16 hwnd, const RECT16 *rect, BOOL16 erase )
567 RedrawWindow16( hwnd, rect, 0, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
571 /***********************************************************************
572 * InvalidateRect32 (USER32.327)
574 void WINAPI InvalidateRect32( HWND32 hwnd, const RECT32 *rect, BOOL32 erase )
576 PAINT_RedrawWindow( hwnd, rect, 0,
577 RDW_INVALIDATE | (erase ? RDW_ERASE : 0), 0 );
581 /***********************************************************************
582 * ValidateRgn16 (USER.128)
584 void WINAPI ValidateRgn16( HWND16 hwnd, HRGN16 hrgn )
586 PAINT_RedrawWindow( (HWND32)hwnd, NULL, (HRGN32)hrgn,
587 RDW_VALIDATE | RDW_NOCHILDREN, 0 );
591 /***********************************************************************
592 * ValidateRgn32 (USER32.571)
594 void WINAPI ValidateRgn32( HWND32 hwnd, HRGN32 hrgn )
596 PAINT_RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOCHILDREN, 0 );
600 /***********************************************************************
601 * ValidateRect16 (USER.127)
603 void WINAPI ValidateRect16( HWND16 hwnd, const RECT16 *rect )
605 RedrawWindow16( hwnd, rect, 0, RDW_VALIDATE | RDW_NOCHILDREN );
609 /***********************************************************************
610 * ValidateRect32 (USER32.570)
612 void WINAPI ValidateRect32( HWND32 hwnd, const RECT32 *rect )
614 PAINT_RedrawWindow( hwnd, rect, 0, RDW_VALIDATE | RDW_NOCHILDREN, 0 );
618 /***********************************************************************
619 * GetUpdateRect16 (USER.190)
621 BOOL16 WINAPI GetUpdateRect16( HWND16 hwnd, LPRECT16 rect, BOOL16 erase )
623 RECT32 r;
624 BOOL16 ret;
626 if (!rect) return GetUpdateRect32( hwnd, NULL, erase );
627 ret = GetUpdateRect32( hwnd, &r, erase );
628 CONV_RECT32TO16( &r, rect );
629 return ret;
633 /***********************************************************************
634 * GetUpdateRect32 (USER32.296)
636 BOOL32 WINAPI GetUpdateRect32( HWND32 hwnd, LPRECT32 rect, BOOL32 erase )
638 WND * wndPtr = WIN_FindWndPtr( hwnd );
639 if (!wndPtr) return FALSE;
641 if (rect)
643 if (wndPtr->hrgnUpdate > 1)
645 HRGN32 hrgn = CreateRectRgn32( 0, 0, 0, 0 );
646 if (GetUpdateRgn32( hwnd, hrgn, erase ) == ERROR) return FALSE;
647 GetRgnBox32( hrgn, rect );
648 DeleteObject32( hrgn );
650 else SetRectEmpty32( rect );
652 return (wndPtr->hrgnUpdate > 1);
656 /***********************************************************************
657 * GetUpdateRgn16 (USER.237)
659 INT16 WINAPI GetUpdateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
661 return GetUpdateRgn32( hwnd, hrgn, erase );
665 /***********************************************************************
666 * GetUpdateRgn32 (USER32.297)
668 INT32 WINAPI GetUpdateRgn32( HWND32 hwnd, HRGN32 hrgn, BOOL32 erase )
670 INT32 retval;
671 WND * wndPtr = WIN_FindWndPtr( hwnd );
672 if (!wndPtr) return ERROR;
674 if (wndPtr->hrgnUpdate <= 1)
676 SetRectRgn32( hrgn, 0, 0, 0, 0 );
677 return NULLREGION;
679 retval = CombineRgn32( hrgn, wndPtr->hrgnUpdate, 0, RGN_COPY );
680 if (erase) RedrawWindow32( hwnd, NULL, 0, RDW_ERASENOW | RDW_NOCHILDREN );
681 return retval;
685 /***********************************************************************
686 * ExcludeUpdateRgn16 (USER.238)
688 INT16 WINAPI ExcludeUpdateRgn16( HDC16 hdc, HWND16 hwnd )
690 return ExcludeUpdateRgn32( hdc, hwnd );
694 /***********************************************************************
695 * ExcludeUpdateRgn32 (USER32.194)
697 INT32 WINAPI ExcludeUpdateRgn32( HDC32 hdc, HWND32 hwnd )
699 RECT32 rect;
700 WND * wndPtr;
702 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return ERROR;
704 if (wndPtr->hrgnUpdate)
706 INT32 ret;
707 HRGN32 hrgn = CreateRectRgn32(wndPtr->rectWindow.left - wndPtr->rectClient.left,
708 wndPtr->rectWindow.top - wndPtr->rectClient.top,
709 wndPtr->rectClient.right - wndPtr->rectClient.left,
710 wndPtr->rectClient.bottom - wndPtr->rectClient.top);
711 if( wndPtr->hrgnUpdate > 1 )
712 CombineRgn32(hrgn, wndPtr->hrgnUpdate, 0, RGN_COPY);
714 /* do ugly coordinate translations in dce.c */
716 ret = DCE_ExcludeRgn( hdc, wndPtr, hrgn );
717 DeleteObject32( hrgn );
718 return ret;
720 return GetClipBox32( hdc, &rect );