Im kind confuse about how PostQuitMessage works..

Im using like this:

case WM_CLOSE :		DestroyWindow( hWnd );	break;	//send WM_DESTROY

case WM_DESTROY :	CleanUp();
			gsp_quit = true;
			PostQuitMessage( 0 );			//send WM_QUIT


That is on my WndProc function.

My message loop is like that:

while ( !gsp_quit ){
		if( PeekMessage( &gsp_msg, NULL, NULL, NULL, PM_REMOVE ) ){

			TranslateMessage( &gsp_msg );
			DispatchMessage	( &gsp_msg );

		}//while F PeekMessage()

	}//F while !gsp_quit


	return gsp_msg.wParam;//it should return 0

The problem is that it just returns 0 (zero) if I use while( PeekMessage() ) instead of 'If', or if I call PeekMessage again at //***

So, i guess theres some overheads on PostQuitMessage before it send your exit code given on its param..what are those overheads?

And where can I search for exit codes info? I was trying to find it at MSDN but I didnt..

7 Years
Discussion Span
Last Post by Icebone1000

Do you know the difference between GetMessage and PickMessage function?

Here is a text for you.

You can use the PeekMessage function to examine a message queue during a lengthy operation. PeekMessage is similar to the GetMessage function; both check a message queue for a message that matches the filter criteria and then copy the message to an MSG structure. The main difference between the two functions is that GetMessage does not return until a message matching the filter criteria is placed in the queue, whereas PeekMessage returns immediately regardless of whether a message is in the queue.


I knew..but I think I just figure out my stupid mistake,
Im quiting the loop before proccessing the WM_QUIT( because gsp_quit became true and the message is not processed )..-_-"

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.