Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

WM_PAINT

Windows Mobile 6.5
A version of this page is also available for
4/8/2010

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


WM_PAINT hdc = (HDC) wParam;
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.

An application should return zero if it processes this message.

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.

Headerwinuser.h
Windows Embedded CEWindows CE 1.0 and later
Windows MobileWindows Mobile Version 5.0 and later

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.