|
-
Apr 4th, 2000, 09:14 PM
#1
Thread Starter
Junior Member
How do I code my program to detect sudden app termination from the upper right "X" ?
-
Apr 4th, 2000, 09:24 PM
#2
Lively Member
Try using this code and see if it works for your situation.
Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Select Case UnloadMode
Case vbFormControlMenu
MsgBox "The user chose the Close command from the Control menu on the form."
Case vbFormCode
MsgBox "The Unload statement is invoked from code."
Case vbAppWindows
MsgBox "The current Microsoft Windows operating environment session is ending."
Case vbAppTaskManager
MsgBox "The Microsoft Windows Task Manager is closing the application."
Case vbFormMDIForm
MsgBox "An MDI child form is closing because the MDI form is closing."
Case vbFormOwner
MsgBox "A form is closing because its owner is closing."
End Select
End Sub
The vbControlMenu is what was passed to the QueryUnload event when I clicked the "X" in the upper right hand corner and when I went to the control menu clicked close.
If you have an exit on your menu bar or a command button the vbFormCode will be passed in.
Is this what your looking for?
-
Apr 4th, 2000, 10:18 PM
#3
Thread Starter
Junior Member
That was pretty neat.
Thanks.
To answer your question, what i was looking for was to ensure that if at anytime , if somewhere in my prgram the user closes the program using the "X" that my program will actually close properly and release it's influence on the system's resources.
Thanks for your help.
-
Apr 5th, 2000, 07:07 AM
#4
Addicted Member
You can also put code in the Form_Unload event to clean up any open objects, etc.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|