BeginPaint
BeginPaint is a Windows API function used to prepare a window’s client area for painting in response to the WM_PAINT message. It validates the window’s update region and returns a device context (HDC) that should be used for drawing. A PAINTSTRUCT structure is filled by the function; the HDC in this structure is the drawing surface, and rcPaint describes the rectangle that needs repainting.
Typical usage occurs inside a window procedure when handling WM_PAINT. The pattern is to declare a PAINTSTRUCT,
Key points: BeginPaint should only be called in response to WM_PAINT. It both provides the device context
If painting is needed outside of WM_PAINT, or if a DC is required without validating the update
See also: EndPaint, WM_PAINT, PAINTSTRUCT, GetDC, ReleaseDC.