Jump to content
  • Advertisement
Sign in to follow this  
jamesss

PostQuitMessage(0) Causes Crash ?

This topic is 3706 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi,When i call PostQuitMessage(0) More Then One Time İt will Crash the Program and Lock the Computer. thanks for answer, and here is my Loop: int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd) { SetupGame(); MSG Msg; ZeroMemory( &Msg,sizeof(Msg) ); while( true ) { if(PeekMessage(&Msg,0,0,0,PM_REMOVE)) { if(Msg.message==WM_QUIT) break; TranslateMessage(&Msg); DispatchMessage (&Msg); } else { RenderGame(); } } return Msg.wParam; CleanGame(); return EXIT_FAILURE; } /*-------------------------------------------*/

Share this post


Link to post
Share on other sites
Advertisement
You shouldn't ever be calling PostQuitMessage more than once. When you call that function it's game over: you get your WM_QUIT message and you're supposed to exit your message loop.

On what line of code does your app actually crash? Also, why do you have code after the return statement in your main function? Your CleanGame function will never get run.

Also, if when you're posting code please use the "code" or "source" tags. See the FAQ for more info.

Share this post


Link to post
Share on other sites
Yeah, your code after your first return message wont work as pointed out from above.
So, if there is any cleaning to do, you will get memory leaks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!