Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OnClose not firing
Message
De
02/01/2004 13:41:22
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00863478
Message ID:
00863496
Vues:
8
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform