2 * Window painting functions
4 * Copyright 1993 Alexandre Julliard
7 static char Copyright
[] = "Copyright Alexandre Julliard, 1993";
15 /* Last CTLCOLOR id */
16 #define CTLCOLOR_MAX CTLCOLOR_STATIC
19 /***********************************************************************
20 * BeginPaint (USER.39)
22 HDC
BeginPaint( HWND hwnd
, LPPAINTSTRUCT lps
)
25 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
26 if (!wndPtr
) return 0;
28 hrgnUpdate
= wndPtr
->hrgnUpdate
; /* Save update region */
30 if (!(lps
->hdc
= GetDCEx( hwnd
, wndPtr
->hrgnUpdate
,
31 DCX_INTERSECTRGN
| DCX_USESTYLE
))) return 0;
32 GetRgnBox( InquireVisRgn(lps
->hdc
), &lps
->rcPaint
);
34 if (wndPtr
->hrgnUpdate
)
36 wndPtr
->hrgnUpdate
= 0;
37 MSG_DecPaintCount( wndPtr
->hmemTaskQ
);
39 wndPtr
->flags
&= ~WIN_NEEDS_BEGINPAINT
;
41 SendMessage( hwnd
, WM_NCPAINT
, hrgnUpdate
, 0 );
42 if (hrgnUpdate
) DeleteObject( hrgnUpdate
);
44 if (!(wndPtr
->flags
& WIN_ERASE_UPDATERGN
)) lps
->fErase
= TRUE
;
45 else lps
->fErase
= !SendMessage( hwnd
, WM_ERASEBKGND
, lps
->hdc
, 0 );
51 /***********************************************************************
54 void EndPaint( HWND hwnd
, LPPAINTSTRUCT lps
)
56 ReleaseDC( hwnd
, lps
->hdc
);
60 /***********************************************************************
61 * FillWindow (USER.324)
63 void FillWindow( HWND hwndParent
, HWND hwnd
, HDC hdc
, HBRUSH hbrush
)
66 GetClientRect( hwnd
, &rect
);
67 PaintRect( hwndParent
, hwnd
, hdc
, hbrush
, &rect
);
71 /***********************************************************************
72 * PaintRect (USER.325)
74 void PaintRect(HWND hwndParent
, HWND hwnd
, HDC hdc
, HBRUSH hbrush
, LPRECT rect
)
76 /* Send WM_CTLCOLOR message if needed */
78 if (hbrush
<= CTLCOLOR_MAX
)
80 if (!hwndParent
) return;
81 hbrush
= (HBRUSH
)SendMessage( hwndParent
, WM_CTLCOLOR
,
82 hdc
, hwnd
| (hbrush
<< 16) );
84 if (hbrush
) FillRect( hdc
, rect
, hbrush
);