PostQuitMessage(0) Causes Crash ?

Started by
3 comments, last by jamesss 15 years, 8 months ago
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; } /*-------------------------------------------*/
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.
i got it ,it was my carelessness. i changed the all message loop and it works fine now.
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.
thats right ,thanks all..

This topic is closed to new replies.

Advertisement