Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

xstreme2000

My Program hangs!!!

This topic is 6931 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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!

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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;
}
}

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!