What is wrong with my app?
I made a very simple app in WinAPI. When I run it, a process starts. When I close it (click the X) it ends but the process is still running and seen in my manager! I was looking through the Net for a possible explanation but no one seems to know why this is happening. Any ideas?
Well I use SDL to make games and I've had a similar problem. It lies in the logic you use to decide whether or not the game is over. Typically the problem is that you exit the API, but the code behind it is still being executed. Posting your code could probably help.
There's a large difference between the window of the process and the actual process. You need to check the messages your window gets to find the signal that your window was closed and respond to that by quitting your actual process (for instance, by returning 0 in WinMain).
A number of my programs use such an inner-loop in the main cycle:
Of course, this implies that this cycle is either in WinMain or a function that, when it returns 0, closes the program.
If you don't know about reading Windows messages, you're going to have to look into that :)
A number of my programs use such an inner-loop in the main cycle:
while(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)){ if(msg.message == WM_QUIT) { return 0; } TranslateMessage(&msg); DispatchMessage(&msg);}
If you don't know about reading Windows messages, you're going to have to look into that :)
and you could always just do a PostQuitMessage(0); whenever you are trying to close the program, this should take care of it.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement