To manage the system display, Windows carries out many operations that affect the contents of the client area. If Windows moves, sizes, or alters the appearance of the screen, the change may affect a given window. If so, Windows marks the area changed by the operation as ready for updating and, at the next opportunity, sends a WM_PAINT message to the window so that it can update the window in the update region. If a window paints in its client area, it must call the BeginPaint function to retrieve a handle of a display context, must update the changed area as defined by the update region, and finally, must call the EndPaint function to complete the operation.
A window can paint within its client area at any time—that is, at times other than in response to a WM_PAINT message. The only requirement is that it retrieve a display context for the client area before carrying out any operations.