Click to See Complete Forum and Search --> : Trap "X" button in form / window
wongqc
Jan 16th, 2000, 03:30 PM
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.
Joacim Andersson
Jan 16th, 2000, 03:57 PM
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
joacim@programmer.net
joacim@yellowblazer.com
www.YellowBlazer.com (http://www.YellowBlazer.com)
MartinLiss
Jan 16th, 2000, 09:54 PM
There are several other values in addition to vbFormControlMenu that depending on your goal you might want to check for. They are:
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).]
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.