Every window message (WM_CREATE, WM_DESTROY, WM_PAINT, WM_USER, etc, etc) is sent by something. Most message are sent by Windows in response to some user interaction or some API call. Others are sent by 3rd-party code (for example, when you call the Win32 API SendMessage
, it's the caller of SendMessage
that is directly sending the message). In any case, the sender of the message probably expects something in response. The expected response depends on the sender of the message and the message type.
In most cases, you'll probably want to follow the rules defined by Microsoft for the window message. For example, in the documentation for WM_CREATE, it says:
If an application processes this message, it should return zero to continue creation of the window. If the application returns –1, the window is destroyed and the CreateWindowEx or CreateWindow function returns a NULL handle.
When handling WM_CREATE messages, you should return the appropriate value as defined above. When handling other messages, you should return whatever the documentation says about that message. When handing a 3rd-party message such as WM_USER, the 3rd-party should clearly indicate what it expects.