BeginPaint function (winuser.h)
The BeginPaint function prepares the specified window for painting and fills a PAINTSTRUCT structure with information about the painting.
Syntax
HDC BeginPaint(
[in] HWND hWnd,
[out] LPPAINTSTRUCT lpPaint
);
Parameters
[in] hWnd
Handle to the window to be repainted.
[out] lpPaint
Pointer to the PAINTSTRUCT structure that will receive painting information.
Return value
If the function succeeds, the return value is the handle to a display device context for the specified window.
If the function fails, the return value is NULL, indicating that no display device context is available.
Remarks
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 BeginPaint 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 uses that brush to erase the background of the update region before returning.
DPI Virtualization
This API does not participate in DPI virtualization. The output returned is always in terms of physical pixels.Examples
For an example, see Drawing in the Client Area.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | winuser.h (include Windows.h) |
Library | User32.lib |
DLL | User32.dll |
API set | ext-ms-win-ntuser-draw-l1-1-0 (introduced in Windows 8) |