Hi all,
Does anyone know how to trap the "X" button found in the upper right hand corner of any window / form? I need to call a function when it is triggered.
Thanx in advance.
Printable View
Hi all,
Does anyone know how to trap the "X" button found in the upper right hand corner of any window / form? I need to call a function when it is triggered.
Thanx in advance.
Use the QueryUnload Event of the form and check the unloadmode for the vbFormControlMenu value:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormControlMenu Then
'Make your call here
End If
End Sub
Good luck!
------------------
Joacim Andersson
[email protected]
[email protected]
www.YellowBlazer.com
There are several other values in addition to vbFormControlMenu that depending on your goal you might want to check for. They are:
------------------Code:Constant Value Description
vbFormControlMenu 0 The user chose the Close command from the Control menu on the form.
vbFormCode 1 The Unload statement is invoked from code.
vbAppWindows 2 The current Microsoft Windows operating environment session is ending.
vbAppTaskManager 3 The Microsoft Windows Task Manager is closing the application.
vbFormMDIForm 4 An MDI child form is closing because the MDI form is closing.
vbFormOwner 5 A form is closing because its owner is closing.
Marty
[This message has been edited by MartinLiss (edited 01-17-2000).]