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 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 on other sites
You are most likely closing the window but not stopping your main loop.

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 on other sites
and you could always just do a PostQuitMessage(0); whenever you are trying to close the program, this should take care of it.

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!

Create an account

Register a new account

• Forum Statistics

• Total Topics
627776
• Total Posts
2979021

• 11
• 10
• 10
• 23
• 9