1.6.4 Painting Sequence

Windows carries out many operations to manage the system display that affect the content of the client area. If Windows moves, sizes, or alters the appearance of the display, 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 to 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 is free to paint in 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.