WM_PAINT (Windows Embedded CE 6.0)

1/6/2010

Sent by an application when Windows or another application makes a request to paint a portion of an application's window.

Syntax

WM_PAINT hdc = (HDC) wParam;

Parameters

  • hdc
    Handle to the device context (HDC) in which to draw.

    If this parameter is NULL, use the default device context.

    This parameter is used by some common controls to enable drawing in a device context other than the default device context.

    Other windows can safely ignore this parameter.

Return Value

An application should return zero if it processes this message.

Remarks

An application sends the WM_PAINT message when the operating system or another application makes a request to paint a portion of the application's window. This message is sent when UpdateWindow is called, or it is sent by DispatchMessage when the application obtains a WM_PAINT message by calling GetMessage or PeekMessage. The sequence of events follows this order:

  • DispatchMessage determines where to send this message.
  • GetMessage or PeekMessage determines which message to dispatch, and returns this message when there are no other messages in the application's message queue.
  • DispatchMessage sends this message to the appropriate window procedure.

The system sends an internal WM_PAINT message only once. After the internal message is returned from GetMessage or PeekMessage, or is sent to a window by UpdateWindow, the system does not post or send any more WM_PAINT messages until the window is invalidated.

An application must call BeginPaint and EndPaint in response to WM_PAINT messages, or pass the message to the DefWindowProc function to validate the window. DefWindowProc validates the update region; it can send the WM_ERASEBKGND message if the window background needs to be erased.

In addition, an application must check for necessary internal painting by looking at its internal data structures for each WM_PAINT message, because a WM_PAINT message may have been caused by a non-NULL update.

For some common controls, the default WM_PAINT message processing checks the wParam parameter. If wParam is non-NULL, the control assumes that the value is a handle to a device context (HDC) and paints using that device context.

Requirements

Header winuser.h
Windows Embedded CE Windows CE 1.0 and later

See Also

Reference

GDI Messages
BeginPaint
DefWindowProc
DispatchMessage
EndPaint
GetMessage
GetUpdateRect
PeekMessage
UpdateWindow
WM_ERASEBKGND