What is wrong with my app?

Started by
4 comments, last by andyborowicz 17 years, 10 months ago
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?
Advertisement
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.
You are most likely closing the window but not stopping your main loop.
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 :)
--Jeroen Stout - WebsiteCreator of-Divided
and you could always just do a PostQuitMessage(0); whenever you are trying to close the program, this should take care of it.
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!

This topic is closed to new replies.

Advertisement