Hi,
Override WndProc on the form. Here is a VB.Net example.
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Const WM_SYSCOMMAND = &H112
Const SC_CLOSE = &HF060&
If m.Msg = WM_SYSCOMMAND Then
' Do something
ElseIf m.Msg = SC_CLOSE Then
' Do something else
End If
' Need to call the mybase.wndproc or the app wont work
MyBase.WndProc(m)
End Sub
Ken