Results 1 to 3 of 3

Thread: Trap "X" button in form / window

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Singapore
    Posts
    10

    Post

    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.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    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



  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Post

    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).]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width