Advertisement

My Program hangs!!!

Started by April 26, 2000 06:51 PM
6 comments, last by xstreme2000 24 years, 7 months ago
I have a Problem:- My program create a window in then the WindowProc goes like this switch(uMsg) { case WM_KEYDOWN: case WM_DESTROY: PostQuitMessage(0); break; } If I press a key the program exits nicely...if I hit Alt+F4 or hit the Close ([X]) button the program hangs... WHY??? thanx in advance
tom.oram@vodafone.net
I believe that you need to call the DefaultWindow Procedure to handle all other widows calls that you don''t specify in your window procedure. This might fix the problem. Cheers!
Advertisement
I think you are calling PostQuitMessage(0) twice, which would be bad.

-Michael
I do call the DefWindowProc but I don''t even think it gets to the WM_DESTROY...it hangs before...I think
If you think it might be hanging earlier, you can always throw in a WM_CLOSE case and then breakpoint it to see if you make it there. Better yet, do some logging (assuming your project is going to be large enough to bother).
Why don''t you do something like this, assuming that you want your app to close when the user hits a key: (just to be safe!)
switch(uMsg)
{
case WM_KEYDOWN:
{
PostQuitMessage(0);
break;
}
case WM_DESTROY:
{
PostQuitMessage(0);
break;
}
}
Thomas - www.moelhave.dk
Advertisement
anothing thing.. when you handle a message, you dont break, you return (except for special cases).. like this

case WM_DESTROY:
PostQuitMessage(0);
return 0;
adamm@san.rr.com
switch(uMsg)
{
case WM_KEYDOWN:
case WM_DESTROY:
PostQuitMessage(0);
break;
}

-and-

switch(uMsg)
{
case WM_KEYDOWN:
{
PostQuitMessage(0);
break;
}
case WM_DESTROY:
{
PostQuitMessage(0);
break;
}
}

are exactly the same. IMO, I think the first one is easier to read.

-Icarus
-Andreas

This topic is closed to new replies.

Advertisement