Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OnClose not firing
Message
From
02/01/2004 13:41:22
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00863478
Message ID:
00863496
Views:
9
Hmmm ... I just noticed that our app doesn't handle this correctly either, so I had to figure this out also. What I've done is to add an Application.Exit() call to the Main Form's ClosingHandler(). And the menu item that closes the application calls that. So, it's something like this (sorry, this will be in C#, you can do the conversion):
private void MenuItemExit_Click(object sender, System.EventArgs e)
{
  System.ComponentModel.CancelEventArgs ee = new CancelEventArgs();
  this.ClosingHandler(sender, ee);
}

private void ClosingHandler(object sender, System.ComponentModel.CancelEventArgs e)
{
  if (!this.MyNormalClosingStuff())
    e.Cancel = true;
  else
    Application.Exit();
}
I simply moved the Application.Exit() out of the MenuItem's click event and put it in the normal Closing EventHandler. I assume you already have code in your main form's ClosingHandler that works when you close the main form with the "X". The trick here was simply getting the Application.Exit() into the proper place.


~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform