2 * Window painting functions
4 * Copyright 1993 Alexandre Julliard
7 static char Copyright[] = "Copyright Alexandre Julliard, 1993";
14 /* Last CTLCOLOR id */
15 #define CTLCOLOR_MAX CTLCOLOR_STATIC
18 /***********************************************************************
19 * BeginPaint (USER.39)
21 HDC BeginPaint( HWND hwnd, LPPAINTSTRUCT lps )
23 WND * wndPtr = WIN_FindWndPtr( hwnd );
24 if (!wndPtr) return 0;
26 lps->hdc = GetDC( hwnd );
27 if (!lps->hdc) return 0;
29 SelectVisRgn( lps->hdc, wndPtr->hrgnUpdate );
30 if (wndPtr->hrgnUpdate)
32 GetRgnBox( wndPtr->hrgnUpdate, &lps->rcPaint );
33 DeleteObject( wndPtr->hrgnUpdate );
34 wndPtr->hrgnUpdate = 0;
38 lps->rcPaint.left = 0;
40 lps->rcPaint.right = wndPtr->rectClient.right-wndPtr->rectClient.left;
41 lps->rcPaint.bottom = wndPtr->rectClient.bottom-wndPtr->rectClient.top;
44 if (!(wndPtr->flags & WIN_ERASE_UPDATERGN)) lps->fErase = TRUE;
45 else lps->fErase = !SendMessage( hwnd, WM_ERASEBKGND, lps->hdc, 0 );
52 /***********************************************************************
55 void EndPaint( HWND hwnd, LPPAINTSTRUCT lps )
57 ReleaseDC( hwnd, lps->hdc );
61 /***********************************************************************
62 * FillWindow (USER.324)
64 void FillWindow( HWND hwndParent, HWND hwnd, HDC hdc, HBRUSH hbrush )
67 WND * wndPtr = WIN_FindWndPtr( hwnd );
71 rect.right = wndPtr->rectClient.right - wndPtr->rectClient.left;
72 rect.bottom = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
73 PaintRect( hwndParent, hwnd, hdc, hbrush, &rect );
78 /***********************************************************************
79 * PaintRect (USER.325)
81 void PaintRect(HWND hwndParent, HWND hwnd, HDC hdc, HBRUSH hbrush, LPRECT rect)
83 /* Send WM_CTLCOLOR message if needed */
85 if (hbrush <= CTLCOLOR_MAX)
87 if (!hwndParent) return;
88 hbrush = (HBRUSH)SendMessage( hwndParent, WM_CTLCOLOR,
89 hdc, hwnd | (hbrush << 16) );
91 if (hbrush) FillRect( hdc, rect, hbrush );