What is the proper way to terminate your MDI app and allow user abort of close

  • Thread starter Thread starter JerryK
  • Start date Start date
J

JerryK

Hi,

I am wondering what is the proper way to terminate an MDI app that has
"dirty" forms.

In my case, the child form is editing some data. If the user presses the
"X" button on the main form, the code I have is

parent_Closing (...) handles MyBase.Closing
Application.Exit()
End Sub

When the Application.Exit()ethod runs it causes the the closing event to run
in the child form. The chid's Closing event brings up a dialog that display
a message about lossing your changes and gives the user the options to Save
changes and close, abandon changes, or cancel the close. If they select the
cancel close method, e.cancel is set to True. I assumed that this would
cause the Application.Exit to cancel, but it apparently does not. So the
question is what is the proper way to give the user a chance to abort the
close?

Thanks,

Jerry
 
Jerry,
In the MDI parent, I would close each of my (MDI) children (with
Form.Close). If after closing all of my children if there are any left open
(unsaved data) I would let the app keep running otherwise I would close the
MDI parent (with either Form.Close or Application.Exit).

I would not use Application.Exit only unless I clearly needed to app to
terminate immediately. As Application.Exit causes the Win32 message pump to
exit, which causes the Application.Run to return in your Main routine.

Hope this helps
Jay
 
Back
Top