Hi
I would like to know how can I handle the event that the user press
the red button "X" (The button which suppose to close the program) ?
I tried to double click on it (in the form editor) but nothing
happened...
Thanks
Yhlove
Just in case the other mentioned events don't do what you need/want,
here's a snippet from Herfried Wagner that can be used to trap the
windows messages that correspond to the 3 buttons on the form (close,
minimize, restore down)
Oh, please no one yell at me for posting this here, I realize in 99%
of situations the FormClosing/FormClosed events will be more than
sufficient. This is mainly for the benefit of people who might be
searching the archives for "Handle X button" that need to use a
wndproc override (you know, the other 1%)
Thanks,
Seth Rowe
Is there a way I can get into a form's close/minimize/maximize events when
those buttons (the 3 small squared button in the upper right corner of a
form) are clicked?
\\\
Private Const WM_SYSCOMMAND As Int32 = &H112
Private Const SC_MAXIMIZE As Int32 = &HF030
Private Const SC_MINIMIZE As Int32 = &HF020
Private Const SC_RESTORE As Int32 = &HF120
Private Const SC_CLOSE As Int32 = &HF060
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_SYSCOMMAND Then
Select Case m.WParam.ToInt32()
Case SC_MAXIMIZE
Debug.WriteLine("Form gets maximized.")
Case SC_MINIMIZE
Debug.WriteLine("Form gets minimized.")
Case SC_RESTORE
Debug.WriteLine("Form gets restored.")
Case SC_CLOSE
Debug.WriteLine("Form gets closed.")
End Select
End If
MyBase.WndProc(m)
End Sub
///