943,712 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 2409
  • C++ RSS
Jun 17th, 2009
0

PeekMessage and PostQuitMessage

Expand Post »
Im kind confuse about how PostQuitMessage works..

Im using like this:
C++ Syntax (Toggle Plain Text)
  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:
C++ Syntax (Toggle Plain Text)
  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..
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Icebone1000 is offline Offline
50 posts
since Jan 2008
Jun 18th, 2009
0

Re: PeekMessage and PostQuitMessage

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.
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Jun 19th, 2009
0

Re: PeekMessage and PostQuitMessage

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 )..-_-"
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Icebone1000 is offline Offline
50 posts
since Jan 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Using .h's in muti-source projects
Next Thread in C++ Forum Timeline: Using multiple sounds at the same time.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC