Announcement
Collapse
No announcement yet.
GetMessage
Collapse
X
-
Probably because about the only ways to get a failure are ...
1. Invalid hWnd
2. Bad PTR to MSG structure
.. neither of which are likely to occur, assuming the programmer is still breathing when he writes the code.
MCMMichael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
-
Funny that you bring it up because earlier tonight I was revisiting the same things.....all (most if not all examples) tend to use
Code:While GetMessage(WindowsMsg, %NULL, 0, 0) WEND
Code:While GetMessage(WindowsMsg, %NULL, 0, 0) <> 0 WEND
To me that looked like a flaw (sure no message? but why stop looping to look for a message????
Now the docs at MSDN sayIf the function retrieves a message other than WM_QUIT, the return value is nonzero.
If the function retrieves the WM_QUIT message, the return value is zero.
If there is an error, the return value is -1. For example, the function fails if hWnd is an invalid window handle or lpMsg is an invalid pointer. To get extended error information, call GetLastError.
If the function retrieves a message other than WM_QUIT, the return value is nonzero.
If there is an error, the return value is -1. For example, the function fails if hWnd is an invalid window handle or lpMsg is an invalid pointer. To get extended error information, call GetLastError.
confusing part is whenIf the function retrieves the WM_QUIT message, the return value is zero.
I am as guilty as others for not checking (since when did I find an error in the message? Or was it a quit???) But lately when I get time I am trying to correct my errors of the past (either from not knowing, or misreading docs, or taking samples at face value) and wonder why examples should not involve a FULLLLLLllll check of not only what the return value is, but does the return value also have a "Sure it's TRUE....but in your case you did not bother to check WHYYYYyyy its TRUE???? )Engineer's Motto: If it aint broke take it apart and fix it
"If at 1st you don't succeed... call it version 1.0"
"Half of Programming is coding"....."The other 90% is DEBUGGING"
"Document my code????" .... "WHYYY??? do you think they call it CODE? "
Comment
-
Cliff, no one software vendor has a monopoly on poor documentation.
For the most part we can all pretty much figure out what it means, since documenters generally don't even try to use words with more than eight letters or two syllables, since they don't know any.Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
Comment