App Closing RRS feed

  • Question

  • Well, I need to make it so once you try and close my application, with the X, or with Alt+F4 it will catch that and bring up a message saying for my game, that if you choose to close it while in battle, your character will stay online for X amount of time.

    How do I do it?

    Thursday, October 23, 2008 11:33 PM


  • Handle the Form.FormClosing event.

    You can examine e.CloseReason to find out why the window is closing.  For example, CloseReason.UserClosing and CloseReason.WindowsShutDown.

    It is also possible to stop the form from closing by setting e.Cancel = True in this event.  For this reason, this event is often used to implement "Do you want to save?" prompts.
    • Marked as answer by Maya Key Thursday, October 23, 2008 11:48 PM
    Thursday, October 23, 2008 11:40 PM