Advertisement

is this a bug of MSDN?

Started by April 06, 2001 02:14 AM
3 comments, last by ed9er 23 years, 10 months ago
version : October 2000 location : Platform SDK/User Interface Services/Windows User Interface/Windowing/Messages and Messages Queues/About/Handling/Message Loop quote :
  
MSG msg;

while( GetMessage( &msg, NULL, 0, 0 ) != 0 && GetMessage(&msg, (HWND) NULL, 0, 0) != -1)

{
    TranslateMessage( &msg );
    DispatchMessage( &msg );
}

  
should it be replaced by this: ?
  
MSG msg;
int rtn;

while(1)
{
    rtn = GetMessage(&msg, NULL, 0, 0);
    if (rtn == 0 || rtn == -1)
        break;
    TranslateMessage( &msg );
    DispatchMessage( &msg );
}

  
cause i wonder(sure) if the code quoted from MSDN will get one extra msg from MsgQueue am i right? M$ sux? ------------------------------ Dedicate to nobody, I''m nobody
------------------------------------------------------CCP is fascistic, they even banned www.sourceforge.net
No you are wrong. There is no problem with that code. You can replace it to yours, it won`t make a difference.


Both piece of code will exit if the return of get message is 0(WM_QUIT) or -1(I don''t what it is)
Advertisement
There''s a big difference between the two pieces of code... The first one will get *two* messages and throw away the first one.

Looks like a bug to me.

-Mike
-Mike
Looks like they''ve fixed it in newer MSDN''s actually.

http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/winui/messques_47n4.htm

-Mike
-Mike
And better yet, when the first GetMessage receives -1 (an error occured) and the second receives 0 (WM_QUIT) the while statement will continue to be executed.


- Houdini
- Houdini

This topic is closed to new replies.

Advertisement