Why?

Started by
13 comments, last by Kojo 19 years, 11 months ago
I have a win32 program that was running fine, window opened and program ran, window closed and program stopped. However, the program is no longer exiting... The window closes and it disapears from windows task manager's "Applications" list, but it remains on the processes list.... why? Has anyone had any experiences anything like this before? EDIT : forgot... this causes the computer to run very slowly after the program is closed and is just generally a pain. [edited by - Kojo on May 19, 2004 7:56:47 PM]
Advertisement
Looks like you didn''t close your program properly.

Do you have an infinite loop running?

Post code would be helpful.
I have one infinite loop, shown below
	while(TRUE)		{	    DWORD start_time = GetTickCount();		//look for a message		while(PeekMessage(&msg,NULL,0,0,PM_REMOVE))		{			//there is a message			//check that we arent quitting			if(msg.message==WM_QUIT) break;						//translate message			TranslateMessage(&msg);			//dispatch message			DispatchMessage(&msg);		}		//run main game loop		GameLoop();		while((GetTickCount() - start_time) < GAMESPEED)		{		}	} 
quote:Original post by Kojo
I have one infinite loop, shown below
	while(TRUE)		{	    DWORD start_time = GetTickCount();		//look for a message		while(PeekMessage(&msg,NULL,0,0,PM_REMOVE))		{			//there is a message			//check that we arent quitting			if(msg.message==WM_QUIT) break;						//translate message			TranslateMessage(&msg);			//dispatch message			DispatchMessage(&msg);		}		//run main game loop		GameLoop();		while((GetTickCount() - start_time) < GAMESPEED)		{		}	}  


When that break is hit the while containing PeekMessage() is left but NOT the one with the condition TRUE.

Thanks Salsa!Colin Jeanne | Invader''s Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud
Try a variable to stop the loop when needed
a = true
while a
{
DWORD start_time = GetTickCount();
//look for a message
while(PeekMessage(&msg,NULL,0,0,PM_REMOVE) || a)
{
//there is a message

//check that we arent quitting
if(msg.message==WM_QUIT) a = false;

//translate message
TranslateMessage(&msg);

//dispatch message
DispatchMessage(&msg);
}

//run main game loop
GameLoop();
while((GetTickCount() - start_time) < GAMESPEED)
{
}
}

(i only use C++ for console apps, And i'm not that good at it, but from what i know this should work).
edit: Forgot message

[edited by - Nice coder on May 20, 2004 4:07:22 AM]
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
A break statement would be cleaner than adding the extra variable, a.

Thanks Salsa!Colin Jeanne | Invader''s Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud
If there''s no code to execute after the outer loop then you coud replace the break with an exit(0) instead.
Just change the "while(PeekMessage...) " to an "if(PeekMessage...)" and leave the "break;" where it is. Then you''re good to go.
Thank you all very much for your responses. I added an extra break and the code works fine now.

It now looks like this...
	while(TRUE)		{	    DWORD start_time = GetTickCount();		//look for a message		while(PeekMessage(&msg,NULL,0,0,PM_REMOVE))		{			//there is a message			//check that we arent quitting			if(msg.message==WM_QUIT) break;						//translate message			TranslateMessage(&msg);			//dispatch message			DispatchMessage(&msg);		}		if(msg.message==WM_QUIT)  break;  // break from the infinite loop		//run main game loop		GameLoop();		while((GetTickCount() - start_time) < GAMESPEED)		{		}	}   


I have another question and don't want to take up space with another new post... How do I get rid of text displayed by TextOut? If I try to fill a rect with black over some white text, nothing happens to the text... anyone?

EDIT: I've yet to make a post which I did not edit imeadiatly after I posted it...

[edited by - Kojo on May 20, 2004 9:16:23 PM]
In what part of your code are you drawing this rectangle? Can you post the function that draws the rectangle over the text?

Thanks Salsa!Colin Jeanne | Invader''s Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud

This topic is closed to new replies.

Advertisement