2 * Window painting functions
4 * Copyright 1993, 1994, 1995, 2001, 2004, 2005, 2008 Alexandre Julliard
5 * Copyright 1996, 1997, 1999 Alex Korobka
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
30 #define WIN32_NO_STATUS
35 #include "wine/server.h"
37 #include "user_private.h"
39 #include "wine/list.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(win
);
47 struct list entry
; /* entry in global DCE list */
52 LONG count
; /* usage count; 0 or 1 for cache DCEs, always 1 for window DCEs,
53 always >= 1 for class DCEs */
56 static struct list dce_list
= LIST_INIT(dce_list
);
58 static BOOL CALLBACK
dc_hook( HDC hDC
, WORD code
, DWORD_PTR data
, LPARAM lParam
);
60 static const WCHAR displayW
[] = { 'D','I','S','P','L','A','Y',0 };
63 /***********************************************************************
66 static void dump_rdw_flags(UINT flags
)
69 if (flags
& RDW_INVALIDATE
) TRACE(" RDW_INVALIDATE");
70 if (flags
& RDW_INTERNALPAINT
) TRACE(" RDW_INTERNALPAINT");
71 if (flags
& RDW_ERASE
) TRACE(" RDW_ERASE");
72 if (flags
& RDW_VALIDATE
) TRACE(" RDW_VALIDATE");
73 if (flags
& RDW_NOINTERNALPAINT
) TRACE(" RDW_NOINTERNALPAINT");
74 if (flags
& RDW_NOERASE
) TRACE(" RDW_NOERASE");
75 if (flags
& RDW_NOCHILDREN
) TRACE(" RDW_NOCHILDREN");
76 if (flags
& RDW_ALLCHILDREN
) TRACE(" RDW_ALLCHILDREN");
77 if (flags
& RDW_UPDATENOW
) TRACE(" RDW_UPDATENOW");
78 if (flags
& RDW_ERASENOW
) TRACE(" RDW_ERASENOW");
79 if (flags
& RDW_FRAME
) TRACE(" RDW_FRAME");
80 if (flags
& RDW_NOFRAME
) TRACE(" RDW_NOFRAME");
87 RDW_NOINTERNALPAINT | \
96 if (flags
& ~RDW_FLAGS
) TRACE(" %04x", flags
& ~RDW_FLAGS
);
102 /***********************************************************************
103 * update_visible_region
105 * Set the visible region and X11 drawable for the DC associated to
108 static void update_visible_region( struct dce
*dce
)
113 DWORD flags
= dce
->flags
;
115 RECT win_rect
, top_rect
;
117 /* don't clip siblings if using parent clip region */
118 if (flags
& DCX_PARENTCLIP
) flags
&= ~DCX_CLIPSIBLINGS
;
120 /* fetch the visible region from the server */
123 RGNDATA
*data
= HeapAlloc( GetProcessHeap(), 0, sizeof(*data
) + size
- 1 );
126 SERVER_START_REQ( get_visible_region
)
128 req
->window
= wine_server_user_handle( dce
->hwnd
);
130 wine_server_set_reply( req
, data
->Buffer
, size
);
131 if (!(status
= wine_server_call( req
)))
133 size_t reply_size
= wine_server_reply_size( reply
);
134 data
->rdh
.dwSize
= sizeof(data
->rdh
);
135 data
->rdh
.iType
= RDH_RECTANGLES
;
136 data
->rdh
.nCount
= reply_size
/ sizeof(RECT
);
137 data
->rdh
.nRgnSize
= reply_size
;
138 vis_rgn
= ExtCreateRegion( NULL
, size
, data
);
140 top_win
= wine_server_ptr_handle( reply
->top_win
);
141 win_rect
.left
= reply
->win_rect
.left
;
142 win_rect
.top
= reply
->win_rect
.top
;
143 win_rect
.right
= reply
->win_rect
.right
;
144 win_rect
.bottom
= reply
->win_rect
.bottom
;
145 top_rect
.left
= reply
->top_rect
.left
;
146 top_rect
.top
= reply
->top_rect
.top
;
147 top_rect
.right
= reply
->top_rect
.right
;
148 top_rect
.bottom
= reply
->top_rect
.bottom
;
150 else size
= reply
->total_size
;
153 HeapFree( GetProcessHeap(), 0, data
);
154 } while (status
== STATUS_BUFFER_OVERFLOW
);
156 if (status
|| !vis_rgn
) return;
158 USER_Driver
->pGetDC( dce
->hdc
, dce
->hwnd
, top_win
, &win_rect
, &top_rect
, flags
);
160 if (dce
->clip_rgn
) CombineRgn( vis_rgn
, vis_rgn
, dce
->clip_rgn
,
161 (flags
& DCX_INTERSECTRGN
) ? RGN_AND
: RGN_DIFF
);
163 /* map region to DC coordinates */
164 OffsetRgn( vis_rgn
, -win_rect
.left
, -win_rect
.top
);
165 SelectVisRgn( dce
->hdc
, vis_rgn
);
166 DeleteObject( vis_rgn
);
170 /***********************************************************************
173 static void reset_dce_attrs( struct dce
*dce
)
175 RestoreDC( dce
->hdc
, 1 ); /* initial save level is always 1 */
176 SaveDC( dce
->hdc
); /* save the state again for next time */
180 /***********************************************************************
183 static void release_dce( struct dce
*dce
)
185 if (!dce
->hwnd
) return; /* already released */
187 USER_Driver
->pReleaseDC( dce
->hwnd
, dce
->hdc
);
189 if (dce
->clip_rgn
) DeleteObject( dce
->clip_rgn
);
192 dce
->flags
&= DCX_CACHE
;
196 /***********************************************************************
199 static void delete_clip_rgn( struct dce
*dce
)
201 if (!dce
->clip_rgn
) return; /* nothing to do */
203 dce
->flags
&= ~(DCX_EXCLUDERGN
| DCX_INTERSECTRGN
);
204 DeleteObject( dce
->clip_rgn
);
207 /* make it dirty so that the vis rgn gets recomputed next time */
208 SetHookFlags( dce
->hdc
, DCHF_INVALIDATEVISRGN
);
212 /***********************************************************************
215 * Allocate a new DCE.
217 static struct dce
*alloc_dce(void)
221 if (!(dce
= HeapAlloc( GetProcessHeap(), 0, sizeof(*dce
) ))) return NULL
;
222 if (!(dce
->hdc
= CreateDCW( displayW
, NULL
, NULL
, NULL
)))
224 HeapFree( GetProcessHeap(), 0, dce
);
234 /* store DCE handle in DC hook data field */
235 SetDCHook( dce
->hdc
, dc_hook
, (DWORD_PTR
)dce
);
236 SetHookFlags( dce
->hdc
, DCHF_INVALIDATEVISRGN
);
241 /***********************************************************************
244 static struct dce
*get_window_dce( HWND hwnd
)
247 WND
*win
= WIN_GetPtr( hwnd
);
249 if (!win
|| win
== WND_OTHER_PROCESS
|| win
== WND_DESKTOP
) return NULL
;
252 if (!dce
&& (dce
= get_class_dce( win
->class )))
257 WIN_ReleasePtr( win
);
259 if (!dce
) /* try to allocate one */
261 struct dce
*dce_to_free
= NULL
;
262 LONG class_style
= GetClassLongW( hwnd
, GCL_STYLE
);
264 if (class_style
& CS_CLASSDC
)
266 if (!(dce
= alloc_dce())) return NULL
;
268 win
= WIN_GetPtr( hwnd
);
269 if (win
&& win
!= WND_OTHER_PROCESS
&& win
!= WND_DESKTOP
)
271 if (win
->dce
) /* another thread beat us to it */
276 else if ((win
->dce
= set_class_dce( win
->class, dce
)) != dce
)
285 list_add_tail( &dce_list
, &dce
->entry
);
287 WIN_ReleasePtr( win
);
289 else dce_to_free
= dce
;
291 else if (class_style
& CS_OWNDC
)
293 if (!(dce
= alloc_dce())) return NULL
;
295 win
= WIN_GetPtr( hwnd
);
296 if (win
&& win
!= WND_OTHER_PROCESS
&& win
!= WND_DESKTOP
)
298 if (win
->dwStyle
& WS_CLIPCHILDREN
) dce
->flags
|= DCX_CLIPCHILDREN
;
299 if (win
->dwStyle
& WS_CLIPSIBLINGS
) dce
->flags
|= DCX_CLIPSIBLINGS
;
300 if (win
->dce
) /* another thread beat us to it */
310 list_add_tail( &dce_list
, &dce
->entry
);
312 WIN_ReleasePtr( win
);
314 else dce_to_free
= dce
;
319 SetDCHook( dce
->hdc
, NULL
, 0 );
320 DeleteDC( dce
->hdc
);
321 HeapFree( GetProcessHeap(), 0, dce
);
328 /***********************************************************************
331 * Free a class or window DCE.
333 void free_dce( struct dce
*dce
, HWND hwnd
)
341 /* turn it into a cache entry */
342 reset_dce_attrs( dce
);
344 dce
->flags
|= DCX_CACHE
;
346 else if (dce
->hwnd
== hwnd
)
352 /* now check for cache DCEs */
356 LIST_FOR_EACH_ENTRY( dce
, &dce_list
, struct dce
, entry
)
358 if (dce
->hwnd
!= hwnd
) continue;
359 if (!(dce
->flags
& DCX_CACHE
)) continue;
361 if (dce
->count
) WARN( "GetDC() without ReleaseDC() for window %p\n", hwnd
);
371 /***********************************************************************
374 * Mark the associated DC as dirty to force a refresh of the visible region
376 static void make_dc_dirty( struct dce
*dce
)
380 /* Don't bother with visible regions of unused DCEs */
381 TRACE("\tpurged %p dce [%p]\n", dce
, dce
->hwnd
);
386 /* Set dirty bits in the hDC and DCE structs */
387 TRACE("\tfixed up %p dce [%p]\n", dce
, dce
->hwnd
);
388 SetHookFlags( dce
->hdc
, DCHF_INVALIDATEVISRGN
);
393 /***********************************************************************
396 * It is called from SetWindowPos() - we have to
397 * mark as dirty all busy DCEs for windows that have pWnd->parent as
398 * an ancestor and whose client rect intersects with specified update
399 * rectangle. In addition, pWnd->parent DCEs may need to be updated if
400 * DCX_CLIPCHILDREN flag is set.
402 void invalidate_dce( HWND hwnd
, const RECT
*rect
)
404 RECT window_rect
, extra_rect
;
406 HWND hwndScope
= GetAncestor( hwnd
, GA_PARENT
);
408 if (!hwndScope
) return;
410 GetWindowRect( hwnd
, &window_rect
);
414 MapWindowPoints( hwndScope
, 0, (POINT
*)&extra_rect
, 2 );
417 TRACE("%p scope hwnd = %p %s (%s)\n",
418 hwnd
, hwndScope
, wine_dbgstr_rect(&window_rect
), wine_dbgstr_rect(rect
) );
420 /* walk all DCEs and fixup non-empty entries */
423 LIST_FOR_EACH_ENTRY( dce
, &dce_list
, struct dce
, entry
)
425 TRACE( "%p: hwnd %p dcx %08x %s %s\n", dce
, dce
->hwnd
, dce
->flags
,
426 (dce
->flags
& DCX_CACHE
) ? "Cache" : "Owned", dce
->count
? "InUse" : "" );
428 if (!dce
->hwnd
) continue;
429 if ((dce
->hwnd
== hwndScope
) && !(dce
->flags
& DCX_CLIPCHILDREN
))
430 continue; /* child window positions don't bother us */
432 /* if DCE window is a child of hwnd, it has to be invalidated */
433 if (dce
->hwnd
== hwnd
|| IsChild( hwnd
, dce
->hwnd
))
435 make_dc_dirty( dce
);
437 else /* otherwise check if the window rectangle intersects this DCE window */
439 if (hwndScope
== GetDesktopWindow() ||
440 hwndScope
== dce
->hwnd
|| IsChild( hwndScope
, dce
->hwnd
))
443 GetWindowRect( dce
->hwnd
, &dce_rect
);
444 if (IntersectRect( &tmp
, &dce_rect
, &window_rect
) ||
445 (rect
&& IntersectRect( &tmp
, &dce_rect
, &extra_rect
)))
446 make_dc_dirty( dce
);
453 /***********************************************************************
456 * Implementation of ReleaseDC.
458 static INT
release_dc( HWND hwnd
, HDC hdc
, BOOL end_paint
)
463 TRACE("%p %p\n", hwnd
, hdc
);
466 dce
= (struct dce
*)GetDCHook( hdc
, NULL
);
467 if (dce
&& dce
->count
)
469 if (!(dce
->flags
& DCX_NORESETATTRS
)) reset_dce_attrs( dce
);
470 if (end_paint
|| (dce
->flags
& DCX_CACHE
)) delete_clip_rgn( dce
);
471 if (dce
->flags
& DCX_CACHE
) dce
->count
= 0;
479 /***********************************************************************
482 * See "Undoc. Windows" for hints (DC, SetDCHook, SetHookFlags)..
484 static BOOL CALLBACK
dc_hook( HDC hDC
, WORD code
, DWORD_PTR data
, LPARAM lParam
)
487 struct dce
*dce
= (struct dce
*)data
;
489 TRACE("hDC = %p, %u\n", hDC
, code
);
492 assert( dce
->hdc
== hDC
);
496 case DCHC_INVALIDVISRGN
:
497 /* GDI code calls this when it detects that the
498 * DC is dirty (usually after SetHookFlags()). This
499 * means that we have to recompute the visible region.
501 if (dce
->count
) update_visible_region( dce
);
502 else /* non-fatal but shouldn't happen */
503 WARN("DC is not in use!\n");
507 * Windows will not let you delete a DC that is busy
508 * (between GetDC and ReleaseDC)
513 WARN("Application trying to delete a busy DC %p\n", dce
->hdc
);
518 list_remove( &dce
->entry
);
519 if (dce
->clip_rgn
) DeleteObject( dce
->clip_rgn
);
520 HeapFree( GetProcessHeap(), 0, dce
);
529 /***********************************************************************
532 * Return update region (in screen coordinates) for a window.
534 static HRGN
get_update_region( HWND hwnd
, UINT
*flags
, HWND
*child
)
543 if (!(data
= HeapAlloc( GetProcessHeap(), 0, sizeof(*data
) + size
- 1 )))
545 SetLastError( ERROR_OUTOFMEMORY
);
549 SERVER_START_REQ( get_update_region
)
551 req
->window
= wine_server_user_handle( hwnd
);
552 req
->from_child
= wine_server_user_handle( child
? *child
: 0 );
554 wine_server_set_reply( req
, data
->Buffer
, size
);
555 if (!(status
= wine_server_call( req
)))
557 size_t reply_size
= wine_server_reply_size( reply
);
558 data
->rdh
.dwSize
= sizeof(data
->rdh
);
559 data
->rdh
.iType
= RDH_RECTANGLES
;
560 data
->rdh
.nCount
= reply_size
/ sizeof(RECT
);
561 data
->rdh
.nRgnSize
= reply_size
;
562 hrgn
= ExtCreateRegion( NULL
, size
, data
);
563 if (child
) *child
= wine_server_ptr_handle( reply
->child
);
564 *flags
= reply
->flags
;
566 else size
= reply
->total_size
;
569 HeapFree( GetProcessHeap(), 0, data
);
570 } while (status
== STATUS_BUFFER_OVERFLOW
);
572 if (status
) SetLastError( RtlNtStatusToDosError(status
) );
577 /***********************************************************************
580 * Get only the update flags, not the update region.
582 static BOOL
get_update_flags( HWND hwnd
, HWND
*child
, UINT
*flags
)
586 SERVER_START_REQ( get_update_region
)
588 req
->window
= wine_server_user_handle( hwnd
);
589 req
->from_child
= wine_server_user_handle( child
? *child
: 0 );
590 req
->flags
= *flags
| UPDATE_NOREGION
;
591 if ((ret
= !wine_server_call_err( req
)))
593 if (child
) *child
= wine_server_ptr_handle( reply
->child
);
594 *flags
= reply
->flags
;
602 /***********************************************************************
603 * redraw_window_rects
605 * Redraw part of a window.
607 static BOOL
redraw_window_rects( HWND hwnd
, UINT flags
, const RECT
*rects
, UINT count
)
611 if (!(flags
& (RDW_INVALIDATE
|RDW_VALIDATE
|RDW_INTERNALPAINT
|RDW_NOINTERNALPAINT
)))
612 return TRUE
; /* nothing to do */
614 SERVER_START_REQ( redraw_window
)
616 req
->window
= wine_server_user_handle( hwnd
);
618 wine_server_add_data( req
, rects
, count
* sizeof(RECT
) );
619 ret
= !wine_server_call_err( req
);
626 /***********************************************************************
629 * Send a WM_NCPAINT message if needed, and return the resulting update region (in screen coords).
630 * Helper for erase_now and BeginPaint.
632 static HRGN
send_ncpaint( HWND hwnd
, HWND
*child
, UINT
*flags
)
634 HRGN whole_rgn
= get_update_region( hwnd
, flags
, child
);
637 if (child
) hwnd
= *child
;
639 if (hwnd
== GetDesktopWindow()) return whole_rgn
;
646 /* check if update rgn overlaps with nonclient area */
647 type
= GetRgnBox( whole_rgn
, &update
);
648 GetClientRect( hwnd
, &client
);
649 MapWindowPoints( hwnd
, 0, (POINT
*)&client
, 2 );
651 if ((*flags
& UPDATE_NONCLIENT
) ||
652 update
.left
< client
.left
|| update
.top
< client
.top
||
653 update
.right
> client
.right
|| update
.bottom
> client
.bottom
)
655 client_rgn
= CreateRectRgnIndirect( &client
);
656 CombineRgn( client_rgn
, client_rgn
, whole_rgn
, RGN_AND
);
658 /* check if update rgn contains complete nonclient area */
659 if (type
== SIMPLEREGION
)
662 GetWindowRect( hwnd
, &window
);
663 if (EqualRect( &window
, &update
))
665 DeleteObject( whole_rgn
);
672 client_rgn
= whole_rgn
;
676 if (whole_rgn
) /* NOTE: WM_NCPAINT allows wParam to be 1 */
678 if (*flags
& UPDATE_NONCLIENT
) SendMessageW( hwnd
, WM_NCPAINT
, (WPARAM
)whole_rgn
, 0 );
679 if (whole_rgn
> (HRGN
)1) DeleteObject( whole_rgn
);
686 /***********************************************************************
689 * Send a WM_ERASEBKGND message if needed, and optionally return the DC for painting.
690 * If a DC is requested, the region is selected into it. In all cases the region is deleted.
691 * Helper for erase_now and BeginPaint.
693 static BOOL
send_erase( HWND hwnd
, UINT flags
, HRGN client_rgn
,
694 RECT
*clip_rect
, HDC
*hdc_ret
)
696 BOOL need_erase
= (flags
& UPDATE_DELAYED_ERASE
) != 0;
700 if (!clip_rect
) clip_rect
= &dummy
;
701 if (hdc_ret
|| (flags
& UPDATE_ERASE
))
703 UINT dcx_flags
= DCX_INTERSECTRGN
| DCX_USESTYLE
;
704 if (IsIconic(hwnd
)) dcx_flags
|= DCX_WINDOW
;
706 if ((hdc
= GetDCEx( hwnd
, client_rgn
, dcx_flags
)))
708 INT type
= GetClipBox( hdc
, clip_rect
);
710 if (flags
& UPDATE_ERASE
)
712 /* don't erase if the clip box is empty */
713 if (type
!= NULLREGION
)
714 need_erase
= !SendMessageW( hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0 );
716 if (!hdc_ret
) release_dc( hwnd
, hdc
, TRUE
);
719 if (hdc_ret
) *hdc_ret
= hdc
;
721 if (!hdc
) DeleteObject( client_rgn
);
726 /***********************************************************************
729 * Implementation of RDW_ERASENOW behavior.
731 void erase_now( HWND hwnd
, UINT rdw_flags
)
735 BOOL need_erase
= FALSE
;
737 /* loop while we find a child to repaint */
740 UINT flags
= UPDATE_NONCLIENT
| UPDATE_ERASE
;
742 if (rdw_flags
& RDW_NOCHILDREN
) flags
|= UPDATE_NOCHILDREN
;
743 else if (rdw_flags
& RDW_ALLCHILDREN
) flags
|= UPDATE_ALLCHILDREN
;
744 if (need_erase
) flags
|= UPDATE_DELAYED_ERASE
;
746 if (!(hrgn
= send_ncpaint( hwnd
, &child
, &flags
))) break;
747 need_erase
= send_erase( child
, flags
, hrgn
, NULL
, NULL
);
749 if (!flags
) break; /* nothing more to do */
750 if ((rdw_flags
& RDW_NOCHILDREN
) && !need_erase
) break;
755 /***********************************************************************
758 * Implementation of RDW_UPDATENOW behavior.
760 * FIXME: Windows uses WM_SYNCPAINT to cut down the number of intertask
761 * SendMessage() calls. This is a comment inside DefWindowProc() source
764 * This message avoids lots of inter-app message traffic
765 * by switching to the other task and continuing the
769 * LOWORD(lParam) = hrgnClip
770 * HIWORD(lParam) = hwndSkip (not used; always NULL)
773 static void update_now( HWND hwnd
, UINT rdw_flags
)
777 /* desktop window never gets WM_PAINT, only WM_ERASEBKGND */
778 if (hwnd
== GetDesktopWindow()) erase_now( hwnd
, rdw_flags
| RDW_NOCHILDREN
);
780 /* loop while we find a child to repaint */
783 UINT flags
= UPDATE_PAINT
| UPDATE_INTERNALPAINT
;
785 if (rdw_flags
& RDW_NOCHILDREN
) flags
|= UPDATE_NOCHILDREN
;
786 else if (rdw_flags
& RDW_ALLCHILDREN
) flags
|= UPDATE_ALLCHILDREN
;
788 if (!get_update_flags( hwnd
, &child
, &flags
)) break;
789 if (!flags
) break; /* nothing more to do */
791 SendMessageW( child
, WM_PAINT
, 0, 0 );
792 if (rdw_flags
& RDW_NOCHILDREN
) break;
797 /*************************************************************************
800 * Helper for ScrollWindowEx:
801 * If the return value is 0, no special caret handling is necessary.
802 * Otherwise the return value is the handle of the window that owns the
803 * caret. Its caret needs to be hidden during the scroll operation and
804 * moved to new_caret_pos if move_caret is TRUE.
806 static HWND
fix_caret(HWND hWnd
, const RECT
*scroll_rect
, INT dx
, INT dy
,
807 UINT flags
, LPBOOL move_caret
, LPPOINT new_caret_pos
)
810 RECT rect
, mapped_rcCaret
;
811 BOOL hide_caret
= FALSE
;
813 if (!GetGUIThreadInfo( GetCurrentThreadId(), &info
)) return 0;
814 if (!info
.hwndCaret
) return 0;
816 if (info
.hwndCaret
== hWnd
)
818 /* Move the caret if it's (partially) in the source rectangle */
819 if (IntersectRect(&rect
, scroll_rect
, &info
.rcCaret
))
823 new_caret_pos
->x
= info
.rcCaret
.left
+ dx
;
824 new_caret_pos
->y
= info
.rcCaret
.top
+ dy
;
830 /* Hide the caret if it's in the destination rectangle */
832 OffsetRect(&rect
, dx
, dy
);
833 hide_caret
= IntersectRect(&rect
, &rect
, &info
.rcCaret
);
838 if ((flags
& SW_SCROLLCHILDREN
) && IsChild(hWnd
, info
.hwndCaret
))
842 /* Hide the caret if it's in the source or in the destination
844 mapped_rcCaret
= info
.rcCaret
;
845 MapWindowPoints(info
.hwndCaret
, hWnd
, (LPPOINT
)&mapped_rcCaret
, 2);
847 if (IntersectRect(&rect
, scroll_rect
, &mapped_rcCaret
))
854 OffsetRect(&rect
, dx
, dy
);
855 hide_caret
= IntersectRect(&rect
, &rect
, &mapped_rcCaret
);
864 HideCaret(info
.hwndCaret
);
865 return info
.hwndCaret
;
872 /***********************************************************************
873 * BeginPaint (USER32.@)
875 HDC WINAPI
BeginPaint( HWND hwnd
, PAINTSTRUCT
*lps
)
878 UINT flags
= UPDATE_NONCLIENT
| UPDATE_ERASE
| UPDATE_PAINT
| UPDATE_INTERNALPAINT
| UPDATE_NOCHILDREN
;
884 if (!(hrgn
= send_ncpaint( hwnd
, NULL
, &flags
))) return 0;
886 lps
->fErase
= send_erase( hwnd
, flags
, hrgn
, &lps
->rcPaint
, &lps
->hdc
);
888 TRACE("hdc = %p box = (%s), fErase = %d\n",
889 lps
->hdc
, wine_dbgstr_rect(&lps
->rcPaint
), lps
->fErase
);
895 /***********************************************************************
896 * EndPaint (USER32.@)
898 BOOL WINAPI
EndPaint( HWND hwnd
, const PAINTSTRUCT
*lps
)
900 if (!lps
) return FALSE
;
901 release_dc( hwnd
, lps
->hdc
, TRUE
);
907 /***********************************************************************
910 HDC WINAPI
GetDCEx( HWND hwnd
, HRGN hrgnClip
, DWORD flags
)
912 static const DWORD clip_flags
= DCX_PARENTCLIP
| DCX_CLIPSIBLINGS
| DCX_CLIPCHILDREN
| DCX_WINDOW
;
913 static const DWORD user_flags
= clip_flags
| DCX_NORESETATTRS
; /* flags that can be set by user */
915 BOOL bUpdateVisRgn
= TRUE
;
917 LONG window_style
= GetWindowLongW( hwnd
, GWL_STYLE
);
919 if (!hwnd
) hwnd
= GetDesktopWindow();
920 else hwnd
= WIN_GetFullHandle( hwnd
);
922 TRACE("hwnd %p, hrgnClip %p, flags %08x\n", hwnd
, hrgnClip
, flags
);
924 if (!IsWindow(hwnd
)) return 0;
928 if (flags
& (DCX_WINDOW
| DCX_PARENTCLIP
)) flags
|= DCX_CACHE
;
930 if (flags
& DCX_USESTYLE
)
932 flags
&= ~(DCX_CLIPCHILDREN
| DCX_CLIPSIBLINGS
| DCX_PARENTCLIP
);
934 if (window_style
& WS_CLIPSIBLINGS
) flags
|= DCX_CLIPSIBLINGS
;
936 if (!(flags
& DCX_WINDOW
))
938 if (GetClassLongW( hwnd
, GCL_STYLE
) & CS_PARENTDC
) flags
|= DCX_PARENTCLIP
;
940 if (window_style
& WS_CLIPCHILDREN
&& !(window_style
& WS_MINIMIZE
))
941 flags
|= DCX_CLIPCHILDREN
;
945 if (flags
& DCX_WINDOW
) flags
&= ~DCX_CLIPCHILDREN
;
947 parent
= GetAncestor( hwnd
, GA_PARENT
);
948 if (!parent
|| (parent
== GetDesktopWindow()))
949 flags
= (flags
& ~DCX_PARENTCLIP
) | DCX_CLIPSIBLINGS
;
951 /* it seems parent clip is ignored when clipping siblings or children */
952 if (flags
& (DCX_CLIPSIBLINGS
| DCX_CLIPCHILDREN
)) flags
&= ~DCX_PARENTCLIP
;
954 if( flags
& DCX_PARENTCLIP
)
956 LONG parent_style
= GetWindowLongW( parent
, GWL_STYLE
);
957 if( (window_style
& WS_VISIBLE
) && (parent_style
& WS_VISIBLE
) )
959 flags
&= ~DCX_CLIPCHILDREN
;
960 if (parent_style
& WS_CLIPSIBLINGS
) flags
|= DCX_CLIPSIBLINGS
;
964 /* find a suitable DCE */
966 if ((flags
& DCX_CACHE
) || !(dce
= get_window_dce( hwnd
)))
968 struct dce
*dceEmpty
= NULL
, *dceUnused
= NULL
;
970 /* Strategy: First, we attempt to find a non-empty but unused DCE with
971 * compatible flags. Next, we look for an empty entry. If the cache is
972 * full we have to purge one of the unused entries.
975 LIST_FOR_EACH_ENTRY( dce
, &dce_list
, struct dce
, entry
)
977 if ((dce
->flags
& DCX_CACHE
) && !dce
->count
)
981 if (!dce
->hwnd
) dceEmpty
= dce
;
982 else if ((dce
->hwnd
== hwnd
) && !((dce
->flags
^ flags
) & clip_flags
))
984 TRACE("\tfound valid %p dce [%p], flags %08x\n",
985 dce
, hwnd
, dce
->flags
);
986 bUpdateVisRgn
= FALSE
;
992 if (&dce
->entry
== &dce_list
) /* nothing found */
993 dce
= dceEmpty
? dceEmpty
: dceUnused
;
995 if (dce
) dce
->count
= 1;
999 /* if there's no dce empty or unused, allocate a new one */
1002 if (!(dce
= alloc_dce())) return 0;
1003 dce
->flags
= DCX_CACHE
;
1005 list_add_head( &dce_list
, &dce
->entry
);
1011 flags
|= DCX_NORESETATTRS
;
1012 if (dce
->hwnd
== hwnd
)
1014 TRACE("\tskipping hVisRgn update\n");
1015 bUpdateVisRgn
= FALSE
; /* updated automatically, via DCHook() */
1019 /* we should free dce->clip_rgn here, but Windows apparently doesn't */
1020 dce
->flags
&= ~(DCX_EXCLUDERGN
| DCX_INTERSECTRGN
);
1025 if (flags
& (DCX_INTERSECTRGN
| DCX_EXCLUDERGN
))
1027 /* if the extra clip region has changed, get rid of the old one */
1028 if (dce
->clip_rgn
!= hrgnClip
|| ((flags
^ dce
->flags
) & (DCX_INTERSECTRGN
| DCX_EXCLUDERGN
)))
1029 delete_clip_rgn( dce
);
1030 dce
->clip_rgn
= hrgnClip
;
1031 if (!dce
->clip_rgn
) dce
->clip_rgn
= CreateRectRgn( 0, 0, 0, 0 );
1032 dce
->flags
|= flags
& (DCX_INTERSECTRGN
| DCX_EXCLUDERGN
);
1033 bUpdateVisRgn
= TRUE
;
1037 dce
->flags
= (dce
->flags
& ~user_flags
) | (flags
& user_flags
);
1039 if (SetHookFlags( dce
->hdc
, DCHF_VALIDATEVISRGN
)) bUpdateVisRgn
= TRUE
; /* DC was dirty */
1041 if (bUpdateVisRgn
) update_visible_region( dce
);
1043 TRACE("(%p,%p,0x%x): returning %p\n", hwnd
, hrgnClip
, flags
, dce
->hdc
);
1048 /***********************************************************************
1051 * Get a device context.
1054 * Success: Handle to the device context
1057 HDC WINAPI
GetDC( HWND hwnd
)
1059 if (!hwnd
) return GetDCEx( 0, 0, DCX_CACHE
| DCX_WINDOW
);
1060 return GetDCEx( hwnd
, 0, DCX_USESTYLE
);
1064 /***********************************************************************
1065 * GetWindowDC (USER32.@)
1067 HDC WINAPI
GetWindowDC( HWND hwnd
)
1069 return GetDCEx( hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
);
1073 /***********************************************************************
1074 * ReleaseDC (USER32.@)
1076 * Release a device context.
1079 * Success: Non-zero. Resources used by hdc are released.
1082 INT WINAPI
ReleaseDC( HWND hwnd
, HDC hdc
)
1084 return release_dc( hwnd
, hdc
, FALSE
);
1088 /**********************************************************************
1089 * WindowFromDC (USER32.@)
1091 HWND WINAPI
WindowFromDC( HDC hdc
)
1097 dce
= (struct dce
*)GetDCHook( hdc
, NULL
);
1098 if (dce
) hwnd
= dce
->hwnd
;
1104 /***********************************************************************
1105 * LockWindowUpdate (USER32.@)
1107 * Enables or disables painting in the chosen window.
1110 * hwnd [I] handle to a window.
1113 * If successful, returns nonzero value. Otherwise,
1117 * You can lock only one window at a time.
1119 BOOL WINAPI
LockWindowUpdate( HWND hwnd
)
1121 static HWND lockedWnd
;
1123 FIXME("(%p), partial stub!\n",hwnd
);
1130 /* Unlock lockedWnd */
1131 /* FIXME: Do something */
1135 /* Attempted to lock a second window */
1136 /* Return FALSE and do nothing */
1147 /***********************************************************************
1148 * RedrawWindow (USER32.@)
1150 BOOL WINAPI
RedrawWindow( HWND hwnd
, const RECT
*rect
, HRGN hrgn
, UINT flags
)
1152 static const RECT empty
;
1155 if (!hwnd
) hwnd
= GetDesktopWindow();
1162 GetRgnBox( hrgn
, &r
);
1163 TRACE( "%p region %p box %s ", hwnd
, hrgn
, wine_dbgstr_rect(&r
) );
1166 TRACE( "%p rect %s ", hwnd
, wine_dbgstr_rect(rect
) );
1168 TRACE( "%p whole window ", hwnd
);
1170 dump_rdw_flags(flags
);
1173 /* process pending expose events before painting */
1174 if (flags
& RDW_UPDATENOW
) USER_Driver
->pMsgWaitForMultipleObjectsEx( 0, NULL
, 0, QS_PAINT
, 0 );
1178 if (IsRectEmpty( rect
)) rect
= &empty
;
1179 ret
= redraw_window_rects( hwnd
, flags
, rect
, 1 );
1183 ret
= redraw_window_rects( hwnd
, flags
, NULL
, 0 );
1185 else /* need to build a list of the region rectangles */
1188 RGNDATA
*data
= NULL
;
1190 if (!(size
= GetRegionData( hrgn
, 0, NULL
))) return FALSE
;
1191 if (!(data
= HeapAlloc( GetProcessHeap(), 0, size
))) return FALSE
;
1192 GetRegionData( hrgn
, size
, data
);
1193 if (!data
->rdh
.nCount
) /* empty region -> use a single all-zero rectangle */
1194 ret
= redraw_window_rects( hwnd
, flags
, &empty
, 1 );
1196 ret
= redraw_window_rects( hwnd
, flags
, (const RECT
*)data
->Buffer
, data
->rdh
.nCount
);
1197 HeapFree( GetProcessHeap(), 0, data
);
1200 if (flags
& RDW_UPDATENOW
) update_now( hwnd
, flags
);
1201 else if (flags
& RDW_ERASENOW
) erase_now( hwnd
, flags
);
1207 /***********************************************************************
1208 * UpdateWindow (USER32.@)
1210 BOOL WINAPI
UpdateWindow( HWND hwnd
)
1212 return RedrawWindow( hwnd
, NULL
, 0, RDW_UPDATENOW
| RDW_ALLCHILDREN
);
1216 /***********************************************************************
1217 * InvalidateRgn (USER32.@)
1219 BOOL WINAPI
InvalidateRgn( HWND hwnd
, HRGN hrgn
, BOOL erase
)
1223 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
1227 return RedrawWindow(hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| (erase
? RDW_ERASE
: 0) );
1231 /***********************************************************************
1232 * InvalidateRect (USER32.@)
1234 * MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
1235 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
1237 BOOL WINAPI
InvalidateRect( HWND hwnd
, const RECT
*rect
, BOOL erase
)
1239 UINT flags
= RDW_INVALIDATE
| (erase
? RDW_ERASE
: 0);
1243 flags
= RDW_ALLCHILDREN
| RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
;
1247 return RedrawWindow( hwnd
, rect
, 0, flags
);
1251 /***********************************************************************
1252 * ValidateRgn (USER32.@)
1254 BOOL WINAPI
ValidateRgn( HWND hwnd
, HRGN hrgn
)
1258 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
1262 return RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
);
1266 /***********************************************************************
1267 * ValidateRect (USER32.@)
1269 * MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
1270 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
1272 BOOL WINAPI
ValidateRect( HWND hwnd
, const RECT
*rect
)
1274 UINT flags
= RDW_VALIDATE
;
1278 flags
= RDW_ALLCHILDREN
| RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
;
1282 return RedrawWindow( hwnd
, rect
, 0, flags
);
1286 /***********************************************************************
1287 * GetUpdateRgn (USER32.@)
1289 INT WINAPI
GetUpdateRgn( HWND hwnd
, HRGN hrgn
, BOOL erase
)
1292 UINT flags
= UPDATE_NOCHILDREN
;
1295 if (erase
) flags
|= UPDATE_NONCLIENT
| UPDATE_ERASE
;
1297 if ((update_rgn
= send_ncpaint( hwnd
, NULL
, &flags
)))
1301 retval
= CombineRgn( hrgn
, update_rgn
, 0, RGN_COPY
);
1302 if (send_erase( hwnd
, flags
, update_rgn
, NULL
, NULL
))
1304 flags
= UPDATE_DELAYED_ERASE
;
1305 get_update_flags( hwnd
, NULL
, &flags
);
1307 /* map region to client coordinates */
1308 offset
.x
= offset
.y
= 0;
1309 ScreenToClient( hwnd
, &offset
);
1310 OffsetRgn( hrgn
, offset
.x
, offset
.y
);
1316 /***********************************************************************
1317 * GetUpdateRect (USER32.@)
1319 BOOL WINAPI
GetUpdateRect( HWND hwnd
, LPRECT rect
, BOOL erase
)
1321 UINT flags
= UPDATE_NOCHILDREN
;
1325 if (erase
) flags
|= UPDATE_NONCLIENT
| UPDATE_ERASE
;
1327 if (!(update_rgn
= send_ncpaint( hwnd
, NULL
, &flags
))) return FALSE
;
1331 if (GetRgnBox( update_rgn
, rect
) != NULLREGION
)
1333 HDC hdc
= GetDCEx( hwnd
, 0, DCX_USESTYLE
);
1334 MapWindowPoints( 0, hwnd
, (LPPOINT
)rect
, 2 );
1335 DPtoLP( hdc
, (LPPOINT
)rect
, 2 );
1336 ReleaseDC( hwnd
, hdc
);
1339 need_erase
= send_erase( hwnd
, flags
, update_rgn
, NULL
, NULL
);
1341 /* check if we still have an update region */
1342 flags
= UPDATE_PAINT
| UPDATE_NOCHILDREN
;
1343 if (need_erase
) flags
|= UPDATE_DELAYED_ERASE
;
1344 return (get_update_flags( hwnd
, NULL
, &flags
) && (flags
& UPDATE_PAINT
));
1348 /***********************************************************************
1349 * ExcludeUpdateRgn (USER32.@)
1351 INT WINAPI
ExcludeUpdateRgn( HDC hdc
, HWND hwnd
)
1353 HRGN update_rgn
= CreateRectRgn( 0, 0, 0, 0 );
1354 INT ret
= GetUpdateRgn( hwnd
, update_rgn
, FALSE
);
1360 GetDCOrgEx( hdc
, &pt
);
1361 MapWindowPoints( 0, hwnd
, &pt
, 1 );
1362 OffsetRgn( update_rgn
, -pt
.x
, -pt
.y
);
1363 ret
= ExtSelectClipRgn( hdc
, update_rgn
, RGN_DIFF
);
1364 DeleteObject( update_rgn
);
1370 /*************************************************************************
1371 * ScrollWindowEx (USER32.@)
1373 * Note: contrary to what the doc says, pixels that are scrolled from the
1374 * outside of clipRect to the inside are NOT painted.
1377 INT WINAPI
ScrollWindowEx( HWND hwnd
, INT dx
, INT dy
,
1378 const RECT
*rect
, const RECT
*clipRect
,
1379 HRGN hrgnUpdate
, LPRECT rcUpdate
,
1382 INT retVal
= NULLREGION
;
1383 BOOL bOwnRgn
= TRUE
;
1384 BOOL bUpdate
= (rcUpdate
|| hrgnUpdate
|| flags
& (SW_INVALIDATE
| SW_ERASE
));
1387 HRGN hrgnWinupd
= 0;
1390 HWND hwndCaret
= NULL
;
1391 BOOL moveCaret
= FALSE
;
1394 TRACE( "%p, %d,%d hrgnUpdate=%p rcUpdate = %p %s %04x\n",
1395 hwnd
, dx
, dy
, hrgnUpdate
, rcUpdate
, wine_dbgstr_rect(rect
), flags
);
1396 TRACE( "clipRect = %s\n", wine_dbgstr_rect(clipRect
));
1397 if( flags
& ~( SW_SCROLLCHILDREN
| SW_INVALIDATE
| SW_ERASE
))
1398 FIXME("some flags (%04x) are unhandled\n", flags
);
1400 rdw_flags
= (flags
& SW_ERASE
) && (flags
& SW_INVALIDATE
) ?
1401 RDW_INVALIDATE
| RDW_ERASE
: RDW_INVALIDATE
;
1403 if (!WIN_IsWindowDrawable( hwnd
, TRUE
)) return ERROR
;
1404 hwnd
= WIN_GetFullHandle( hwnd
);
1406 GetClientRect(hwnd
, &rc
);
1408 if (clipRect
) IntersectRect(&cliprc
,&rc
,clipRect
);
1411 if (rect
) IntersectRect(&rc
, &rc
, rect
);
1413 if( hrgnUpdate
) bOwnRgn
= FALSE
;
1414 else if( bUpdate
) hrgnUpdate
= CreateRectRgn( 0, 0, 0, 0 );
1416 newCaretPos
.x
= newCaretPos
.y
= 0;
1418 if( !IsRectEmpty(&cliprc
) && (dx
|| dy
)) {
1419 DWORD dcxflags
= DCX_CACHE
;
1420 DWORD style
= GetWindowLongW( hwnd
, GWL_STYLE
);
1422 hwndCaret
= fix_caret(hwnd
, &rc
, dx
, dy
, flags
, &moveCaret
, &newCaretPos
);
1424 if( style
& WS_CLIPSIBLINGS
) dcxflags
|= DCX_CLIPSIBLINGS
;
1425 if( GetClassLongW( hwnd
, GCL_STYLE
) & CS_PARENTDC
)
1426 dcxflags
|= DCX_PARENTCLIP
;
1427 if( !(flags
& SW_SCROLLCHILDREN
) && (style
& WS_CLIPCHILDREN
))
1428 dcxflags
|= DCX_CLIPCHILDREN
;
1429 hDC
= GetDCEx( hwnd
, 0, dcxflags
);
1432 ScrollDC( hDC
, dx
, dy
, &rc
, &cliprc
, hrgnUpdate
, rcUpdate
);
1434 ReleaseDC( hwnd
, hDC
);
1437 RedrawWindow( hwnd
, NULL
, hrgnUpdate
, rdw_flags
);
1440 /* If the windows has an update region, this must be
1441 * scrolled as well. Keep a copy in hrgnWinupd
1442 * to be added to hrngUpdate at the end. */
1443 hrgnTemp
= CreateRectRgn( 0, 0, 0, 0 );
1444 retVal
= GetUpdateRgn( hwnd
, hrgnTemp
, FALSE
);
1445 if (retVal
!= NULLREGION
)
1447 HRGN hrgnClip
= CreateRectRgnIndirect(&cliprc
);
1449 hrgnWinupd
= CreateRectRgn( 0, 0, 0, 0);
1450 CombineRgn( hrgnWinupd
, hrgnTemp
, 0, RGN_COPY
);
1452 OffsetRgn( hrgnTemp
, dx
, dy
);
1453 CombineRgn( hrgnTemp
, hrgnTemp
, hrgnClip
, RGN_AND
);
1455 CombineRgn( hrgnWinupd
, hrgnWinupd
, hrgnTemp
, RGN_OR
);
1456 RedrawWindow( hwnd
, NULL
, hrgnTemp
, rdw_flags
);
1458 /* Catch the case where the scrolling amount exceeds the size of the
1459 * original window. This generated a second update area that is the
1460 * location where the original scrolled content would end up.
1461 * This second region is not returned by the ScrollDC and sets
1462 * ScrollWindowEx apart from just a ScrollDC.
1464 * This has been verified with testing on windows.
1466 if (abs(dx
) > abs(rc
.right
- rc
.left
) ||
1467 abs(dy
) > abs(rc
.bottom
- rc
.top
))
1469 SetRectRgn( hrgnTemp
, rc
.left
+ dx
, rc
.top
+ dy
, rc
.right
+dx
, rc
.bottom
+ dy
);
1470 CombineRgn( hrgnTemp
, hrgnTemp
, hrgnClip
, RGN_AND
);
1471 CombineRgn( hrgnUpdate
, hrgnUpdate
, hrgnTemp
, RGN_OR
);
1474 CombineRgn( hrgnWinupd
, hrgnWinupd
, hrgnTemp
, RGN_OR
);
1476 DeleteObject( hrgnClip
);
1478 DeleteObject( hrgnTemp
);
1480 /* nothing was scrolled */
1482 SetRectRgn( hrgnUpdate
, 0, 0, 0, 0 );
1483 SetRectEmpty( rcUpdate
);
1486 if( flags
& SW_SCROLLCHILDREN
)
1488 HWND
*list
= WIN_ListChildren( hwnd
);
1493 for (i
= 0; list
[i
]; i
++)
1495 GetWindowRect( list
[i
], &r
);
1496 MapWindowPoints( 0, hwnd
, (POINT
*)&r
, 2 );
1497 if (!rect
|| IntersectRect(&dummy
, &r
, rect
))
1498 SetWindowPos( list
[i
], 0, r
.left
+ dx
, r
.top
+ dy
, 0, 0,
1499 SWP_NOZORDER
| SWP_NOSIZE
| SWP_NOACTIVATE
|
1500 SWP_NOREDRAW
| SWP_DEFERERASE
);
1502 HeapFree( GetProcessHeap(), 0, list
);
1506 if( flags
& (SW_INVALIDATE
| SW_ERASE
) )
1507 RedrawWindow( hwnd
, NULL
, hrgnUpdate
, rdw_flags
|
1508 ((flags
& SW_SCROLLCHILDREN
) ? RDW_ALLCHILDREN
: 0 ) );
1511 CombineRgn( hrgnUpdate
, hrgnUpdate
, hrgnWinupd
, RGN_OR
);
1512 DeleteObject( hrgnWinupd
);
1516 if ( moveCaret
) SetCaretPos( newCaretPos
.x
, newCaretPos
.y
);
1517 ShowCaret(hwndCaret
);
1520 if( bOwnRgn
&& hrgnUpdate
) DeleteObject( hrgnUpdate
);
1526 /*************************************************************************
1527 * ScrollWindow (USER32.@)
1530 BOOL WINAPI
ScrollWindow( HWND hwnd
, INT dx
, INT dy
,
1531 const RECT
*rect
, const RECT
*clipRect
)
1533 return (ERROR
!= ScrollWindowEx( hwnd
, dx
, dy
, rect
, clipRect
, 0, NULL
,
1534 (rect
? 0 : SW_SCROLLCHILDREN
) |
1535 SW_INVALIDATE
| SW_ERASE
));
1539 /*************************************************************************
1540 * ScrollDC (USER32.@)
1542 * dx, dy, lprcScroll and lprcClip are all in logical coordinates (msdn is
1543 * wrong) hrgnUpdate is returned in device coordinates with rcUpdate in
1544 * logical coordinates.
1546 BOOL WINAPI
ScrollDC( HDC hdc
, INT dx
, INT dy
, const RECT
*lprcScroll
,
1547 const RECT
*lprcClip
, HRGN hrgnUpdate
, LPRECT lprcUpdate
)
1550 return USER_Driver
->pScrollDC( hdc
, dx
, dy
, lprcScroll
, lprcClip
, hrgnUpdate
, lprcUpdate
);
1553 /************************************************************************
1554 * PrintWindow (USER32.@)
1557 BOOL WINAPI
PrintWindow(HWND hwnd
, HDC hdcBlt
, UINT nFlags
)
1559 UINT flags
= PRF_CHILDREN
| PRF_ERASEBKGND
| PRF_OWNED
| PRF_CLIENT
;
1560 if(!(nFlags
& PW_CLIENTONLY
))
1562 flags
|= PRF_NONCLIENT
;
1564 SendMessageW(hwnd
, WM_PRINT
, (WPARAM
)hdcBlt
, flags
);