Sign in to follow this  

PostQuitMessage(0) Causes Crash ?

This topic is 3457 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
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
i got it ,it was my carelessness. i changed the all message loop and it works fine now.

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

This topic is 3457 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this