![](smile.gif)
Programs stay running!
Hey Guys!
My problem is that every time I run my windows program and then close it, it seems to remain running. It doesn''t appear on the task bar or the alt-tab list or anywhere, but when I press control-alt-delete it''s name is there. Until I forcibly destroy it by using ''end task'' I can''t compile it again because VC++ says it can''t open it for editing. Has anypne else come across this problem?
Sorry to keep writing to this board with problems like this but I''m only a newbie so please don''t hurt me
Any help would be appreciated greatly.
Lor.
![](smile.gif)
May 04, 2001 03:38 PM
I have had this exact same problem when I started Win32. I haven''t pinpointed it, but I''m almost certain it lies within
WinProc (or whatever your version is named). If each of your
case : statements has a return 0; in it,
take it out and put onereturn 0; beneath the switch.
Then have adefault : return DefWindowProc(...); . That
seemed to fix it for me once, but I''m not 100% positive it''ll
work. Post some WinProc or WinMain code up if you will. It will
allow us all to check it out a little deeper
WinProc (or whatever your version is named). If each of your
take it out and put one
Then have a
seemed to fix it for me once, but I''m not 100% positive it''ll
work. Post some WinProc or WinMain code up if you will. It will
allow us all to check it out a little deeper
It sound like you are:
Closing/Destroying the window.
NOT exiting the app..
I''ve had problems like that with some utility programs I''ve written(badly I might add)that would run until finished and then display a dialog when done..
It is very easy to write programs that run in the background, with no window or taskbar element..I''d suggest checking your code where you destroy your window, and making SURE that the app is exiting, not stuck in some while loop or something like that..
Just for debugging fun you could put a test in your main loop that would check to see if the window was destroyed or not..if it starts coming up, YOUR APP IS STILL RUNNING..
Double-check your code, this is probably something that can be fixed in just a few lines..there''s no specific way to tell with the info you''ve provided, but I can almost guarantee it''s either a typo type bug in your code OR a simple misunderstanding of how to use one or more win32 api functions..
If you post the code I bet someone here could narrow it down quickly, but definitely double-check your code, this should not happen unless you''ve written it to behave this way..
"Like all good things, it starts with a monkey.."
Closing/Destroying the window.
NOT exiting the app..
I''ve had problems like that with some utility programs I''ve written(badly I might add)that would run until finished and then display a dialog when done..
It is very easy to write programs that run in the background, with no window or taskbar element..I''d suggest checking your code where you destroy your window, and making SURE that the app is exiting, not stuck in some while loop or something like that..
Just for debugging fun you could put a test in your main loop that would check to see if the window was destroyed or not..if it starts coming up, YOUR APP IS STILL RUNNING..
Double-check your code, this is probably something that can be fixed in just a few lines..there''s no specific way to tell with the info you''ve provided, but I can almost guarantee it''s either a typo type bug in your code OR a simple misunderstanding of how to use one or more win32 api functions..
If you post the code I bet someone here could narrow it down quickly, but definitely double-check your code, this should not happen unless you''ve written it to behave this way..
"Like all good things, it starts with a monkey.."
"Like all good things, it starts with a monkey.."
Your program is probably not exiting the message loop! What may have happened is that you forgot to put the command
PostQuitMessage(0);
in the WM_DESTROY message handler function. That''s the command that sends the WM_QUIT message to your program.
The other possable problem is that your message loop is not looking for the WM_QUIT message and never exits.
Your message loop should look at the return value of GetMessage. Here''s a very simple message loop for reference.
GetMessage returns true if the message is WM_QUIT or false for all other messages.
bool done = false;
while(!done){
if(!GetMessage(&msg,NULL,0,0)) done = true;
else{
TranslateMessage(&msg);
DispatchMessage(&msg);
} // else
} // while
PostQuitMessage(0);
in the WM_DESTROY message handler function. That''s the command that sends the WM_QUIT message to your program.
The other possable problem is that your message loop is not looking for the WM_QUIT message and never exits.
Your message loop should look at the return value of GetMessage. Here''s a very simple message loop for reference.
GetMessage returns true if the message is WM_QUIT or false for all other messages.
bool done = false;
while(!done){
if(!GetMessage(&msg,NULL,0,0)) done = true;
else{
TranslateMessage(&msg);
DispatchMessage(&msg);
} // else
} // while
------------------------------Piggies, I need more piggies![pig][pig][pig][pig][pig][pig]------------------------------Do not invoke the wrath of the Irken elite. [flaming]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement