Sign in to follow this  
andyborowicz

What is wrong with my app?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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:

while(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
{
return 0;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}


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 :)

Share this post


Link to post
Share on other sites
I had the PostQuitMessage(0); line, and my loop was also finished. But there were some differences in my WinMain... Changed it and now it works :) Thanx guys for all feedback!

Share this post


Link to post
Share on other sites

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