In MSDN's Win32-Api documentation (at http://msdn.microsoft.com/en-us/library/ms633573%2开发者_如何学Python8VS.85%29.aspx) on the WindowProc
, it states: The return value is the result of the message processing and depends on the message sent.
Since I have to implement this (callback) procedure, I'd like to know what it depends on, and what I have to return. Can someone shed some light on this?
It is dependent on the exact message you are processing. You need to refer to the documentation for that message to see the expected values and meanings of the return value.
For instance, for WM_CREATE, you should return zero to continue window creation, and -1 to fail and destroy the window. For WM_GETICON, you should return a handle to the icon for your window.
For messages that you do not explictly handle, you should call DefWindowProc, passing to it all the parameters to your window proc, and return its return value to the caller.
Michael's answer answers the question perfectly, but just for reference, the usual return value will always be 0
.
For most messages it means that your application has processed the message. But always consult the MSDN page for the actual message to know for sure.
精彩评论