Jump to content
  • Advertisement
Sign in to follow this  
benryves

[Win32 Console] Cleaning up when the X button is clicked?

This topic is 4852 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'm developing a console app that uses SDL for low-level sound. Naturally, once you've finished running the app you want to clean up buffers, shut down SDL cleanly and whatnot. In my case, clicking the "X" button on the app causes the app to crash as it ends up forcing a messy shutdown. Is there a way to prevent the X button from closing the app and "catching" a click on it so that I can safely shut down the app manually?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Sparhawk42
Clicking on the X should send WM_QUIT to your app, so you just need to handle this event in your message proc.


Actually, he's using a CONSOLE window, and not a window, which makes it very different.

To answer Benryves question: As far as I know, it's impossible to handle the [x] button on the dialog. I remember the same question being asked a while back, but I think the answer was: You don't.

I have no idea if you can hook the message proc for it, you should probably check up in the MSDN.

Toolmaker

Share this post


Link to post
Share on other sites
Pure speculation ahead:

Clicking the 'X' presumably tells Windows to attempt to kill the process, which implies sending a SIGTERM signal to your app, which you can catch using the signal() command.

Failing that, you can try putting code in an onexit() handler and seeing if that gets called.

Share this post


Link to post
Share on other sites
Keep in mind that you probably want your HandlerRoutine to return FALSE, even if you handle the event since you want the program to actually close, instead of blocking the close.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!