Private Sub sxcad_setup_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
If New StackTrace().GetFrames().Any(Function(x) x.GetMethod().Name = "Close") Then
MessageBox.Show("Closed by calling Close()")
Else
MessageBox.Show("Closed by X or Alt+F4")
End If
End Sub