PeekMessage and PostQuitMessage

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jan 2008
Posts: 45
Reputation: Icebone1000 is an unknown quantity at this point 
Solved Threads: 0
Icebone1000's Avatar
Icebone1000 Icebone1000 is offline Offline
Light Poster

PeekMessage and PostQuitMessage

 
0
  #1
Jun 17th, 2009
Im kind confuse about how PostQuitMessage works..

Im using like this:
  1. case WM_CLOSE : DestroyWindow( hWnd ); break; //send WM_DESTROY
  2.  
  3. case WM_DESTROY : CleanUp();
  4. gsp_quit = true;
  5. PostQuitMessage( 0 ); //send WM_QUIT
  6.  
  7. break;
That is on my WndProc function.


My message loop is like that:
  1.  
  2. while ( !gsp_quit ){
  3.  
  4. if( PeekMessage( &gsp_msg, NULL, NULL, NULL, PM_REMOVE ) ){
  5.  
  6. TranslateMessage( &gsp_msg );
  7. DispatchMessage ( &gsp_msg );
  8.  
  9. }//while F PeekMessage()
  10.  
  11. }//F while !gsp_quit
  12.  
  13. //***
  14.  
  15. 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..
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,615
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 469
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: PeekMessage and PostQuitMessage

 
0
  #2
Jun 18th, 2009
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.
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 45
Reputation: Icebone1000 is an unknown quantity at this point 
Solved Threads: 0
Icebone1000's Avatar
Icebone1000 Icebone1000 is offline Offline
Light Poster

Re: PeekMessage and PostQuitMessage

 
0
  #3
Jun 19th, 2009
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 )..-_-"
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC