公共类 clsGlobalVariables
Public Shared mdi_main As mdiMain
结束类
导入 System.Windows.Forms
公共类 mdiMain
Public forced_close As Boolean = False
Private Sub mdiMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
e.Cancel = True
If MsgBox("Are you sure you want to exit?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
' Close all child forms of the parent.
For Each ChildForm As Form In Me.MdiChildren
ChildForm.Close()
Next
e.Cancel = False
End If
End Sub
结束类
公开课 frmMember
Private Sub frmMember_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
Select Case e.CloseReason
Case CloseReason.UserClosing
e.Cancel = True
If Not clsGlobalVariables.mdi_main.forced_close Then
If MsgBox("Are you sure you want to close?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
e.Cancel = False
End If
End If
Case Else
clsGlobalVariables.mdi_main.forced_close = True
e.Cancel = True
End Select
End Sub
结束类