I did not parse the closing events of the main window and the sub-window. When I was concerned with the main window, the sub-window closing events were also triggered. This is a headache for me.
But I still find a way to understand. That is, an "E. closereason" event is added to the sub-window. // Sub-window closing event
Mfmentity. formclosing + = New Formclosingeventhandler (mfmentity_formclosing );
/// <Summary>
/// When the service is closed, a message indicating auto-saving events is displayed.
/// Scott 1, 20070828
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Static Void Mfmentity_formclosing ( Object Sender, formclosingeventargs E)
{
//Determine whether the cursor is the Main Window Interface
Note: Determine whether the primary window is related.
If (E. closereason! =Closereason. mdiformclosing )
{
Arraylist alchanged = New Arraylist ();
If (Mfrmmain. mdichil.pdf. Length > 0 )
{
// Determine whether the front window is fmentity
If (Mfrmmain. activemdichild Is Wincontrols. fmentity)
{
Wincontrols. fmentity fmchanged = (Wincontrols. fmentity) mfrmmain. activemdichild;
If (Fmchanged. Mode = 2 )
{
// Put the window into the arraylist, and then upload the window
Alchanged. Add (fmchanged );
}
}
}
If (Alchanged ! = Null && Alchanged. Count > 0 )
{
Int Iresult = Fronthelper. showexitsaveform (alchanged );
Switch (Iresult)
{
Case 1 :
// Save
Foreach (Wincontrols. fmentity In Alchanged. toarray ( Typeof (Wincontrols. fmentity )))
{
// Save data
Fronthelper. savedata ();
}
Break ;
Case - 1 :
// Don't save
Break ;
Case 0 :
// Cancel
E. Cancel = True ;
Break ;
Default :
// Save
Break ;
}
}
}
}
Parameter type of the closereason Column
member name |
description |
applicationexitcall |
An exit method similar to the (invoke) application is called. |
|
formownerclosing |
the ticket is being closed. |
|
mdiformclosing |
the parent table of the multiple file interface (MDI) table is being reviewed. |
|
none |
the reason for the relationship is not yet clarified or cannot be determined. |
|
taskmanagerclosing |
Microsoft Windows administrators are shutting down applications. |
|
userclosing |
the user is reading the user interface (UI) related table, for example, click [] in the window of the table, select [] in the "" window, or click Alt + F4. |
|
windowsshutdown |
the operating system is shutting down all applications before the host is shut down. |
|
/// <Summary>
/// Main Window closing event
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Private Void Fmmain_formclosing ( Object Sender, formclosingeventargs E)
{
If ( This . Mdichil.pdf. Length > 0 )
{
Arraylist alchanged = New Arraylist ();
For ( Int Iform = 0 ; Iform < This . Mdichil.pdf. length; iform ++ )
{
If ( This . Mdichil1_[ iform] Is Wincontrols. fmentity)
{
Wincontrols. fmentity fmchanged = (Wincontrols. fmentity) This . Mdichil1_[ iform];
If (Fmchanged. Mode = 2 )
{
Alchanged. Add (fmchanged );
}
}
}
If (Alchanged ! = Null && Alchanged. Count > 0 )
{
Int Iresult = Fronthelper. showexitsaveform (alchanged );
Switch (Iresult)
{
Case 1 :
// Save
Foreach (Wincontrols. fmentity In Alchanged. toarray ( Typeof (Wincontrols. fmentity )))
{
Fronthelper. savedata ();
}
Break ;
Case - 1 :
// Don't save
Break ;
Case 0 :
// Cancel
E. Cancel = True ;
Break ;
Default :
// Save
Break ;
}
}
}
}