HDC BeginPaint(hwnd, lpps) | |||||
HWND hwnd; | /* handle of window to paint | */ | |||
PAINTSTRUCT FAR* lpps; | /* address of structure with paint information | */ |
The BeginPaint function prepares the specified window for painting and fills a PAINTSTRUCT structure with information about the painting.
hwnd
Identifies the window to be repainted.
lpps
Points to the PAINTSTRUCT structure that will receive the painting information. The PAINTSTRUCT structure has the following form:
typedef struct tagPAINTSTRUCT { /* ps */
HDC hdc;
BOOL fErase;
RECT rcPaint;
BOOL fRestore;
BOOL fIncUpdate;
BYTE rgbReserved[16];
} PAINTSTRUCT;
For a full description of this structure, see the Microsoft Windows Programmer's Reference, Volume 3.
The return value is the handle of the device context for the given window if the function is successful.
The BeginPaint function automatically sets the clipping region of the device context to exclude any area outside the update region. The update region is set by the InvalidateRect or InvalidateRgn function and by the system after sizing, moving, creating, scrolling, or any other operation that affects the client area. If the update region is marked for erasing, BeginPaint sends a WM_ERASEBKGND message to the window.
An application should not call BeginPaint except in response to a WM_PAINT message. Each call to the BeginPaint function must have a corresponding call to the EndPaint function.
If the caret is in the area to be painted, BeginPaint automatically hides the caret to prevent it from being erased.
If the window's class has a background brush, BeginPaint will use that brush to erase the background of the update region before returning.
The following example calls an application-defined function to paint a bar graph in a window's client area during the WM_PAINT message:
PAINTSTRUCT
ps; case WM_PAINT: BeginPaint(hwnd, &ps); . . . EndPaint(hwnd, &ps); break;
EndPaint, InvalidateRect, InvalidateRgn, ValidateRect, ValidateRgn