2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Win32k subsystem
4 * PURPOSE: Window painting function
5 * FILE: win32ss/user/ntuser/painting.c
6 * PROGRAMER: Filip Navara (xnavara@volny.cz)
10 DBG_DEFAULT_CHANNEL(UserPainting
);
12 BOOL
UserExtTextOutW(HDC hdc
, INT x
, INT y
, UINT flags
, PRECTL lprc
,
13 LPCWSTR lpString
, UINT count
);
15 /* PRIVATE FUNCTIONS **********************************************************/
18 * @name IntIntersectWithParents
20 * Intersect window rectangle with all parent client rectangles.
23 * Pointer to child window to start intersecting from.
25 * Pointer to rectangle that we want to intersect in screen
26 * coordinates on input and intersected rectangle on output (if TRUE
30 * If any parent is minimized or invisible or the resulting rectangle
31 * is empty then FALSE is returned. Otherwise TRUE is returned.
35 IntIntersectWithParents(PWND Child
, RECTL
*WindowRect
)
39 if (Child
->ExStyle
& WS_EX_REDIRECTED
)
42 ParentWnd
= Child
->spwndParent
;
43 while (ParentWnd
!= NULL
)
45 if (!(ParentWnd
->style
& WS_VISIBLE
) ||
46 (ParentWnd
->style
& WS_MINIMIZE
) ||
47 !RECTL_bIntersectRect(WindowRect
, WindowRect
, &ParentWnd
->rcClient
) )
52 if (ParentWnd
->ExStyle
& WS_EX_REDIRECTED
)
55 ParentWnd
= ParentWnd
->spwndParent
;
62 IntValidateParents(PWND Child
, BOOL Recurse
)
64 RECTL ParentRect
, Rect
;
65 BOOL Start
, Ret
= TRUE
;
66 PWND ParentWnd
= Child
;
69 if (ParentWnd
->style
& WS_CHILD
)
72 ParentWnd
= ParentWnd
->spwndParent
;
73 while (ParentWnd
->style
& WS_CHILD
);
76 // No pending nonclient paints.
77 if (!(ParentWnd
->state
& WNDS_SYNCPAINTPENDING
)) Recurse
= FALSE
;
80 ParentWnd
= Child
->spwndParent
;
83 if (ParentWnd
->style
& WS_CLIPCHILDREN
)
86 if (ParentWnd
->hrgnUpdate
!= 0)
93 // Start with child clipping.
98 Rect
= Child
->rcWindow
;
100 if (!IntIntersectWithParents(Child
, &Rect
)) break;
102 Rgn
= IntSysCreateRectpRgnIndirect(&Rect
);
106 PREGION RgnClip
= REGION_LockRgn(Child
->hrgnClip
);
107 IntGdiCombineRgn(Rgn
, Rgn
, RgnClip
, RGN_AND
);
108 REGION_UnlockRgn(RgnClip
);
112 ParentRect
= ParentWnd
->rcWindow
;
114 if (!IntIntersectWithParents(ParentWnd
, &ParentRect
)) break;
116 IntInvalidateWindows( ParentWnd
,
118 RDW_VALIDATE
| RDW_NOCHILDREN
| RDW_NOUPDATEDIRTY
);
120 ParentWnd
= ParentWnd
->spwndParent
;
123 if (Rgn
) REGION_Delete(Rgn
);
129 Synchronize painting to the top-level windows of other threads.
132 IntSendSyncPaint(PWND Wnd
, ULONG Flags
)
134 PTHREADINFO ptiCur
, ptiWnd
;
135 PUSER_SENT_MESSAGE Message
;
139 ptiWnd
= Wnd
->head
.pti
;
140 ptiCur
= PsGetCurrentThreadWin32Thread();
142 Not the current thread, Wnd is in send Nonclient paint also in send erase background and it is visiable.
144 if ( Wnd
->head
.pti
!= ptiCur
&&
145 Wnd
->state
& WNDS_SENDNCPAINT
&&
146 Wnd
->state
& WNDS_SENDERASEBACKGROUND
&&
147 Wnd
->style
& WS_VISIBLE
)
149 // For testing, if you see this, break out the Champagne and have a party!
150 TRACE("SendSyncPaint Wnd in State!\n");
151 if (!IsListEmpty(&ptiWnd
->SentMessagesListHead
))
153 // Scan sent queue messages to see if we received sync paint messages.
154 Entry
= ptiWnd
->SentMessagesListHead
.Flink
;
155 Message
= CONTAINING_RECORD(Entry
, USER_SENT_MESSAGE
, ListEntry
);
159 if (Message
->Msg
.message
== WM_SYNCPAINT
&&
160 Message
->Msg
.hwnd
== UserHMGetHandle(Wnd
))
161 { // Already received so exit out.
162 ERR("SendSyncPaint Found one in the Sent Msg Queue!\n");
166 Entry
= Message
->ListEntry
.Flink
;
167 Message
= CONTAINING_RECORD(Entry
, USER_SENT_MESSAGE
, ListEntry
);
169 while (Entry
!= &ptiWnd
->SentMessagesListHead
);
173 TRACE("Sending WM_SYNCPAINT\n");
174 // This message has no parameters. But it does! Pass Flags along.
175 co_IntSendMessageNoWait(UserHMGetHandle(Wnd
), WM_SYNCPAINT
, Flags
, 0);
176 Wnd
->state
|= WNDS_SYNCPAINTPENDING
;
180 // Send to all the children if this is the desktop window.
181 if (UserIsDesktopWindow(Wnd
))
183 if ( Flags
& RDW_ALLCHILDREN
||
184 ( !(Flags
& RDW_NOCHILDREN
) && Wnd
->style
& WS_CLIPCHILDREN
))
186 PWND spwndChild
= Wnd
->spwndChild
;
189 if ( spwndChild
->style
& WS_CHILD
&&
190 spwndChild
->head
.pti
!= ptiCur
)
192 spwndChild
= spwndChild
->spwndNext
;
195 IntSendSyncPaint( spwndChild
, Flags
);
196 spwndChild
= spwndChild
->spwndNext
;
203 * @name IntCalcWindowRgn
205 * Get a window or client region.
209 IntCalcWindowRgn(PWND Wnd
, BOOL Client
)
215 hRgnWindow
= NtGdiCreateRectRgn(
219 Wnd
->rcClient
.bottom
);
223 hRgnWindow
= NtGdiCreateRectRgn(
227 Wnd
->rcWindow
.bottom
);
230 if (Wnd
->hrgnClip
!= NULL
&& !(Wnd
->style
& WS_MINIMIZE
))
232 NtGdiOffsetRgn(hRgnWindow
,
235 NtGdiCombineRgn(hRgnWindow
, hRgnWindow
, Wnd
->hrgnClip
, RGN_AND
);
236 NtGdiOffsetRgn(hRgnWindow
,
245 * @name IntGetNCUpdateRgn
247 * Get non-client update region of a window and optionally validate it.
250 * Pointer to window to get the NC update region from.
252 * Set to TRUE to force validating the NC update region.
255 * Handle to NC update region. The caller is responsible for deleting
260 IntGetNCUpdateRgn(PWND Window
, BOOL Validate
)
264 UINT RgnType
, NcType
;
267 if (Window
->hrgnUpdate
!= NULL
&&
268 Window
->hrgnUpdate
!= HRGN_WINDOW
)
270 hRgnNonClient
= IntCalcWindowRgn(Window
, FALSE
);
273 * If region creation fails it's safe to fallback to whole
276 if (hRgnNonClient
== NULL
)
281 hRgnWindow
= IntCalcWindowRgn(Window
, TRUE
);
282 if (hRgnWindow
== NULL
)
284 GreDeleteObject(hRgnNonClient
);
288 NcType
= IntGdiGetRgnBox(hRgnNonClient
, &update
);
290 RgnType
= NtGdiCombineRgn(hRgnNonClient
, hRgnNonClient
, hRgnWindow
, RGN_DIFF
);
292 if (RgnType
== ERROR
)
294 GreDeleteObject(hRgnWindow
);
295 GreDeleteObject(hRgnNonClient
);
298 else if (RgnType
== NULLREGION
)
300 GreDeleteObject(hRgnWindow
);
301 GreDeleteObject(hRgnNonClient
);
302 Window
->state
&= ~WNDS_UPDATEDIRTY
;
307 * Remove the nonclient region from the standard update region if
308 * we were asked for it.
313 if (NtGdiCombineRgn(Window
->hrgnUpdate
, Window
->hrgnUpdate
, hRgnWindow
, RGN_AND
) == NULLREGION
)
315 IntGdiSetRegionOwner(Window
->hrgnUpdate
, GDI_OBJ_HMGR_POWNED
);
316 GreDeleteObject(Window
->hrgnUpdate
);
317 Window
->state
&= ~WNDS_UPDATEDIRTY
;
318 Window
->hrgnUpdate
= NULL
;
319 if (!(Window
->state
& WNDS_INTERNALPAINT
))
320 MsqDecPaintCountQueue(Window
->head
.pti
);
324 /* check if update rgn contains complete nonclient area */
325 if (NcType
== SIMPLEREGION
)
328 IntGetWindowRect( Window
, &window
);
330 if (IntEqualRect( &window
, &update
))
332 GreDeleteObject(hRgnNonClient
);
333 hRgnNonClient
= HRGN_WINDOW
;
337 GreDeleteObject(hRgnWindow
);
339 return hRgnNonClient
;
343 return Window
->hrgnUpdate
;
348 IntSendNCPaint(PWND pWnd
, HRGN hRgn
)
350 pWnd
->state
&= ~WNDS_SENDNCPAINT
;
352 if ( pWnd
== GetW32ThreadInfo()->MessageQueue
->spwndActive
&&
353 !(pWnd
->state
& WNDS_ACTIVEFRAME
))
355 pWnd
->state
|= WNDS_ACTIVEFRAME
;
356 pWnd
->state
&= ~WNDS_NONCPAINT
;
360 if (pWnd
->state2
& WNDS2_FORCEFULLNCPAINTCLIPRGN
)
362 pWnd
->state2
&= ~WNDS2_FORCEFULLNCPAINTCLIPRGN
;
366 if (hRgn
) co_IntSendMessage(UserHMGetHandle(pWnd
), WM_NCPAINT
, (WPARAM
)hRgn
, 0);
370 IntSendChildNCPaint(PWND pWnd
)
372 for (pWnd
= pWnd
->spwndChild
; pWnd
; pWnd
= pWnd
->spwndNext
)
374 if ((pWnd
->hrgnUpdate
== NULL
) && (pWnd
->state
& WNDS_SENDNCPAINT
))
376 USER_REFERENCE_ENTRY Ref
;
377 UserRefObjectCo(pWnd
, &Ref
);
378 IntSendNCPaint(pWnd
, HRGN_WINDOW
);
379 UserDerefObjectCo(pWnd
);
387 * Internal function used by IntRedrawWindow.
391 co_IntPaintWindows(PWND Wnd
, ULONG Flags
, BOOL Recurse
)
394 HWND hWnd
= Wnd
->head
.h
;
395 HRGN TempRegion
= NULL
;
397 Wnd
->state
&= ~WNDS_PAINTNOTPROCESSED
;
399 if (Wnd
->state
& WNDS_SENDNCPAINT
||
400 Wnd
->state
& WNDS_SENDERASEBACKGROUND
)
402 if (!(Wnd
->style
& WS_VISIBLE
))
404 Wnd
->state
&= ~(WNDS_SENDNCPAINT
|WNDS_SENDERASEBACKGROUND
|WNDS_ERASEBACKGROUND
);
409 if (Wnd
->hrgnUpdate
== NULL
)
411 Wnd
->state
&= ~(WNDS_SENDERASEBACKGROUND
|WNDS_ERASEBACKGROUND
);
414 if (Wnd
->head
.pti
== PsGetCurrentThreadWin32Thread())
416 if (Wnd
->state
& WNDS_SENDNCPAINT
)
418 TempRegion
= IntGetNCUpdateRgn(Wnd
, TRUE
);
420 IntSendNCPaint(Wnd
, TempRegion
);
422 if (TempRegion
> HRGN_WINDOW
&& GreIsHandleValid(TempRegion
))
424 /* NOTE: The region can already be deleted! */
425 GreDeleteObject(TempRegion
);
429 if (Wnd
->state
& WNDS_SENDERASEBACKGROUND
)
431 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
434 hDC
= UserGetDCEx( Wnd
,
436 DCX_CACHE
|DCX_USESTYLE
|DCX_INTERSECTRGN
|DCX_KEEPCLIPRGN
);
438 if (Wnd
->head
.pti
->ppi
!= pti
->ppi
)
440 ERR("Sending DC to another Process!!!\n");
443 Wnd
->state
&= ~(WNDS_SENDERASEBACKGROUND
|WNDS_ERASEBACKGROUND
);
444 // Kill the loop, so Clear before we send.
445 if (!co_IntSendMessage(hWnd
, WM_ERASEBKGND
, (WPARAM
)hDC
, 0))
447 Wnd
->state
|= (WNDS_SENDERASEBACKGROUND
|WNDS_ERASEBACKGROUND
);
449 UserReleaseDC(Wnd
, hDC
, FALSE
);
458 * Check that the window is still valid at this point
460 if (!IntIsWindow(hWnd
))
466 * Paint child windows.
469 if (!(Flags
& RDW_NOCHILDREN
) &&
470 !(Wnd
->style
& WS_MINIMIZE
) &&
471 ( Flags
& RDW_ALLCHILDREN
||
472 (Flags
& RDW_CLIPCHILDREN
&& Wnd
->style
& WS_CLIPCHILDREN
) ) )
475 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
477 if ((List
= IntWinListChildren(Wnd
)))
479 for (phWnd
= List
; *phWnd
; ++phWnd
)
481 if ((Wnd
= UserGetWindowObject(*phWnd
)) == NULL
)
484 if (Wnd
->head
.pti
!= pti
&& Wnd
->style
& WS_CHILD
)
487 if (Wnd
->style
& WS_VISIBLE
)
489 USER_REFERENCE_ENTRY Ref
;
490 UserRefObjectCo(Wnd
, &Ref
);
491 co_IntPaintWindows(Wnd
, Flags
, TRUE
);
492 UserDerefObjectCo(Wnd
);
495 ExFreePoolWithTag(List
, USERTAG_WINDOWLIST
);
503 * Internal function used by IntRedrawWindow, simplecall.
507 co_IntUpdateWindows(PWND Wnd
, ULONG Flags
, BOOL Recurse
)
509 HWND hWnd
= Wnd
->head
.h
;
511 if ( Wnd
->hrgnUpdate
!= NULL
|| Wnd
->state
& WNDS_INTERNALPAINT
)
515 if (!IntValidateParents(Wnd
, Recurse
))
521 if (Wnd
->state
& WNDS_INTERNALPAINT
)
523 Wnd
->state
&= ~WNDS_INTERNALPAINT
;
525 if (Wnd
->hrgnUpdate
== NULL
)
526 MsqDecPaintCountQueue(Wnd
->head
.pti
);
529 Wnd
->state
|= WNDS_PAINTNOTPROCESSED
;
530 Wnd
->state
&= ~WNDS_UPDATEDIRTY
;
532 Wnd
->state2
|= WNDS2_WMPAINTSENT
;
533 co_IntSendMessage(hWnd
, WM_PAINT
, 0, 0);
535 if (Wnd
->state
& WNDS_PAINTNOTPROCESSED
)
537 USER_REFERENCE_ENTRY Ref
;
538 UserRefObjectCo(Wnd
, &Ref
);
539 co_IntPaintWindows(Wnd
, RDW_NOCHILDREN
, FALSE
);
540 UserDerefObjectCo(Wnd
);
544 // Force flags as a toggle. Fixes msg:test_paint_messages:WmChildPaintNc.
545 Flags
= (Flags
& RDW_NOCHILDREN
) ? RDW_NOCHILDREN
: RDW_ALLCHILDREN
; // All children is the default.
548 * Update child windows.
551 if (!(Flags
& RDW_NOCHILDREN
) &&
552 (Flags
& RDW_ALLCHILDREN
) &&
553 !UserIsDesktopWindow(Wnd
))
557 for (Child
= Wnd
->spwndChild
; Child
; Child
= Child
->spwndNext
)
559 /* transparent window, check for non-transparent sibling to paint first, then skip it */
560 if ( Child
->ExStyle
& WS_EX_TRANSPARENT
&&
561 ( Child
->hrgnUpdate
!= NULL
|| Child
->state
& WNDS_INTERNALPAINT
) )
563 PWND Next
= Child
->spwndNext
;
566 if ( Next
->hrgnUpdate
!= NULL
|| Next
->state
& WNDS_INTERNALPAINT
) break;
568 Next
= Next
->spwndNext
;
574 if (Child
->style
& WS_VISIBLE
)
576 USER_REFERENCE_ENTRY Ref
;
577 UserRefObjectCo(Child
, &Ref
);
578 co_IntUpdateWindows(Child
, Flags
, TRUE
);
579 UserDerefObjectCo(Child
);
586 UserUpdateWindows(PWND pWnd
, ULONG Flags
)
588 // If transparent and any sibling windows below needs to be painted, leave.
589 if (pWnd
->ExStyle
& WS_EX_TRANSPARENT
)
591 PWND Next
= pWnd
->spwndNext
;
595 if ( Next
->head
.pti
== pWnd
->head
.pti
&&
596 ( Next
->hrgnUpdate
!= NULL
|| Next
->state
& WNDS_INTERNALPAINT
) )
601 Next
= Next
->spwndNext
;
604 co_IntUpdateWindows(pWnd
, Flags
, FALSE
);
608 UserSyncAndPaintWindows(PWND pWnd
, ULONG Flags
)
611 // Find parent, if it needs to be painted, leave.
614 if ((Parent
= Parent
->spwndParent
) == NULL
) break;
615 if ( Parent
->style
& WS_CLIPCHILDREN
) break;
616 if ( Parent
->hrgnUpdate
!= NULL
|| Parent
->state
& WNDS_INTERNALPAINT
) return;
619 IntSendSyncPaint(pWnd
, Flags
);
620 co_IntPaintWindows(pWnd
, Flags
, FALSE
);
624 * IntInvalidateWindows
626 * Internal function used by IntRedrawWindow, UserRedrawDesktop,
627 * co_WinPosSetWindowPos, co_UserRedrawWindow.
630 IntInvalidateWindows(PWND Wnd
, PREGION Rgn
, ULONG Flags
)
632 INT RgnType
= NULLREGION
;
633 BOOL HadPaintMessage
;
635 TRACE("IntInvalidateWindows start Rgn %p\n",Rgn
);
637 if ( Rgn
> PRGN_WINDOW
)
640 * If the nonclient is not to be redrawn, clip the region to the client
643 if ((Flags
& RDW_INVALIDATE
) != 0 && (Flags
& RDW_FRAME
) == 0)
647 RgnClient
= IntSysCreateRectpRgnIndirect(&Wnd
->rcClient
);
650 RgnType
= IntGdiCombineRgn(Rgn
, Rgn
, RgnClient
, RGN_AND
);
651 REGION_Delete(RgnClient
);
656 * Clip the given region with window rectangle (or region)
659 if (!Wnd
->hrgnClip
|| (Wnd
->style
& WS_MINIMIZE
))
661 PREGION RgnWindow
= IntSysCreateRectpRgnIndirect(&Wnd
->rcWindow
);
664 RgnType
= IntGdiCombineRgn(Rgn
, Rgn
, RgnWindow
, RGN_AND
);
665 REGION_Delete(RgnWindow
);
670 PREGION RgnClip
= REGION_LockRgn(Wnd
->hrgnClip
);
673 REGION_bOffsetRgn(Rgn
,
676 RgnType
= IntGdiCombineRgn(Rgn
, Rgn
, RgnClip
, RGN_AND
);
677 REGION_bOffsetRgn(Rgn
,
680 REGION_UnlockRgn(RgnClip
);
686 RgnType
= NULLREGION
;
690 * Save current state of pending updates
693 HadPaintMessage
= IntIsWindowDirty(Wnd
);
696 * Update the region and flags
699 // The following flags are used to invalidate the window.
700 if (Flags
& (RDW_INVALIDATE
|RDW_INTERNALPAINT
|RDW_ERASE
|RDW_FRAME
))
702 if (Flags
& RDW_INTERNALPAINT
)
704 Wnd
->state
|= WNDS_INTERNALPAINT
;
707 if (Flags
& RDW_INVALIDATE
)
711 Wnd
->state
&= ~WNDS_NONCPAINT
;
713 /* If not the same thread set it dirty. */
714 if (Wnd
->head
.pti
!= PsGetCurrentThreadWin32Thread())
716 Wnd
->state
|= WNDS_UPDATEDIRTY
;
717 if (Wnd
->state2
& WNDS2_WMPAINTSENT
)
718 Wnd
->state2
|= WNDS2_ENDPAINTINVALIDATE
;
721 if (Flags
& RDW_FRAME
)
722 Wnd
->state
|= WNDS_SENDNCPAINT
;
724 if (Flags
& RDW_ERASE
)
725 Wnd
->state
|= WNDS_SENDERASEBACKGROUND
;
727 if (RgnType
!= NULLREGION
&& Rgn
> PRGN_WINDOW
)
729 if (Wnd
->hrgnUpdate
== NULL
)
731 Wnd
->hrgnUpdate
= NtGdiCreateRectRgn(0, 0, 0, 0);
732 IntGdiSetRegionOwner(Wnd
->hrgnUpdate
, GDI_OBJ_HMGR_PUBLIC
);
735 if (Wnd
->hrgnUpdate
!= HRGN_WINDOW
)
737 RgnUpdate
= REGION_LockRgn(Wnd
->hrgnUpdate
);
740 RgnType
= IntGdiCombineRgn(RgnUpdate
, RgnUpdate
, Rgn
, RGN_OR
);
741 REGION_UnlockRgn(RgnUpdate
);
742 if (RgnType
== NULLREGION
)
744 IntGdiSetRegionOwner(Wnd
->hrgnUpdate
, GDI_OBJ_HMGR_POWNED
);
745 GreDeleteObject(Wnd
->hrgnUpdate
);
746 Wnd
->hrgnUpdate
= NULL
;
752 Flags
|= RDW_ERASE
|RDW_FRAME
; // For children.
756 if (!HadPaintMessage
&& IntIsWindowDirty(Wnd
))
758 MsqIncPaintCountQueue(Wnd
->head
.pti
);
761 } // The following flags are used to validate the window.
762 else if (Flags
& (RDW_VALIDATE
|RDW_NOINTERNALPAINT
|RDW_NOERASE
|RDW_NOFRAME
))
764 if (Wnd
->state
& WNDS_UPDATEDIRTY
&& !(Flags
& RDW_NOUPDATEDIRTY
))
767 if (Flags
& RDW_NOINTERNALPAINT
)
769 Wnd
->state
&= ~WNDS_INTERNALPAINT
;
772 if (Flags
& RDW_VALIDATE
)
774 if (Flags
& RDW_NOFRAME
)
775 Wnd
->state
&= ~WNDS_SENDNCPAINT
;
777 if (Flags
& RDW_NOERASE
)
778 Wnd
->state
&= ~(WNDS_SENDERASEBACKGROUND
|WNDS_ERASEBACKGROUND
);
780 if (Wnd
->hrgnUpdate
> HRGN_WINDOW
&& RgnType
!= NULLREGION
&& Rgn
> PRGN_WINDOW
)
782 PREGION RgnUpdate
= REGION_LockRgn(Wnd
->hrgnUpdate
);
786 RgnType
= IntGdiCombineRgn(RgnUpdate
, RgnUpdate
, Rgn
, RGN_DIFF
);
787 REGION_UnlockRgn(RgnUpdate
);
789 if (RgnType
== NULLREGION
)
791 IntGdiSetRegionOwner(Wnd
->hrgnUpdate
, GDI_OBJ_HMGR_POWNED
);
792 GreDeleteObject(Wnd
->hrgnUpdate
);
793 Wnd
->hrgnUpdate
= NULL
;
797 // If update is null, do not erase.
798 if (Wnd
->hrgnUpdate
== NULL
)
800 Wnd
->state
&= ~(WNDS_SENDERASEBACKGROUND
|WNDS_ERASEBACKGROUND
);
804 if (HadPaintMessage
&& !IntIsWindowDirty(Wnd
))
806 MsqDecPaintCountQueue(Wnd
->head
.pti
);
811 * Process children if needed
814 if (!(Flags
& RDW_NOCHILDREN
) &&
815 !(Wnd
->style
& WS_MINIMIZE
) &&
816 ((Flags
& RDW_ALLCHILDREN
) || !(Wnd
->style
& WS_CLIPCHILDREN
)))
820 for (Child
= Wnd
->spwndChild
; Child
; Child
= Child
->spwndNext
)
822 if (Child
->style
& WS_VISIBLE
)
825 * Recursive call to update children hrgnUpdate
827 PREGION RgnTemp
= IntSysCreateRectpRgn(0, 0, 0, 0);
830 if (Rgn
> PRGN_WINDOW
) IntGdiCombineRgn(RgnTemp
, Rgn
, 0, RGN_COPY
);
831 IntInvalidateWindows(Child
, ((Rgn
> PRGN_WINDOW
)?RgnTemp
:Rgn
), Flags
);
832 REGION_Delete(RgnTemp
);
837 TRACE("IntInvalidateWindows exit\n");
841 * IntIsWindowDrawable
844 * Window is drawable when it is visible and all parents are not
849 IntIsWindowDrawable(PWND Wnd
)
853 for (WndObject
= Wnd
; WndObject
!= NULL
; WndObject
= WndObject
->spwndParent
)
855 if ( WndObject
->state2
& WNDS2_INDESTROY
||
856 WndObject
->state
& WNDS_DESTROYED
||
858 !(WndObject
->style
& WS_VISIBLE
) ||
859 ((WndObject
->style
& WS_MINIMIZE
) && (WndObject
!= Wnd
)))
871 * Internal version of NtUserRedrawWindow that takes WND as
878 const RECTL
* UpdateRect
,
882 PREGION TmpRgn
= NULL
;
883 TRACE("co_UserRedrawWindow start Rgn %p\n",UpdateRgn
);
887 * Validation of passed parameters.
890 if (!IntIsWindowDrawable(Window
))
892 return TRUE
; // Just do nothing!!!
897 Window
= UserGetDesktopWindow();
902 * Transform the parameters UpdateRgn and UpdateRect into
903 * a region hRgn specified in screen coordinates.
906 if (Flags
& (RDW_INVALIDATE
| RDW_VALIDATE
)) // Both are OKAY!
908 /* We can't hold lock on GDI objects while doing roundtrips to user mode,
909 * so use a copy instead */
912 TmpRgn
= IntSysCreateRectpRgn(0, 0, 0, 0);
914 if (UpdateRgn
> PRGN_WINDOW
)
916 IntGdiCombineRgn(TmpRgn
, UpdateRgn
, NULL
, RGN_COPY
);
919 if (Window
!= UserGetDesktopWindow())
921 REGION_bOffsetRgn(TmpRgn
, Window
->rcClient
.left
, Window
->rcClient
.top
);
926 if (UpdateRect
!= NULL
)
928 if (Window
== UserGetDesktopWindow())
930 TmpRgn
= IntSysCreateRectpRgnIndirect(UpdateRect
);
934 TmpRgn
= IntSysCreateRectpRgn(Window
->rcClient
.left
+ UpdateRect
->left
,
935 Window
->rcClient
.top
+ UpdateRect
->top
,
936 Window
->rcClient
.left
+ UpdateRect
->right
,
937 Window
->rcClient
.top
+ UpdateRect
->bottom
);
942 if ((Flags
& (RDW_INVALIDATE
| RDW_FRAME
)) == (RDW_INVALIDATE
| RDW_FRAME
) ||
943 (Flags
& (RDW_VALIDATE
| RDW_NOFRAME
)) == (RDW_VALIDATE
| RDW_NOFRAME
))
945 if (!RECTL_bIsEmptyRect(&Window
->rcWindow
))
946 TmpRgn
= IntSysCreateRectpRgnIndirect(&Window
->rcWindow
);
950 if (!RECTL_bIsEmptyRect(&Window
->rcClient
))
951 TmpRgn
= IntSysCreateRectpRgnIndirect(&Window
->rcClient
);
957 /* Fixes test RDW_INTERNALPAINT behavior */
960 TmpRgn
= PRGN_WINDOW
; // Need a region so the bits can be set!!!
965 * Adjust the window update region depending on hRgn and flags.
968 if (Flags
& (RDW_INVALIDATE
| RDW_VALIDATE
| RDW_INTERNALPAINT
| RDW_NOINTERNALPAINT
) &&
971 IntInvalidateWindows(Window
, TmpRgn
, Flags
);
976 * Repaint and erase windows if needed.
979 if (Flags
& RDW_UPDATENOW
)
981 UserUpdateWindows(Window
, Flags
);
983 else if (Flags
& RDW_ERASENOW
)
985 if ((Flags
& (RDW_NOCHILDREN
|RDW_ALLCHILDREN
)) == 0)
986 Flags
|= RDW_CLIPCHILDREN
;
988 UserSyncAndPaintWindows(Window
, Flags
);
996 if (TmpRgn
> PRGN_WINDOW
)
998 REGION_Delete(TmpRgn
);
1000 TRACE("co_UserRedrawWindow exit\n");
1006 PaintSuspendedWindow(PWND pwnd
, HRGN hrgnOrig
)
1008 if (pwnd
->hrgnUpdate
)
1011 INT Flags
= DC_NC
|DC_NOSENDMSG
;
1017 if (pwnd
->hrgnUpdate
> HRGN_WINDOW
)
1019 hrgnTemp
= NtGdiCreateRectRgn(0, 0, 0, 0);
1020 type
= NtGdiCombineRgn( hrgnTemp
, pwnd
->hrgnUpdate
, 0, RGN_COPY
);
1023 GreDeleteObject(hrgnTemp
);
1024 hrgnTemp
= HRGN_WINDOW
;
1029 hrgnTemp
= GreCreateRectRgnIndirect(&pwnd
->rcWindow
);
1033 hrgnTemp
> HRGN_WINDOW
&&
1034 NtGdiCombineRgn(hrgnTemp
, hrgnTemp
, hrgnOrig
, RGN_AND
) == NULLREGION
)
1036 GreDeleteObject(hrgnTemp
);
1040 hDC
= UserGetDCEx(pwnd
, hrgnTemp
, DCX_WINDOW
|DCX_INTERSECTRGN
|DCX_USESTYLE
|DCX_KEEPCLIPRGN
);
1042 Rect
= pwnd
->rcWindow
;
1043 RECTL_vOffsetRect(&Rect
, -pwnd
->rcWindow
.left
, -pwnd
->rcWindow
.top
);
1045 // Clear out client area!
1046 FillRect(hDC
, &Rect
, IntGetSysColorBrush(COLOR_WINDOW
));
1048 NC_DoNCPaint(pwnd
, hDC
, Flags
); // Redraw without MENUs.
1050 UserReleaseDC(pwnd
, hDC
, FALSE
);
1052 prgn
= REGION_LockRgn(hrgnTemp
);
1053 IntInvalidateWindows(pwnd
, prgn
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ALLCHILDREN
);
1054 REGION_UnlockRgn(prgn
);
1056 // Set updates for this window.
1057 pwnd
->state
|= WNDS_SENDNCPAINT
|WNDS_SENDERASEBACKGROUND
|WNDS_UPDATEDIRTY
;
1059 // DCX_KEEPCLIPRGN is set. Check it anyway.
1060 if (hrgnTemp
> HRGN_WINDOW
&& GreIsHandleValid(hrgnTemp
)) GreDeleteObject(hrgnTemp
);
1065 UpdateTheadChildren(PWND pWnd
, HRGN hRgn
)
1067 PaintSuspendedWindow( pWnd
, hRgn
);
1069 if (!(pWnd
->style
& WS_CLIPCHILDREN
))
1072 pWnd
= pWnd
->spwndChild
; // invalidate children if any.
1075 UpdateTheadChildren( pWnd
, hRgn
);
1076 pWnd
= pWnd
->spwndNext
;
1081 UpdateThreadWindows(PWND pWnd
, PTHREADINFO pti
, HRGN hRgn
)
1085 for ( pwndTemp
= pWnd
;
1087 pwndTemp
= pwndTemp
->spwndNext
)
1089 if (pwndTemp
->head
.pti
== pti
)
1091 UserUpdateWindows(pwndTemp
, RDW_ALLCHILDREN
);
1095 if (IsThreadSuspended(pwndTemp
->head
.pti
) || MsqIsHung(pwndTemp
->head
.pti
))
1097 UpdateTheadChildren(pwndTemp
, hRgn
);
1100 UserUpdateWindows(pwndTemp
, RDW_ALLCHILDREN
);
1106 IntIsWindowDirty(PWND Wnd
)
1108 return ( Wnd
->style
& WS_VISIBLE
&&
1109 ( Wnd
->hrgnUpdate
!= NULL
||
1110 Wnd
->state
& WNDS_INTERNALPAINT
) );
1114 Conditions to paint any window:
1116 1. Update region is not null.
1117 2. Internal paint flag is set.
1118 3. Paint count is not zero.
1122 IntFindWindowToRepaint(PWND Window
, PTHREADINFO Thread
)
1127 for (; Window
!= NULL
; Window
= Window
->spwndNext
)
1129 if (IntWndBelongsToThread(Window
, Thread
))
1131 if (IntIsWindowDirty(Window
))
1133 /* Make sure all non-transparent siblings are already drawn. */
1134 if (Window
->ExStyle
& WS_EX_TRANSPARENT
)
1136 for (TempWindow
= Window
->spwndNext
; TempWindow
!= NULL
;
1137 TempWindow
= TempWindow
->spwndNext
)
1139 if (!(TempWindow
->ExStyle
& WS_EX_TRANSPARENT
) &&
1140 IntWndBelongsToThread(TempWindow
, Thread
) &&
1141 IntIsWindowDirty(TempWindow
))
1150 /* find a child of the specified window that needs repainting */
1151 if (Window
->spwndChild
)
1153 hChild
= IntFindWindowToRepaint(Window
->spwndChild
, Thread
);
1162 // Internal painting of windows.
1165 IntPaintWindow( PWND Window
)
1167 // Handle normal painting.
1168 co_IntPaintWindows( Window
, RDW_NOCHILDREN
, FALSE
);
1180 PWND PaintWnd
, StartWnd
;
1182 if ((MsgFilterMin
!= 0 || MsgFilterMax
!= 0) &&
1183 (MsgFilterMin
> WM_PAINT
|| MsgFilterMax
< WM_PAINT
))
1186 if (Thread
->TIF_flags
& TIF_SYSTEMTHREAD
)
1188 ERR("WM_PAINT is in a System Thread!\n");
1191 StartWnd
= UserGetDesktopWindow();
1192 PaintWnd
= IntFindWindowToRepaint(StartWnd
, Thread
);
1194 Message
->hwnd
= PaintWnd
? UserHMGetHandle(PaintWnd
) : NULL
;
1196 if (Message
->hwnd
== NULL
&& Thread
->cPaintsReady
)
1198 // Find note in window.c:"PAINTING BUG".
1199 ERR("WARNING SOMETHING HAS GONE WRONG: Thread marked as containing dirty windows, but no dirty windows found! Counts %u\n",Thread
->cPaintsReady
);
1200 /* Hack to stop spamming the debug log ! */
1201 Thread
->cPaintsReady
= 0;
1205 if (Message
->hwnd
== NULL
)
1208 if (!(Window
== NULL
||
1209 PaintWnd
== Window
||
1210 IntIsChildWindow(Window
, PaintWnd
))) /* check that it is a child of the specified parent */
1213 if (PaintWnd
->state
& WNDS_INTERNALPAINT
)
1215 PaintWnd
->state
&= ~WNDS_INTERNALPAINT
;
1216 if (!PaintWnd
->hrgnUpdate
)
1217 MsqDecPaintCountQueue(Thread
);
1219 PaintWnd
->state2
&= ~WNDS2_STARTPAINT
;
1220 PaintWnd
->state
&= ~WNDS_UPDATEDIRTY
;
1223 while (Window
&& !UserIsDesktopWindow(Window
))
1225 // Role back and check for clip children, do not set if any.
1226 if (Window
->spwndParent
&& !(Window
->spwndParent
->style
& WS_CLIPCHILDREN
))
1228 PaintWnd
->state2
|= WNDS2_WMPAINTSENT
;
1230 Window
= Window
->spwndParent
;
1233 Message
->wParam
= Message
->lParam
= 0;
1234 Message
->message
= WM_PAINT
;
1246 INT cx
, cy
, xSrc
, ySrc
;
1248 if ( nFlags
& PW_CLIENTONLY
)
1250 cx
= pwnd
->rcClient
.right
- pwnd
->rcClient
.left
;
1251 cy
= pwnd
->rcClient
.bottom
- pwnd
->rcClient
.top
;
1252 xSrc
= pwnd
->rcClient
.left
- pwnd
->rcWindow
.left
;
1253 ySrc
= pwnd
->rcClient
.top
- pwnd
->rcWindow
.top
;
1257 cx
= pwnd
->rcWindow
.right
- pwnd
->rcWindow
.left
;
1258 cy
= pwnd
->rcWindow
.bottom
- pwnd
->rcWindow
.top
;
1263 // TODO: Setup Redirection for Print.
1266 /* Update the window just incase. */
1267 co_IntUpdateWindows( pwnd
, RDW_ALLCHILDREN
, FALSE
);
1269 hdcSrc
= UserGetDCEx( pwnd
, NULL
, DCX_CACHE
|DCX_WINDOW
);
1270 /* Print window to printer context. */
1271 NtGdiBitBlt( hdcBlt
,
1283 UserReleaseDC( pwnd
, hdcSrc
, FALSE
);
1285 // TODO: Release Redirection from Print.
1292 IntFlashWindowEx(PWND pWnd
, PFLASHWINFO pfwi
)
1294 DWORD_PTR FlashState
;
1295 UINT uCount
= pfwi
->uCount
;
1296 BOOL Activate
= FALSE
, Ret
= FALSE
;
1300 FlashState
= (DWORD_PTR
)UserGetProp(pWnd
, AtomFlashWndState
, TRUE
);
1302 if (FlashState
== FLASHW_FINISHED
)
1304 // Cycle has finished, kill timer and set this to Stop.
1305 FlashState
|= FLASHW_KILLSYSTIMER
;
1306 pfwi
->dwFlags
= FLASHW_STOP
;
1312 if (pfwi
->dwFlags
== FLASHW_SYSTIMER
)
1314 // Called from system timer, restore flags, counts and state.
1315 pfwi
->dwFlags
= LOWORD(FlashState
);
1316 uCount
= HIWORD(FlashState
);
1317 FlashState
= MAKELONG(LOWORD(FlashState
),0);
1321 // Clean out the trash! Fix SeaMonkey crash after restart.
1326 if (FlashState
== 0)
1327 { // First time in cycle, setup flash state.
1328 if ( pWnd
->state
& WNDS_ACTIVEFRAME
||
1329 (pfwi
->dwFlags
& FLASHW_CAPTION
&& pWnd
->style
& (WS_BORDER
|WS_DLGFRAME
)))
1331 FlashState
= FLASHW_STARTED
|FLASHW_ACTIVE
;
1335 // Set previous window state.
1336 Ret
= !!(FlashState
& FLASHW_ACTIVE
);
1338 if ( (pfwi
->dwFlags
& FLASHW_TIMERNOFG
) == FLASHW_TIMERNOFG
&&
1339 gpqForeground
== pWnd
->head
.pti
->MessageQueue
)
1341 // Flashing until foreground, set this to Stop.
1342 pfwi
->dwFlags
= FLASHW_STOP
;
1346 // Toggle activate flag.
1347 if ( pfwi
->dwFlags
== FLASHW_STOP
)
1349 if (gpqForeground
&& gpqForeground
->spwndActive
== pWnd
)
1356 Activate
= (FlashState
& FLASHW_ACTIVE
) == 0;
1359 if ( pfwi
->dwFlags
== FLASHW_STOP
|| pfwi
->dwFlags
& FLASHW_CAPTION
)
1361 co_IntSendMessage(UserHMGetHandle(pWnd
), WM_NCACTIVATE
, Activate
, 0);
1364 // FIXME: Check for a Stop Sign here.
1365 if ( pfwi
->dwFlags
& FLASHW_TRAY
)
1367 // Need some shell work here too.
1368 TRACE("FIXME: Flash window no Tray support!\n");
1371 if ( pfwi
->dwFlags
== FLASHW_STOP
)
1373 if (FlashState
& FLASHW_KILLSYSTIMER
)
1375 IntKillTimer(pWnd
, ID_EVENT_SYSTIMER_FLASHWIN
, TRUE
);
1378 UserRemoveProp(pWnd
, AtomFlashWndState
, TRUE
);
1381 { // Have a count and started, set timer.
1384 FlashState
|= FLASHW_COUNT
;
1386 if (!(Activate
^ !!(FlashState
& FLASHW_STARTED
)))
1389 if (!(FlashState
& FLASHW_KILLSYSTIMER
))
1390 pfwi
->dwFlags
|= FLASHW_TIMER
;
1393 if (pfwi
->dwFlags
& FLASHW_TIMER
)
1395 FlashState
|= FLASHW_KILLSYSTIMER
;
1398 ID_EVENT_SYSTIMER_FLASHWIN
,
1399 pfwi
->dwTimeout
? pfwi
->dwTimeout
: gpsi
->dtCaretBlink
,
1404 if (FlashState
& FLASHW_COUNT
&& uCount
== 0)
1406 // Keep spinning? Nothing else to do.
1407 FlashState
= FLASHW_FINISHED
;
1411 // Save state and flags so this can be restored next time through.
1412 FlashState
^= (FlashState
^ -!!(Activate
)) & FLASHW_ACTIVE
;
1413 FlashState
^= (FlashState
^ pfwi
->dwFlags
) & (FLASHW_MASK
& ~FLASHW_TIMER
);
1415 FlashState
= MAKELONG(LOWORD(FlashState
),uCount
);
1416 UserSetProp(pWnd
, AtomFlashWndState
, (HANDLE
)FlashState
, TRUE
);
1422 IntBeginPaint(PWND Window
, PPAINTSTRUCT Ps
)
1428 co_UserHideCaret(Window
);
1430 Window
->state2
|= WNDS2_STARTPAINT
;
1431 Window
->state
&= ~WNDS_PAINTNOTPROCESSED
;
1433 if (Window
->state
& WNDS_SENDNCPAINT
)
1436 // Application can keep update dirty.
1439 Window
->state
&= ~WNDS_UPDATEDIRTY
;
1440 hRgn
= IntGetNCUpdateRgn(Window
, FALSE
);
1441 IntSendNCPaint(Window
, hRgn
);
1442 if (hRgn
> HRGN_WINDOW
&& GreIsHandleValid(hRgn
))
1444 /* NOTE: The region can already be deleted! */
1445 GreDeleteObject(hRgn
);
1448 while(Window
->state
& WNDS_UPDATEDIRTY
);
1452 Window
->state
&= ~WNDS_UPDATEDIRTY
;
1455 RtlZeroMemory(Ps
, sizeof(PAINTSTRUCT
));
1457 if (Window
->state2
& WNDS2_ENDPAINTINVALIDATE
)
1459 ERR("BP: Another thread invalidated this window\n");
1462 Ps
->hdc
= UserGetDCEx( Window
,
1464 DCX_INTERSECTRGN
| DCX_USESTYLE
);
1470 // If set, always clear flags out due to the conditions later on for sending the message.
1471 if (Window
->state
& WNDS_SENDERASEBACKGROUND
)
1473 Window
->state
&= ~(WNDS_SENDERASEBACKGROUND
|WNDS_ERASEBACKGROUND
);
1477 if (Window
->hrgnUpdate
!= NULL
)
1479 MsqDecPaintCountQueue(Window
->head
.pti
);
1480 IntGdiSetRegionOwner(Window
->hrgnUpdate
, GDI_OBJ_HMGR_POWNED
);
1481 /* The region is part of the dc now and belongs to the process! */
1482 Window
->hrgnUpdate
= NULL
;
1486 if (Window
->state
& WNDS_INTERNALPAINT
)
1487 MsqDecPaintCountQueue(Window
->head
.pti
);
1490 type
= GdiGetClipBox(Ps
->hdc
, &Ps
->rcPaint
);
1492 IntGetClientRect(Window
, &Rect
);
1494 Window
->state
&= ~WNDS_INTERNALPAINT
;
1496 if ( Erase
&& // Set to erase,
1497 type
!= NULLREGION
&& // don't erase if the clip box is empty,
1498 (!(Window
->pcls
->style
& CS_PARENTDC
) || // not parent dc or
1499 RECTL_bIntersectRect( &Rect
, &Rect
, &Ps
->rcPaint
) ) ) // intersecting.
1501 Ps
->fErase
= !co_IntSendMessage(UserHMGetHandle(Window
), WM_ERASEBKGND
, (WPARAM
)Ps
->hdc
, 0);
1504 Window
->state
|= (WNDS_SENDERASEBACKGROUND
|WNDS_ERASEBACKGROUND
);
1512 IntSendChildNCPaint(Window
);
1518 IntEndPaint(PWND Wnd
, PPAINTSTRUCT Ps
)
1524 UserReleaseDC(Wnd
, hdc
, TRUE
);
1526 if (Wnd
->state2
& WNDS2_ENDPAINTINVALIDATE
)
1528 ERR("EP: Another thread invalidated this window\n");
1529 Wnd
->state2
&= ~WNDS2_ENDPAINTINVALIDATE
;
1532 Wnd
->state2
&= ~(WNDS2_WMPAINTSENT
|WNDS2_STARTPAINT
);
1534 co_UserShowCaret(Wnd
);
1540 IntFillWindow(PWND pWndParent
,
1551 type
= GdiGetClipBox(hDC
, &Rect
);
1553 IntGetClientRect(pWnd
, &Rect1
);
1555 if ( type
!= NULLREGION
&& // Clip box is not empty,
1556 (!(pWnd
->pcls
->style
& CS_PARENTDC
) || // not parent dc or
1557 RECTL_bIntersectRect( &Rect
, &Rect
, &Rect1
) ) ) // intersecting.
1562 if (!UserIsDesktopWindow(pWndParent
))
1564 x
= pWndParent
->rcClient
.left
- pWnd
->rcClient
.left
;
1565 y
= pWndParent
->rcClient
.top
- pWnd
->rcClient
.top
;
1568 GreSetBrushOrg(hDC
, x
, y
, &ppt
);
1570 if ( hBrush
< (HBRUSH
)CTLCOLOR_MAX
)
1571 hBrush
= GetControlColor( pWndParent
, pWnd
, hDC
, HandleToUlong(hBrush
) + WM_CTLCOLORMSGBOX
);
1573 FillRect(hDC
, &Rect
, hBrush
);
1575 GreSetBrushOrg(hDC
, ppt
.x
, ppt
.y
, NULL
);
1583 /* PUBLIC FUNCTIONS ***********************************************************/
1593 NtUserBeginPaint(HWND hWnd
, PAINTSTRUCT
* UnsafePs
)
1599 USER_REFERENCE_ENTRY Ref
;
1600 DECLARE_RETURN(HDC
);
1602 TRACE("Enter NtUserBeginPaint\n");
1603 UserEnterExclusive();
1605 if (!(Window
= UserGetWindowObject(hWnd
)))
1610 UserRefObjectCo(Window
, &Ref
);
1612 hDC
= IntBeginPaint(Window
, &Ps
);
1614 Status
= MmCopyToCaller(UnsafePs
, &Ps
, sizeof(PAINTSTRUCT
));
1615 if (! NT_SUCCESS(Status
))
1617 SetLastNtError(Status
);
1624 if (Window
) UserDerefObjectCo(Window
);
1626 TRACE("Leave NtUserBeginPaint, ret=%p\n",_ret_
);
1640 NtUserEndPaint(HWND hWnd
, CONST PAINTSTRUCT
* pUnsafePs
)
1642 NTSTATUS Status
= STATUS_SUCCESS
;
1645 USER_REFERENCE_ENTRY Ref
;
1646 DECLARE_RETURN(BOOL
);
1648 TRACE("Enter NtUserEndPaint\n");
1649 UserEnterExclusive();
1651 if (!(Window
= UserGetWindowObject(hWnd
)))
1656 UserRefObjectCo(Window
, &Ref
); // Here for the exception.
1660 ProbeForRead(pUnsafePs
, sizeof(*pUnsafePs
), 1);
1661 RtlCopyMemory(&Ps
, pUnsafePs
, sizeof(PAINTSTRUCT
));
1663 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1665 Status
= _SEH2_GetExceptionCode();
1668 if (!NT_SUCCESS(Status
))
1673 RETURN(IntEndPaint(Window
, &Ps
));
1676 if (Window
) UserDerefObjectCo(Window
);
1678 TRACE("Leave NtUserEndPaint, ret=%i\n",_ret_
);
1684 * FillWindow: Called from User; Dialog, Edit and ListBox procs during a WM_ERASEBKGND.
1690 NtUserFillWindow(HWND hWndParent
,
1696 PWND pWnd
, pWndParent
= NULL
;
1697 USER_REFERENCE_ENTRY Ref
;
1699 TRACE("Enter NtUserFillWindow\n");
1700 UserEnterExclusive();
1707 if (!(pWnd
= UserGetWindowObject(hWnd
)))
1712 if (hWndParent
&& !(pWndParent
= UserGetWindowObject(hWndParent
)))
1717 UserRefObjectCo(pWnd
, &Ref
);
1718 ret
= IntFillWindow( pWndParent
, pWnd
, hDC
, hBrush
);
1719 UserDerefObjectCo(pWnd
);
1722 TRACE("Leave NtUserFillWindow, ret=%i\n",ret
);
1731 NtUserFlashWindowEx(IN PFLASHWINFO pfwi
)
1734 FLASHWINFO finfo
= {0};
1737 UserEnterExclusive();
1741 ProbeForRead(pfwi
, sizeof(FLASHWINFO
), 1);
1742 RtlCopyMemory(&finfo
, pfwi
, sizeof(FLASHWINFO
));
1744 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1746 SetLastNtError(_SEH2_GetExceptionCode());
1747 _SEH2_YIELD(goto Exit
);
1751 if (!( pWnd
= ValidateHwndNoErr(finfo
.hwnd
)) ||
1752 finfo
.cbSize
!= sizeof(FLASHWINFO
) ||
1753 finfo
.dwFlags
& ~(FLASHW_ALL
|FLASHW_TIMER
|FLASHW_TIMERNOFG
) )
1755 EngSetLastError(ERROR_INVALID_PARAMETER
);
1759 Ret
= IntFlashWindowEx(pWnd
, &finfo
);
1767 GetUpdateRgn, this fails the same as the old one.
1770 co_UserGetUpdateRgn(PWND Window
, HRGN hRgn
, BOOL bErase
)
1776 ASSERT_REFS_CO(Window
);
1780 USER_REFERENCE_ENTRY Ref
;
1781 UserRefObjectCo(Window
, &Ref
);
1782 co_IntPaintWindows(Window
, RDW_NOCHILDREN
, FALSE
);
1783 UserDerefObjectCo(Window
);
1786 Window
->state
&= ~WNDS_UPDATEDIRTY
;
1788 if (Window
->hrgnUpdate
== NULL
)
1790 NtGdiSetRectRgn(hRgn
, 0, 0, 0, 0);
1794 Rect
= Window
->rcClient
;
1795 Type
= IntIntersectWithParents(Window
, &Rect
);
1797 if (Window
->hrgnUpdate
== HRGN_WINDOW
)
1800 ERR("GURn: Caller is passing Window Region 1\n");
1803 NtGdiSetRectRgn(hRgn
, 0, 0, 0, 0);
1807 RegionType
= SIMPLEREGION
;
1809 if (!UserIsDesktopWindow(Window
))
1811 RECTL_vOffsetRect(&Rect
,
1812 -Window
->rcClient
.left
,
1813 -Window
->rcClient
.top
);
1815 GreSetRectRgnIndirect(hRgn
, &Rect
);
1819 HRGN hrgnTemp
= GreCreateRectRgnIndirect(&Rect
);
1821 RegionType
= NtGdiCombineRgn(hRgn
, hrgnTemp
, Window
->hrgnUpdate
, RGN_AND
);
1823 if (RegionType
== ERROR
|| RegionType
== NULLREGION
)
1825 if (hrgnTemp
) GreDeleteObject(hrgnTemp
);
1826 NtGdiSetRectRgn(hRgn
, 0, 0, 0, 0);
1830 if (!UserIsDesktopWindow(Window
))
1832 NtGdiOffsetRgn(hRgn
,
1833 -Window
->rcClient
.left
,
1834 -Window
->rcClient
.top
);
1836 if (hrgnTemp
) GreDeleteObject(hrgnTemp
);
1842 co_UserGetUpdateRect(PWND Window
, PRECT pRect
, BOOL bErase
)
1849 USER_REFERENCE_ENTRY Ref
;
1850 UserRefObjectCo(Window
, &Ref
);
1851 co_IntPaintWindows(Window
, RDW_NOCHILDREN
, FALSE
);
1852 UserDerefObjectCo(Window
);
1855 Window
->state
&= ~WNDS_UPDATEDIRTY
;
1857 if (Window
->hrgnUpdate
== NULL
)
1859 pRect
->left
= pRect
->top
= pRect
->right
= pRect
->bottom
= 0;
1864 /* Get the update region bounding box. */
1865 if (Window
->hrgnUpdate
== HRGN_WINDOW
)
1867 *pRect
= Window
->rcClient
;
1868 ERR("GURt: Caller is retrieving Window Region 1\n");
1872 RegionType
= IntGdiGetRgnBox(Window
->hrgnUpdate
, pRect
);
1874 if (RegionType
!= ERROR
&& RegionType
!= NULLREGION
)
1875 RECTL_bIntersectRect(pRect
, pRect
, &Window
->rcClient
);
1878 if (IntIntersectWithParents(Window
, pRect
))
1880 if (!UserIsDesktopWindow(Window
))
1882 RECTL_vOffsetRect(pRect
,
1883 -Window
->rcClient
.left
,
1884 -Window
->rcClient
.top
);
1886 if (Window
->pcls
->style
& CS_OWNDC
)
1890 hdc
= UserGetDCEx(Window
, NULL
, DCX_USESTYLE
);
1891 //layout = NtGdiSetLayout(hdc, -1, 0);
1892 //IntMapWindowPoints( 0, Window, (LPPOINT)pRect, 2 );
1893 GreDPtoLP( hdc
, (LPPOINT
)pRect
, 2 );
1894 //NtGdiSetLayout(hdc, -1, layout);
1895 UserReleaseDC(Window
, hdc
, FALSE
);
1900 pRect
->left
= pRect
->top
= pRect
->right
= pRect
->bottom
= 0;
1907 * NtUserGetUpdateRgn
1914 NtUserGetUpdateRgn(HWND hWnd
, HRGN hRgn
, BOOL bErase
)
1916 DECLARE_RETURN(INT
);
1920 TRACE("Enter NtUserGetUpdateRgn\n");
1921 UserEnterExclusive();
1923 if (!(Window
= UserGetWindowObject(hWnd
)))
1928 ret
= co_UserGetUpdateRgn(Window
, hRgn
, bErase
);
1933 TRACE("Leave NtUserGetUpdateRgn, ret=%i\n",_ret_
);
1939 * NtUserGetUpdateRect
1946 NtUserGetUpdateRect(HWND hWnd
, LPRECT UnsafeRect
, BOOL bErase
)
1952 DECLARE_RETURN(BOOL
);
1954 TRACE("Enter NtUserGetUpdateRect\n");
1955 UserEnterExclusive();
1957 if (!(Window
= UserGetWindowObject(hWnd
)))
1962 Ret
= co_UserGetUpdateRect(Window
, &Rect
, bErase
);
1964 if (UnsafeRect
!= NULL
)
1966 Status
= MmCopyToCaller(UnsafeRect
, &Rect
, sizeof(RECTL
));
1967 if (!NT_SUCCESS(Status
))
1969 EngSetLastError(ERROR_INVALID_PARAMETER
);
1977 TRACE("Leave NtUserGetUpdateRect, ret=%i\n",_ret_
);
1983 * NtUserRedrawWindow
1992 CONST RECT
*lprcUpdate
,
1996 RECTL SafeUpdateRect
;
1999 USER_REFERENCE_ENTRY Ref
;
2000 NTSTATUS Status
= STATUS_SUCCESS
;
2001 PREGION RgnUpdate
= NULL
;
2002 DECLARE_RETURN(BOOL
);
2004 TRACE("Enter NtUserRedrawWindow\n");
2005 UserEnterExclusive();
2007 if (!(Wnd
= UserGetWindowObject(hWnd
? hWnd
: IntGetDesktopWindow())))
2016 ProbeForRead(lprcUpdate
, sizeof(RECTL
), 1);
2017 RtlCopyMemory(&SafeUpdateRect
, lprcUpdate
, sizeof(RECTL
));
2019 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2021 Status
= _SEH2_GetExceptionCode();
2024 if (!NT_SUCCESS(Status
))
2026 EngSetLastError(RtlNtStatusToDosError(Status
));
2031 if ( flags
& ~(RDW_ERASE
|RDW_FRAME
|RDW_INTERNALPAINT
|RDW_INVALIDATE
|
2032 RDW_NOERASE
|RDW_NOFRAME
|RDW_NOINTERNALPAINT
|RDW_VALIDATE
|
2033 RDW_ERASENOW
|RDW_UPDATENOW
|RDW_ALLCHILDREN
|RDW_NOCHILDREN
) )
2035 /* RedrawWindow fails only in case that flags are invalid */
2036 EngSetLastError(ERROR_INVALID_FLAGS
);
2040 /* We can't hold lock on GDI objects while doing roundtrips to user mode,
2041 * so it will be copied.
2043 if (hrgnUpdate
> HRGN_WINDOW
)
2045 RgnUpdate
= REGION_LockRgn(hrgnUpdate
);
2048 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2051 REGION_UnlockRgn(RgnUpdate
);
2053 else if (hrgnUpdate
== HRGN_WINDOW
) // Trap it out.
2055 ERR("NTRW: Caller is passing Window Region 1\n");
2058 UserRefObjectCo(Wnd
, &Ref
);
2060 Ret
= co_UserRedrawWindow( Wnd
,
2061 lprcUpdate
? &SafeUpdateRect
: NULL
,
2065 UserDerefObjectCo(Wnd
);
2070 TRACE("Leave NtUserRedrawWindow, ret=%i\n",_ret_
);
2076 UserDrawCaptionText(
2079 const PUNICODE_STRING Text
,
2084 HFONT hOldFont
= NULL
;
2085 COLORREF OldTextColor
;
2086 NONCLIENTMETRICSW nclm
;
2088 BOOLEAN bDeleteFont
= FALSE
;
2091 ULONG fit
= 0, Length
;
2094 TRACE("UserDrawCaptionText: %wZ\n", Text
);
2096 nclm
.cbSize
= sizeof(nclm
);
2097 if (!UserSystemParametersInfo(SPI_GETNONCLIENTMETRICS
, nclm
.cbSize
, &nclm
, 0))
2099 ERR("UserSystemParametersInfo() failed!\n");
2105 if(uFlags
& DC_SMALLCAP
)
2106 Status
= TextIntCreateFontIndirect(&nclm
.lfSmCaptionFont
, &hFont
);
2108 Status
= TextIntCreateFontIndirect(&nclm
.lfCaptionFont
, &hFont
);
2110 if(!NT_SUCCESS(Status
))
2112 ERR("TextIntCreateFontIndirect() failed! Status: 0x%x\n", Status
);
2119 IntGdiSetBkMode(hDc
, TRANSPARENT
);
2121 hOldFont
= NtGdiSelectFont(hDc
, hFont
);
2123 if(uFlags
& DC_INBUTTON
)
2124 OldTextColor
= IntGdiSetTextColor(hDc
, IntGetSysColor(COLOR_BTNTEXT
));
2126 OldTextColor
= IntGdiSetTextColor(hDc
,
2127 IntGetSysColor(uFlags
& DC_ACTIVE
? COLOR_CAPTIONTEXT
: COLOR_INACTIVECAPTIONTEXT
));
2129 // Adjust for system menu.
2130 if (pWnd
&& pWnd
->style
& WS_SYSMENU
)
2132 r
.right
-= UserGetSystemMetrics(SM_CYCAPTION
) - 1;
2133 if ((pWnd
->style
& (WS_MAXIMIZEBOX
| WS_MINIMIZEBOX
)) && !(pWnd
->ExStyle
& WS_EX_TOOLWINDOW
))
2135 r
.right
-= UserGetSystemMetrics(SM_CXSIZE
) + 1;
2136 r
.right
-= UserGetSystemMetrics(SM_CXSIZE
) + 1;
2140 GreGetTextExtentExW(hDc
, Text
->Buffer
, Text
->Length
/sizeof(WCHAR
), r
.right
- r
.left
, &fit
, 0, &Size
, 0);
2142 Length
= (Text
->Length
/sizeof(WCHAR
) == fit
? fit
: fit
+1);
2144 if (Text
->Length
/sizeof(WCHAR
) > Length
)
2150 { // Faster while in setup.
2151 UserExtTextOutW( hDc
,
2153 lpRc
->top
+ (lpRc
->bottom
- lpRc
->top
- Size
.cy
) / 2, // DT_SINGLELINE && DT_VCENTER
2163 Text
->Length
/sizeof(WCHAR
),
2165 DT_END_ELLIPSIS
|DT_SINGLELINE
|DT_VCENTER
|DT_NOPREFIX
|DT_LEFT
);
2168 IntGdiSetTextColor(hDc
, OldTextColor
);
2171 NtGdiSelectFont(hDc
, hOldFont
);
2174 GreDeleteObject(hFont
);
2180 // This draws Buttons, Icons and Text...
2182 BOOL
UserDrawCaption(
2188 const PUNICODE_STRING Str
,
2192 HBRUSH hBgBrush
, hOldBrush
= NULL
;
2196 RECTL_vMakeWellOrdered(lpRc
);
2198 /* Determine whether the icon needs to be displayed */
2199 if (!hIcon
&& pWnd
!= NULL
)
2201 HasIcon
= (uFlags
& DC_ICON
) && !(uFlags
& DC_SMALLCAP
) &&
2202 (pWnd
->style
& WS_SYSMENU
) && !(pWnd
->ExStyle
& WS_EX_TOOLWINDOW
);
2205 HasIcon
= (hIcon
!= NULL
);
2207 // Draw the caption background
2208 if((uFlags
& DC_GRADIENT
) && !(uFlags
& DC_INBUTTON
))
2210 static GRADIENT_RECT gcap
= {0, 1};
2211 TRIVERTEX Vertices
[2];
2214 Colors
[0] = IntGetSysColor((uFlags
& DC_ACTIVE
) ?
2215 COLOR_ACTIVECAPTION
: COLOR_INACTIVECAPTION
);
2217 Colors
[1] = IntGetSysColor((uFlags
& DC_ACTIVE
) ?
2218 COLOR_GRADIENTACTIVECAPTION
: COLOR_GRADIENTINACTIVECAPTION
);
2220 Vertices
[0].x
= Rect
.left
;
2221 Vertices
[0].y
= Rect
.top
;
2222 Vertices
[0].Red
= (WORD
)Colors
[0]<<8;
2223 Vertices
[0].Green
= (WORD
)Colors
[0] & 0xFF00;
2224 Vertices
[0].Blue
= (WORD
)(Colors
[0]>>8) & 0xFF00;
2225 Vertices
[0].Alpha
= 0;
2227 Vertices
[1].x
= Rect
.right
;
2228 Vertices
[1].y
= Rect
.bottom
;
2229 Vertices
[1].Red
= (WORD
)Colors
[1]<<8;
2230 Vertices
[1].Green
= (WORD
)Colors
[1] & 0xFF00;
2231 Vertices
[1].Blue
= (WORD
)(Colors
[1]>>8) & 0xFF00;
2232 Vertices
[1].Alpha
= 0;
2234 if(!GreGradientFill(hDc
, Vertices
, 2, &gcap
, 1, GRADIENT_FILL_RECT_H
))
2236 ERR("GreGradientFill() failed!\n");
2242 if(uFlags
& DC_INBUTTON
)
2243 hBgBrush
= IntGetSysColorBrush(COLOR_3DFACE
);
2244 else if(uFlags
& DC_ACTIVE
)
2245 hBgBrush
= IntGetSysColorBrush(COLOR_ACTIVECAPTION
);
2247 hBgBrush
= IntGetSysColorBrush(COLOR_INACTIVECAPTION
);
2249 hOldBrush
= NtGdiSelectBrush(hDc
, hBgBrush
);
2253 ERR("NtGdiSelectBrush() failed!\n");
2257 if(!NtGdiPatBlt(hDc
, Rect
.left
, Rect
.top
,
2258 Rect
.right
- Rect
.left
,
2259 Rect
.bottom
- Rect
.top
,
2262 ERR("NtGdiPatBlt() failed!\n");
2270 PCURICON_OBJECT pIcon
= NULL
;
2274 pIcon
= UserGetCurIconObject(hIcon
);
2278 pIcon
= NC_IconForWindow(pWnd
);
2279 // FIXME: NC_IconForWindow should reference it for us */
2281 UserReferenceObject(pIcon
);
2286 LONG cx
= UserGetSystemMetrics(SM_CXSMICON
);
2287 LONG cy
= UserGetSystemMetrics(SM_CYSMICON
);
2288 LONG x
= Rect
.left
- cx
/2 + 1 + (Rect
.bottom
- Rect
.top
)/2; // this is really what Window does
2289 LONG y
= (Rect
.top
+ Rect
.bottom
- cy
)/2; // center
2290 UserDrawIconEx(hDc
, x
, y
, pIcon
, cx
, cy
, 0, NULL
, DI_NORMAL
);
2291 UserDereferenceObject(pIcon
);
2300 Rect
.left
+= Rect
.bottom
- Rect
.top
;
2302 if((uFlags
& DC_TEXT
))
2308 Set
= UserDrawCaptionText(pWnd
, hDc
, Str
, &Rect
, uFlags
, hFont
);
2309 else if (pWnd
!= NULL
) // FIXME: Windows does not do that
2311 UNICODE_STRING ustr
;
2312 ustr
.Buffer
= pWnd
->strName
.Buffer
; // FIXME: LARGE_STRING truncated!
2313 ustr
.Length
= (USHORT
)min(pWnd
->strName
.Length
, MAXUSHORT
);
2314 ustr
.MaximumLength
= (USHORT
)min(pWnd
->strName
.MaximumLength
, MAXUSHORT
);
2315 Set
= UserDrawCaptionText(pWnd
, hDc
, &ustr
, &Rect
, uFlags
, hFont
);
2320 pWnd
->state2
&= ~WNDS2_CAPTIONTEXTTRUNCATED
;
2322 pWnd
->state2
|= WNDS2_CAPTIONTEXTTRUNCATED
;
2329 if (hOldBrush
) NtGdiSelectBrush(hDc
, hOldBrush
);
2336 UserRealizePalette(HDC hdc
)
2338 HWND hWnd
, hWndDesktop
;
2341 Ret
= IntGdiRealizePalette(hdc
);
2342 if (Ret
) // There was a change.
2344 hWnd
= IntWindowFromDC(hdc
);
2345 if (hWnd
) // Send broadcast if dc is associated with a window.
2346 { // FYI: Thread locked in CallOneParam.
2347 hWndDesktop
= IntGetDesktopWindow();
2348 if ( hWndDesktop
!= hWnd
)
2350 PWND pWnd
= UserGetWindowObject(hWndDesktop
);
2351 ERR("RealizePalette Desktop.");
2352 hdc
= UserGetWindowDC(pWnd
);
2353 IntPaintDesktop(hdc
);
2354 UserReleaseDC(pWnd
,hdc
,FALSE
);
2356 UserSendNotifyMessage((HWND
)HWND_BROADCAST
, WM_PALETTECHANGED
, (WPARAM
)hWnd
, 0);
2364 NtUserDrawCaptionTemp(
2370 const PUNICODE_STRING str
,
2374 UNICODE_STRING SafeStr
= {0};
2375 NTSTATUS Status
= STATUS_SUCCESS
;
2379 UserEnterExclusive();
2383 if(!(pWnd
= UserGetWindowObject(hWnd
)))
2392 ProbeForRead(lpRc
, sizeof(RECTL
), sizeof(ULONG
));
2393 RtlCopyMemory(&SafeRect
, lpRc
, sizeof(RECTL
));
2396 SafeStr
= ProbeForReadUnicodeString(str
);
2397 if (SafeStr
.Length
!= 0)
2399 ProbeForRead( SafeStr
.Buffer
,
2405 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2407 Status
= _SEH2_GetExceptionCode();
2411 if (Status
!= STATUS_SUCCESS
)
2413 SetLastNtError(Status
);
2419 Ret
= UserDrawCaption(pWnd
, hDC
, &SafeRect
, hFont
, hIcon
, &SafeStr
, uFlags
);
2422 if ( RECTL_bIsEmptyRect(&SafeRect
) && hFont
== 0 && hIcon
== 0 )
2425 if (uFlags
& DC_DRAWCAPTIONMD
)
2427 ERR("NC Caption Mode\n");
2428 UserDrawCaptionBar(pWnd
, hDC
, uFlags
);
2431 else if (uFlags
& DC_DRAWFRAMEMD
)
2433 ERR("NC Paint Mode\n");
2434 NC_DoNCPaint(pWnd
, hDC
, uFlags
); // Update Menus too!
2438 Ret
= UserDrawCaption(pWnd
, hDC
, &SafeRect
, hFont
, hIcon
, NULL
, uFlags
);
2447 NtUserDrawCaption(HWND hWnd
,
2452 return NtUserDrawCaptionTemp(hWnd
, hDC
, lpRc
, 0, 0, NULL
, uFlags
);
2456 co_UserExcludeUpdateRgn(HDC hDC
, PWND Window
)
2461 if (Window
->hrgnUpdate
)
2463 if (Window
->hrgnUpdate
== HRGN_WINDOW
)
2465 return NtGdiIntersectClipRect(hDC
, 0, 0, 0, 0);
2470 HRGN hrgn
= NtGdiCreateRectRgn(0,0,0,0);
2472 if ( hrgn
&& GreGetDCPoint( hDC
, GdiGetDCOrg
, &pt
) )
2474 if ( NtGdiGetRandomRgn( hDC
, hrgn
, CLIPRGN
) == NULLREGION
)
2476 NtGdiOffsetRgn(hrgn
, pt
.x
, pt
.y
);
2481 PMONITOR pm
= UserGetPrimaryMonitor();
2482 hrgnScreen
= NtGdiCreateRectRgn(0,0,0,0);
2483 NtGdiCombineRgn(hrgnScreen
, hrgnScreen
, pm
->hrgnMonitor
, RGN_OR
);
2485 NtGdiCombineRgn(hrgn
, hrgnScreen
, NULL
, RGN_COPY
);
2487 GreDeleteObject(hrgnScreen
);
2490 NtGdiCombineRgn(hrgn
, hrgn
, Window
->hrgnUpdate
, RGN_DIFF
);
2492 NtGdiOffsetRgn(hrgn
, -pt
.x
, -pt
.y
);
2494 ret
= NtGdiExtSelectClipRgn(hDC
, hrgn
, RGN_COPY
);
2496 GreDeleteObject(hrgn
);
2503 return GdiGetClipBox( hDC
, &rc
);
2509 NtUserExcludeUpdateRgn(
2516 TRACE("Enter NtUserExcludeUpdateRgn\n");
2517 UserEnterExclusive();
2519 pWnd
= UserGetWindowObject(hWnd
);
2522 ret
= co_UserExcludeUpdateRgn(hDC
, pWnd
);
2524 TRACE("Leave NtUserExcludeUpdateRgn, ret=%i\n", ret
);
2532 NtUserInvalidateRect(
2534 CONST RECT
*lpUnsafeRect
,
2537 UINT flags
= RDW_INVALIDATE
| (bErase
? RDW_ERASE
: 0);
2540 flags
= RDW_ALLCHILDREN
| RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
;
2541 lpUnsafeRect
= NULL
;
2543 return NtUserRedrawWindow(hWnd
, lpUnsafeRect
, NULL
, flags
);
2548 NtUserInvalidateRgn(
2555 EngSetLastError( ERROR_INVALID_WINDOW_HANDLE
);
2558 return NtUserRedrawWindow(hWnd
, NULL
, hRgn
, RDW_INVALIDATE
| (bErase
? RDW_ERASE
: 0));
2571 UserEnterExclusive();
2575 if (!(Window
= UserGetWindowObject(hwnd
)) ||
2576 UserIsDesktopWindow(Window
) || UserIsMessageWindow(Window
))
2583 /* Validate flags and check it as a mask for 0 or 1. */
2584 if ( (nFlags
& PW_CLIENTONLY
) == nFlags
)
2585 Ret
= IntPrintWindow( Window
, hdcBlt
, nFlags
);
2587 EngSetLastError(ERROR_INVALID_PARAMETER
);
2595 /* ValidateRect gets redirected to NtUserValidateRect:
2596 http://blog.csdn.net/ntdll/archive/2005/10/19/509299.aspx */
2603 UINT flags
= RDW_VALIDATE
;
2606 flags
= RDW_ALLCHILDREN
| RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
;
2609 return NtUserRedrawWindow(hWnd
, lpRect
, NULL
, flags
);