Removed the chop command that was there to get rid of dos ^M.
[wine/dcerpc.git] / windows / painting.c
blob3eb9f99e871a43697f666ed479fe6c8e6566a068
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 "dce.h"
14 #include "heap.h"
15 #include "debug.h"
16 #include "wine/winuser16.h"
18 /* Last CTLCOLOR id */
19 #define CTLCOLOR_MAX CTLCOLOR_STATIC
21 /***********************************************************************
22 * WIN_UpdateNCArea
25 void WIN_UpdateNCArea(WND* wnd, BOOL bUpdate)
27 POINT16 pt = {0, 0};
28 HRGN 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 WIN_ReleaseDesktop();
38 return;
40 WIN_ReleaseDesktop();
42 if( wnd->hrgnUpdate > 1 )
44 ClientToScreen16(wnd->hwndSelf, &pt);
46 hClip = CreateRectRgn( 0, 0, 0, 0 );
47 if (!CombineRgn( hClip, wnd->hrgnUpdate, 0, RGN_COPY ))
49 DeleteObject(hClip);
50 hClip = 1;
52 else
53 OffsetRgn( hClip, pt.x, pt.y );
55 if (bUpdate)
57 /* exclude non-client area from update region */
58 HRGN hrgn = CreateRectRgn( 0, 0,
59 wnd->rectClient.right - wnd->rectClient.left,
60 wnd->rectClient.bottom - wnd->rectClient.top);
62 if (hrgn && (CombineRgn( wnd->hrgnUpdate, wnd->hrgnUpdate,
63 hrgn, RGN_AND) == NULLREGION))
65 DeleteObject( wnd->hrgnUpdate );
66 wnd->hrgnUpdate = 1;
69 DeleteObject( hrgn );
73 wnd->flags &= ~WIN_NEEDS_NCPAINT;
75 if ((wnd->hwndSelf == GetActiveWindow()) &&
76 !(wnd->flags & WIN_NCACTIVATED))
78 wnd->flags |= WIN_NCACTIVATED;
79 if( hClip > 1) DeleteObject( hClip );
80 hClip = 1;
83 if (hClip) SendMessage16( wnd->hwndSelf, WM_NCPAINT, hClip, 0L );
85 if (hClip > 1) DeleteObject( hClip );
89 /***********************************************************************
90 * BeginPaint16 (USER.39)
92 HDC16 WINAPI BeginPaint16( HWND16 hwnd, LPPAINTSTRUCT16 lps )
94 BOOL bIcon;
95 HRGN hrgnUpdate;
96 WND *wndPtr = WIN_FindWndPtr( hwnd );
97 if (!wndPtr) return 0;
99 bIcon = (wndPtr->dwStyle & WS_MINIMIZE && wndPtr->class->hIcon);
101 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
103 if (wndPtr->flags & WIN_NEEDS_NCPAINT) WIN_UpdateNCArea( wndPtr, TRUE );
105 if (((hrgnUpdate = wndPtr->hrgnUpdate) != 0) ||
106 (wndPtr->flags & WIN_INTERNAL_PAINT))
107 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
109 wndPtr->hrgnUpdate = 0;
110 wndPtr->flags &= ~WIN_INTERNAL_PAINT;
112 HideCaret( hwnd );
114 TRACE(win,"hrgnUpdate = %04x, \n", hrgnUpdate);
116 /* When bIcon is TRUE hrgnUpdate is automatically in window coordinates
117 * (because rectClient == rectWindow for WS_MINIMIZE windows).
120 if (wndPtr->class->style & CS_PARENTDC)
122 /* Don't clip the output to the update region for CS_PARENTDC window */
123 if(hrgnUpdate > 1)
124 DeleteObject(hrgnUpdate);
125 lps->hdc = GetDCEx16( hwnd, 0, DCX_WINDOWPAINT | DCX_USESTYLE |
126 (bIcon ? DCX_WINDOW : 0) );
128 else
130 lps->hdc = GetDCEx16(hwnd, hrgnUpdate, DCX_INTERSECTRGN |
131 DCX_WINDOWPAINT | DCX_USESTYLE |
132 (bIcon ? DCX_WINDOW : 0) );
135 TRACE(win,"hdc = %04x\n", lps->hdc);
137 if (!lps->hdc)
139 WARN(win, "GetDCEx() failed in BeginPaint(), hwnd=%04x\n", hwnd);
140 WIN_ReleaseWndPtr(wndPtr);
141 return 0;
144 GetClipBox16( lps->hdc, &lps->rcPaint );
146 TRACE(win,"box = (%i,%i - %i,%i)\n", lps->rcPaint.left, lps->rcPaint.top,
147 lps->rcPaint.right, lps->rcPaint.bottom );
149 if (wndPtr->flags & WIN_NEEDS_ERASEBKGND)
151 wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
152 lps->fErase = !SendMessage16(hwnd, (bIcon) ? WM_ICONERASEBKGND
153 : WM_ERASEBKGND,
154 (WPARAM16)lps->hdc, 0 );
156 else lps->fErase = TRUE;
158 WIN_ReleaseWndPtr(wndPtr);
159 return lps->hdc;
163 /***********************************************************************
164 * BeginPaint32 (USER32.10)
166 HDC WINAPI BeginPaint( HWND hwnd, PAINTSTRUCT *lps )
168 PAINTSTRUCT16 ps;
170 BeginPaint16( hwnd, &ps );
171 lps->hdc = (HDC)ps.hdc;
172 lps->fErase = ps.fErase;
173 lps->rcPaint.top = ps.rcPaint.top;
174 lps->rcPaint.left = ps.rcPaint.left;
175 lps->rcPaint.right = ps.rcPaint.right;
176 lps->rcPaint.bottom = ps.rcPaint.bottom;
177 lps->fRestore = ps.fRestore;
178 lps->fIncUpdate = ps.fIncUpdate;
179 return lps->hdc;
183 /***********************************************************************
184 * EndPaint16 (USER.40)
186 BOOL16 WINAPI EndPaint16( HWND16 hwnd, const PAINTSTRUCT16* lps )
188 ReleaseDC16( hwnd, lps->hdc );
189 ShowCaret( hwnd );
190 return TRUE;
194 /***********************************************************************
195 * EndPaint32 (USER32.176)
197 BOOL WINAPI EndPaint( HWND hwnd, const PAINTSTRUCT *lps )
199 ReleaseDC( hwnd, lps->hdc );
200 ShowCaret( hwnd );
201 return TRUE;
205 /***********************************************************************
206 * FillWindow (USER.324)
208 void WINAPI FillWindow16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc, HBRUSH16 hbrush )
210 RECT16 rect;
211 GetClientRect16( hwnd, &rect );
212 DPtoLP16( hdc, (LPPOINT16)&rect, 2 );
213 PaintRect16( hwndParent, hwnd, hdc, hbrush, &rect );
217 /***********************************************************************
218 * PAINT_GetControlBrush
220 static HBRUSH16 PAINT_GetControlBrush( HWND hParent, HWND hWnd, HDC16 hDC, UINT16 ctlType )
222 HBRUSH16 bkgBrush = (HBRUSH16)SendMessageA( hParent, WM_CTLCOLORMSGBOX + ctlType,
223 (WPARAM)hDC, (LPARAM)hWnd );
224 if( !IsGDIObject16(bkgBrush) )
225 bkgBrush = DEFWND_ControlColor( hDC, ctlType );
226 return bkgBrush;
230 /***********************************************************************
231 * PaintRect (USER.325)
233 void WINAPI PaintRect16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc,
234 HBRUSH16 hbrush, const RECT16 *rect)
236 if( hbrush <= CTLCOLOR_MAX )
238 if( hwndParent )
239 hbrush = PAINT_GetControlBrush( hwndParent, hwnd, hdc, (UINT16)hbrush );
240 else
241 return;
243 if( hbrush )
244 FillRect16( hdc, rect, hbrush );
248 /***********************************************************************
249 * GetControlBrush (USER.326)
251 HBRUSH16 WINAPI GetControlBrush16( HWND16 hwnd, HDC16 hdc, UINT16 ctlType )
253 WND* wndPtr = WIN_FindWndPtr( hwnd );
254 HBRUSH16 retvalue;
256 if((ctlType <= CTLCOLOR_MAX) && wndPtr )
258 WND* parent;
259 if( wndPtr->dwStyle & WS_POPUP ) parent = WIN_LockWndPtr(wndPtr->owner);
260 else parent = WIN_LockWndPtr(wndPtr->parent);
261 if( !parent ) parent = wndPtr;
262 retvalue = (HBRUSH16)PAINT_GetControlBrush( parent->hwndSelf, hwnd, hdc, ctlType );
263 WIN_ReleaseWndPtr(parent);
264 goto END;
266 retvalue = (HBRUSH16)0;
267 END:
268 WIN_ReleaseWndPtr(wndPtr);
269 return retvalue;
273 /***********************************************************************
274 * PAINT_RedrawWindow
276 * FIXME: Windows uses WM_SYNCPAINT to cut down the number of intertask
277 * SendMessage() calls. This is a comment inside DefWindowProc() source
278 * from 16-bit SDK:
280 * This message avoids lots of inter-app message traffic
281 * by switching to the other task and continuing the
282 * recursion there.
284 * wParam = flags
285 * LOWORD(lParam) = hrgnClip
286 * HIWORD(lParam) = hwndSkip (not used; always NULL)
288 * All in all, a prime candidate for a rewrite.
290 BOOL PAINT_RedrawWindow( HWND hwnd, const RECT *rectUpdate,
291 HRGN hrgnUpdate, UINT flags, UINT control )
293 BOOL bIcon;
294 HRGN hrgn;
295 RECT rectClient;
296 WND* wndPtr;
297 WND **list, **ppWnd;
299 if (!hwnd) hwnd = GetDesktopWindow();
300 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
301 if (!WIN_IsWindowDrawable( wndPtr, !(flags & RDW_FRAME) ) )
303 WIN_ReleaseWndPtr(wndPtr);
304 return TRUE; /* No redraw needed */
307 bIcon = (wndPtr->dwStyle & WS_MINIMIZE && wndPtr->class->hIcon);
308 if (rectUpdate)
310 TRACE(win, "%04x %d,%d-%d,%d %04x flags=%04x\n",
311 hwnd, rectUpdate->left, rectUpdate->top,
312 rectUpdate->right, rectUpdate->bottom, hrgnUpdate, flags );
314 else
316 TRACE(win, "%04x NULL %04x flags=%04x\n", hwnd, hrgnUpdate, flags);
319 GetClientRect( hwnd, &rectClient );
321 if (flags & RDW_INVALIDATE) /* Invalidate */
323 int rgnNotEmpty = COMPLEXREGION;
325 if (wndPtr->hrgnUpdate > 1) /* Is there already an update region? */
327 if ((hrgn = hrgnUpdate) == 0)
328 hrgn = CreateRectRgnIndirect( rectUpdate ? rectUpdate :
329 &rectClient );
330 rgnNotEmpty = CombineRgn( wndPtr->hrgnUpdate, wndPtr->hrgnUpdate,
331 hrgn, RGN_OR );
332 if (!hrgnUpdate) DeleteObject( hrgn );
334 else /* No update region yet */
336 if (!(wndPtr->flags & WIN_INTERNAL_PAINT))
337 QUEUE_IncPaintCount( wndPtr->hmemTaskQ );
338 if (hrgnUpdate)
340 wndPtr->hrgnUpdate = CreateRectRgn( 0, 0, 0, 0 );
341 rgnNotEmpty = CombineRgn( wndPtr->hrgnUpdate, hrgnUpdate,
342 0, RGN_COPY );
344 else wndPtr->hrgnUpdate = CreateRectRgnIndirect( rectUpdate ?
345 rectUpdate : &rectClient );
348 if (flags & RDW_FRAME) wndPtr->flags |= WIN_NEEDS_NCPAINT;
350 /* restrict update region to client area (FIXME: correct?) */
351 if (wndPtr->hrgnUpdate)
353 HRGN clientRgn = CreateRectRgnIndirect( &rectClient );
354 rgnNotEmpty = CombineRgn( wndPtr->hrgnUpdate, clientRgn,
355 wndPtr->hrgnUpdate, RGN_AND );
356 DeleteObject( clientRgn );
359 /* check for bogus update region */
360 if ( rgnNotEmpty == NULLREGION )
362 wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
363 DeleteObject( wndPtr->hrgnUpdate );
364 wndPtr->hrgnUpdate=0;
365 if (!(wndPtr->flags & WIN_INTERNAL_PAINT))
366 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
368 else
369 if (flags & RDW_ERASE) wndPtr->flags |= WIN_NEEDS_ERASEBKGND;
370 flags |= RDW_FRAME; /* Force children frame invalidation */
372 else if (flags & RDW_VALIDATE) /* Validate */
374 /* We need an update region in order to validate anything */
375 if (wndPtr->hrgnUpdate > 1)
377 if (!hrgnUpdate && !rectUpdate)
379 /* Special case: validate everything */
380 DeleteObject( wndPtr->hrgnUpdate );
381 wndPtr->hrgnUpdate = 0;
383 else
385 if ((hrgn = hrgnUpdate) == 0)
386 hrgn = CreateRectRgnIndirect( rectUpdate );
387 if (CombineRgn( wndPtr->hrgnUpdate, wndPtr->hrgnUpdate,
388 hrgn, RGN_DIFF ) == NULLREGION)
390 DeleteObject( wndPtr->hrgnUpdate );
391 wndPtr->hrgnUpdate = 0;
393 if (!hrgnUpdate) DeleteObject( hrgn );
395 if (!wndPtr->hrgnUpdate) /* No more update region */
396 if (!(wndPtr->flags & WIN_INTERNAL_PAINT))
397 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
399 if (flags & RDW_NOFRAME) wndPtr->flags &= ~WIN_NEEDS_NCPAINT;
400 if (flags & RDW_NOERASE) wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
403 /* Set/clear internal paint flag */
405 if (flags & RDW_INTERNALPAINT)
407 if ( wndPtr->hrgnUpdate <= 1 && !(wndPtr->flags & WIN_INTERNAL_PAINT))
408 QUEUE_IncPaintCount( wndPtr->hmemTaskQ );
409 wndPtr->flags |= WIN_INTERNAL_PAINT;
411 else if (flags & RDW_NOINTERNALPAINT)
413 if ( wndPtr->hrgnUpdate <= 1 && (wndPtr->flags & WIN_INTERNAL_PAINT))
414 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
415 wndPtr->flags &= ~WIN_INTERNAL_PAINT;
418 /* Erase/update window */
420 if (flags & RDW_UPDATENOW)
422 if (wndPtr->hrgnUpdate) /* wm_painticon wparam is 1 */
423 SendMessage16( hwnd, (bIcon) ? WM_PAINTICON : WM_PAINT, bIcon, 0 );
425 else if (flags & RDW_ERASENOW)
427 if (wndPtr->flags & WIN_NEEDS_NCPAINT)
428 WIN_UpdateNCArea( wndPtr, FALSE);
430 if (wndPtr->flags & WIN_NEEDS_ERASEBKGND)
432 HDC hdc = GetDCEx( hwnd, wndPtr->hrgnUpdate,
433 DCX_INTERSECTRGN | DCX_USESTYLE |
434 DCX_KEEPCLIPRGN | DCX_WINDOWPAINT |
435 (bIcon ? DCX_WINDOW : 0) );
436 if (hdc)
438 if (SendMessage16( hwnd, (bIcon) ? WM_ICONERASEBKGND
439 : WM_ERASEBKGND,
440 (WPARAM16)hdc, 0 ))
441 wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND;
442 ReleaseDC( hwnd, hdc );
447 /* Recursively process children */
449 if (!(flags & RDW_NOCHILDREN) &&
450 ((flags & RDW_ALLCHILDREN) || !(wndPtr->dwStyle & WS_CLIPCHILDREN)) &&
451 !(wndPtr->dwStyle & WS_MINIMIZE) )
453 if ( hrgnUpdate || rectUpdate )
455 if (!(hrgn = CreateRectRgn( 0, 0, 0, 0 )))
457 WIN_ReleaseWndPtr(wndPtr);
458 return TRUE;
460 if( !hrgnUpdate )
462 control |= (RDW_C_DELETEHRGN | RDW_C_USEHRGN);
463 if( !(hrgnUpdate = CreateRectRgnIndirect( rectUpdate )) )
465 DeleteObject( hrgn );
466 WIN_ReleaseWndPtr(wndPtr);
467 return TRUE;
470 if( (list = WIN_BuildWinArray( wndPtr, 0, NULL )) )
472 for (ppWnd = list; *ppWnd; ppWnd++)
474 WIN_UpdateWndPtr(&wndPtr,*ppWnd);
475 if (!IsWindow(wndPtr->hwndSelf)) continue;
476 if (wndPtr->dwStyle & WS_VISIBLE)
478 SetRectRgn( hrgn,
479 wndPtr->rectWindow.left, wndPtr->rectWindow.top,
480 wndPtr->rectWindow.right, wndPtr->rectWindow.bottom );
481 if (CombineRgn( hrgn, hrgn, hrgnUpdate, RGN_AND ))
483 OffsetRgn( hrgn, -wndPtr->rectClient.left,
484 -wndPtr->rectClient.top );
485 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, hrgn, flags,
486 RDW_C_USEHRGN );
490 WIN_ReleaseWinArray(list);
492 DeleteObject( hrgn );
493 if (control & RDW_C_DELETEHRGN) DeleteObject( hrgnUpdate );
495 else
497 if( (list = WIN_BuildWinArray( wndPtr, 0, NULL )) )
499 for (ppWnd = list; *ppWnd; ppWnd++)
501 WIN_UpdateWndPtr(&wndPtr,*ppWnd);
502 if (IsWindow( wndPtr->hwndSelf ))
503 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0, flags, 0 );
505 WIN_ReleaseWinArray(list);
510 WIN_ReleaseWndPtr(wndPtr);
511 return TRUE;
515 /***********************************************************************
516 * RedrawWindow32 (USER32.426)
518 BOOL WINAPI RedrawWindow( HWND hwnd, const RECT *rectUpdate,
519 HRGN hrgnUpdate, UINT flags )
521 return PAINT_RedrawWindow( hwnd, rectUpdate, hrgnUpdate, flags, 0 );
525 /***********************************************************************
526 * RedrawWindow16 (USER.290)
528 BOOL16 WINAPI RedrawWindow16( HWND16 hwnd, const RECT16 *rectUpdate,
529 HRGN16 hrgnUpdate, UINT16 flags )
531 if (rectUpdate)
533 RECT r;
534 CONV_RECT16TO32( rectUpdate, &r );
535 return (BOOL16)RedrawWindow( (HWND)hwnd, &r, hrgnUpdate, flags );
537 return (BOOL16)PAINT_RedrawWindow( (HWND)hwnd, NULL,
538 (HRGN)hrgnUpdate, flags, 0 );
542 /***********************************************************************
543 * UpdateWindow16 (USER.124)
545 void WINAPI UpdateWindow16( HWND16 hwnd )
547 PAINT_RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_NOCHILDREN, 0 );
550 /***********************************************************************
551 * UpdateWindow32 (USER32.567)
553 void WINAPI UpdateWindow( HWND hwnd )
555 PAINT_RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_NOCHILDREN, 0 );
558 /***********************************************************************
559 * InvalidateRgn16 (USER.126)
561 void WINAPI InvalidateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
563 PAINT_RedrawWindow((HWND)hwnd, NULL, (HRGN)hrgn,
564 RDW_INVALIDATE | (erase ? RDW_ERASE : 0), 0 );
568 /***********************************************************************
569 * InvalidateRgn32 (USER32.329)
571 BOOL WINAPI InvalidateRgn( HWND hwnd, HRGN hrgn, BOOL erase )
573 return PAINT_RedrawWindow(hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0), 0 );
577 /***********************************************************************
578 * InvalidateRect16 (USER.125)
580 void WINAPI InvalidateRect16( HWND16 hwnd, const RECT16 *rect, BOOL16 erase )
582 RedrawWindow16( hwnd, rect, 0, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
586 /***********************************************************************
587 * InvalidateRect32 (USER32.328)
589 BOOL WINAPI InvalidateRect( HWND hwnd, const RECT *rect, BOOL erase )
591 return PAINT_RedrawWindow( hwnd, rect, 0,
592 RDW_INVALIDATE | (erase ? RDW_ERASE : 0), 0 );
596 /***********************************************************************
597 * ValidateRgn16 (USER.128)
599 void WINAPI ValidateRgn16( HWND16 hwnd, HRGN16 hrgn )
601 PAINT_RedrawWindow( (HWND)hwnd, NULL, (HRGN)hrgn,
602 RDW_VALIDATE | RDW_NOCHILDREN, 0 );
606 /***********************************************************************
607 * ValidateRgn32 (USER32.572)
609 void WINAPI ValidateRgn( HWND hwnd, HRGN hrgn )
611 PAINT_RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOCHILDREN, 0 );
615 /***********************************************************************
616 * ValidateRect16 (USER.127)
618 void WINAPI ValidateRect16( HWND16 hwnd, const RECT16 *rect )
620 RedrawWindow16( hwnd, rect, 0, RDW_VALIDATE | RDW_NOCHILDREN );
624 /***********************************************************************
625 * ValidateRect32 (USER32.571)
627 void WINAPI ValidateRect( HWND hwnd, const RECT *rect )
629 PAINT_RedrawWindow( hwnd, rect, 0, RDW_VALIDATE | RDW_NOCHILDREN, 0 );
633 /***********************************************************************
634 * GetUpdateRect16 (USER.190)
636 BOOL16 WINAPI GetUpdateRect16( HWND16 hwnd, LPRECT16 rect, BOOL16 erase )
638 RECT r;
639 BOOL16 ret;
641 if (!rect) return GetUpdateRect( hwnd, NULL, erase );
642 ret = GetUpdateRect( hwnd, &r, erase );
643 CONV_RECT32TO16( &r, rect );
644 return ret;
648 /***********************************************************************
649 * GetUpdateRect32 (USER32.297)
651 BOOL WINAPI GetUpdateRect( HWND hwnd, LPRECT rect, BOOL erase )
653 BOOL retvalue;
654 WND * wndPtr = WIN_FindWndPtr( hwnd );
655 if (!wndPtr) return FALSE;
657 if (rect)
659 if (wndPtr->hrgnUpdate > 1)
661 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
662 if (GetUpdateRgn( hwnd, hrgn, erase ) == ERROR)
664 retvalue = FALSE;
665 goto END;
667 GetRgnBox( hrgn, rect );
668 DeleteObject( hrgn );
669 if (wndPtr->class->style & CS_OWNDC)
671 if (GetMapMode(wndPtr->dce->hDC) != MM_TEXT)
673 DPtoLP (wndPtr->dce->hDC, (LPPOINT)rect, 2);
677 else SetRectEmpty( rect );
679 retvalue = (wndPtr->hrgnUpdate > 1);
680 END:
681 WIN_ReleaseWndPtr(wndPtr);
682 return retvalue;
686 /***********************************************************************
687 * GetUpdateRgn16 (USER.237)
689 INT16 WINAPI GetUpdateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
691 return GetUpdateRgn( hwnd, hrgn, erase );
695 /***********************************************************************
696 * GetUpdateRgn32 (USER32.298)
698 INT WINAPI GetUpdateRgn( HWND hwnd, HRGN hrgn, BOOL erase )
700 INT retval;
701 WND * wndPtr = WIN_FindWndPtr( hwnd );
702 if (!wndPtr) return ERROR;
704 if (wndPtr->hrgnUpdate <= 1)
706 SetRectRgn( hrgn, 0, 0, 0, 0 );
707 retval = NULLREGION;
708 goto END;
710 retval = CombineRgn( hrgn, wndPtr->hrgnUpdate, 0, RGN_COPY );
711 if (erase) RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW | RDW_NOCHILDREN );
712 END:
713 WIN_ReleaseWndPtr(wndPtr);
714 return retval;
718 /***********************************************************************
719 * ExcludeUpdateRgn16 (USER.238)
721 INT16 WINAPI ExcludeUpdateRgn16( HDC16 hdc, HWND16 hwnd )
723 return ExcludeUpdateRgn( hdc, hwnd );
727 /***********************************************************************
728 * ExcludeUpdateRgn32 (USER32.195)
730 INT WINAPI ExcludeUpdateRgn( HDC hdc, HWND hwnd )
732 RECT rect;
733 WND * wndPtr;
735 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return ERROR;
737 if (wndPtr->hrgnUpdate)
739 INT ret;
740 HRGN hrgn = CreateRectRgn(wndPtr->rectWindow.left - wndPtr->rectClient.left,
741 wndPtr->rectWindow.top - wndPtr->rectClient.top,
742 wndPtr->rectClient.right - wndPtr->rectClient.left,
743 wndPtr->rectClient.bottom - wndPtr->rectClient.top);
744 if( wndPtr->hrgnUpdate > 1 )
745 CombineRgn(hrgn, wndPtr->hrgnUpdate, 0, RGN_COPY);
747 /* do ugly coordinate translations in dce.c */
749 ret = DCE_ExcludeRgn( hdc, wndPtr, hrgn );
750 DeleteObject( hrgn );
751 WIN_ReleaseWndPtr(wndPtr);
752 return ret;
754 WIN_ReleaseWndPtr(wndPtr);
755 return GetClipBox( hdc, &rect );