dapperry
asked on
Determine s Shutdown|Close All Programs
I have a little program that runs in the system tray. In the Form_Unload event I have a confirmation message box, which asks the user if they really want to exit. However, if the User does a shutdown, restart, or "Close All Programs and Login in as another user" it still gives the confirmation msgbox. I don't want this to happen. So how do I tell if the user or the system is trying to shut the programs down?
:) dapperry
:) dapperry
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, I guess thats one form event I just never got around to looking at!
:) dapperry
:) dapperry
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Select Case UnloadMode
Case vbFormControlMenu
'The user chose the Close command from the Control menu on the form.
Case vbFormCode
'The Unload statement is invoked from code.
Case vbAppWindows
'The current Microsoft Windows operating environment session is ending.
Case vbAppTaskManager
'The Microsoft Windows Task Manager is closing the application.
Case vbFormMDIForm
'An MDI child form is closing
End Select
End Sub