Detect Windows Shutdown

Looking for help (code) that will detect when a user has selected to shutdown windows. Please keep in mind I do not need to know how to shutdown windows through code just how to detect if a user has selected to shutdown windows.

Any help would be much appreciated.

Comments

  • : Looking for help (code) that will detect when a user has selected to shutdown windows. Please keep in mind I do not need to know how to shutdown windows through code just how to detect if a user has selected to shutdown windows.
    :
    : Any help would be much appreciated.
    :

    Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

    UnloadMode returns a value witch determine how the program ends.
    By clicking a menubutton or if windows shuts down.

    Hope this helps!

  • : : Looking for help (code) that will detect when a user has selected to shutdown windows. Please keep in mind I do not need to know how to shutdown windows through code just how to detect if a user has selected to shutdown windows.
    : :
    : : Any help would be much appreciated.
    : :
    :
    : Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    :
    : UnloadMode returns a value witch determine how the program ends.
    : By clicking a menubutton or if windows shuts down.
    :
    : Hope this helps!
    :
    :
    Thanks for the tip.. got me to this testing stage:

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

    If UnloadMode = 0 Then
    MsgBox ("User has chosen Close command from the Control-menu box on a form")
    Error_Handler
    End If
    If UnloadMode = 1 Then
    MsgBox ("Unload method invoked from code")
    Error_Handler
    End If
    If UnloadMode = 2 Then
    MsgBox ("Current Windows session ending")
    Error_Handler
    End If
    If UnloadMode = 3 Then
    MsgBox ("Windows Task Manager is closing the application")
    Error_Handler
    End If
    If UnloadMode = 4 Then
    MsgBox ("MDI child form is closing because the MDI form is closing")
    Error_Handler
    End If

    End Sub

    I'm running WinXP but the unloadmode = 2 event is never executed. While I'm the topic neither is the unloadmode = 3 executed. Any suggestions?
  • : : : Looking for help (code) that will detect when a user has selected to shutdown windows. Please keep in mind I do not need to know how to shutdown windows through code just how to detect if a user has selected to shutdown windows.
    : : :
    : : : Any help would be much appreciated.
    : : :
    : :
    : : Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    : :
    : : UnloadMode returns a value witch determine how the program ends.
    : : By clicking a menubutton or if windows shuts down.
    : :
    : : Hope this helps!
    : :
    : :
    : Thanks for the tip.. got me to this testing stage:
    :
    : Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    :
    : If UnloadMode = 0 Then
    : MsgBox ("User has chosen Close command from the Control-menu box on a form")
    : Error_Handler
    : End If
    : If UnloadMode = 1 Then
    : MsgBox ("Unload method invoked from code")
    : Error_Handler
    : End If
    : If UnloadMode = 2 Then
    : MsgBox ("Current Windows session ending")
    : Error_Handler
    : End If
    : If UnloadMode = 3 Then
    : MsgBox ("Windows Task Manager is closing the application")
    : Error_Handler
    : End If
    : If UnloadMode = 4 Then
    : MsgBox ("MDI child form is closing because the MDI form is closing")
    : Error_Handler
    : End If
    :
    : End Sub
    :
    : I'm running WinXP but the unloadmode = 2 event is never executed. While I'm the topic neither is the unloadmode = 3 executed. Any suggestions?
    :

    Theoretically, I s'pose you could use:

    MsgBox UnloadMode

    and see what value, if anything, is passed. If the MsgBox never comes up, you may be out of luck. If it does, then you'll have your value...
  • : : : : Looking for help (code) that will detect when a user has selected to shutdown windows. Please keep in mind I do not need to know how to shutdown windows through code just how to detect if a user has selected to shutdown windows.
    : : : :
    : : : : Any help would be much appreciated.
    : : : :
    : : :
    : : : Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    : : :
    : : : UnloadMode returns a value witch determine how the program ends.
    : : : By clicking a menubutton or if windows shuts down.
    : : :
    : : : Hope this helps!
    : : :
    : : :
    : : Thanks for the tip.. got me to this testing stage:
    : :
    : : Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    : :
    : : If UnloadMode = 0 Then
    : : MsgBox ("User has chosen Close command from the Control-menu box on a form")
    : : Error_Handler
    : : End If
    : : If UnloadMode = 1 Then
    : : MsgBox ("Unload method invoked from code")
    : : Error_Handler
    : : End If
    : : If UnloadMode = 2 Then
    : : MsgBox ("Current Windows session ending")
    : : Error_Handler
    : : End If
    : : If UnloadMode = 3 Then
    : : MsgBox ("Windows Task Manager is closing the application")
    : : Error_Handler
    : : End If
    : : If UnloadMode = 4 Then
    : : MsgBox ("MDI child form is closing because the MDI form is closing")
    : : Error_Handler
    : : End If
    : :
    : : End Sub
    : :
    : : I'm running WinXP but the unloadmode = 2 event is never executed. While I'm the topic neither is the unloadmode = 3 executed. Any suggestions?
    : :
    :
    : Theoretically, I s'pose you could use:
    :
    : MsgBox UnloadMode
    :
    : and see what value, if anything, is passed. If the MsgBox never comes up, you may be out of luck. If it does, then you'll have your value...
    :

    It's worth try
    I wonder why it never reaches that value?

  • : : : : : Looking for help (code) that will detect when a user has selected to shutdown windows. Please keep in mind I do not need to know how to shutdown windows through code just how to detect if a user has selected to shutdown windows.
    : : : : :
    : : : : : Any help would be much appreciated.
    : : : : :
    : : : :
    : : : : Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    : : : :
    : : : : UnloadMode returns a value witch determine how the program ends.
    : : : : By clicking a menubutton or if windows shuts down.
    : : : :
    : : : : Hope this helps!
    : : : :
    : : : :
    : : : Thanks for the tip.. got me to this testing stage:
    : : :
    : : : Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    : : :
    : : : If UnloadMode = 0 Then
    : : : MsgBox ("User has chosen Close command from the Control-menu box on a form")
    : : : Error_Handler
    : : : End If
    : : : If UnloadMode = 1 Then
    : : : MsgBox ("Unload method invoked from code")
    : : : Error_Handler
    : : : End If
    : : : If UnloadMode = 2 Then
    : : : MsgBox ("Current Windows session ending")
    : : : Error_Handler
    : : : End If
    : : : If UnloadMode = 3 Then
    : : : MsgBox ("Windows Task Manager is closing the application")
    : : : Error_Handler
    : : : End If
    : : : If UnloadMode = 4 Then
    : : : MsgBox ("MDI child form is closing because the MDI form is closing")
    : : : Error_Handler
    : : : End If
    : : :
    : : : End Sub
    : : :
    : : : I'm running WinXP but the unloadmode = 2 event is never executed. While I'm the topic neither is the unloadmode = 3 executed. Any suggestions?
    : : :
    : :
    : : Theoretically, I s'pose you could use:
    : :
    : : MsgBox UnloadMode
    : :
    : : and see what value, if anything, is passed. If the MsgBox never comes up, you may be out of luck. If it does, then you'll have your value...
    : :
    :
    : It's worth try
    : I wonder why it never reaches that value?
    :
    :

    If I knew why we got values in the first place, I'd be willing to guess why not. The message sent to a window doesn't include a value, so it has to come from the runtime. I guess XP isn't detectable by the standards in place when the runtime was written...
  • : : : : : : Looking for help (code) that will detect when a user has selected to shutdown windows. Please keep in mind I do not need to know how to shutdown windows through code just how to detect if a user has selected to shutdown windows.
    : : : : : :
    : : : : : : Any help would be much appreciated.
    : : : : : :
    : : : : :
    : : : : : Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    : : : : :
    : : : : : UnloadMode returns a value witch determine how the program ends.
    : : : : : By clicking a menubutton or if windows shuts down.
    : : : : :
    : : : : : Hope this helps!
    : : : : :
    : : : : :
    : : : : Thanks for the tip.. got me to this testing stage:
    : : : :
    : : : : Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    : : : :
    : : : : If UnloadMode = 0 Then
    : : : : MsgBox ("User has chosen Close command from the Control-menu box on a form")
    : : : : Error_Handler
    : : : : End If
    : : : : If UnloadMode = 1 Then
    : : : : MsgBox ("Unload method invoked from code")
    : : : : Error_Handler
    : : : : End If
    : : : : If UnloadMode = 2 Then
    : : : : MsgBox ("Current Windows session ending")
    : : : : Error_Handler
    : : : : End If
    : : : : If UnloadMode = 3 Then
    : : : : MsgBox ("Windows Task Manager is closing the application")
    : : : : Error_Handler
    : : : : End If
    : : : : If UnloadMode = 4 Then
    : : : : MsgBox ("MDI child form is closing because the MDI form is closing")
    : : : : Error_Handler
    : : : : End If
    : : : :
    : : : : End Sub
    : : : :
    : : : : I'm running WinXP but the unloadmode = 2 event is never executed. While I'm the topic neither is the unloadmode = 3 executed. Any suggestions?
    : : : :
    : : :
    : : : Theoretically, I s'pose you could use:
    : : :
    : : : MsgBox UnloadMode
    : : :
    : : : and see what value, if anything, is passed. If the MsgBox never comes up, you may be out of luck. If it does, then you'll have your value...
    : : :
    : :
    : : It's worth try
    : : I wonder why it never reaches that value?
    : :
    : :
    :
    : If I knew why we got values in the first place, I'd be willing to guess why not. The message sent to a window doesn't include a value, so it has to come from the runtime. I guess XP isn't detectable by the standards in place when the runtime was written...
    :
    It's very strange but I'm sure their is a work around, just matter of playing around and reseaching. The app I would like to develop depends on this so I really don't have much choice but to be keep digging throught the depths of the net.
  • : It's very strange but I'm sure their is a work around, just matter of playing around and reseaching. The app I would like to develop depends on this so I really don't have much choice but to be keep digging throught the depths of the net.
    :

    Have fun and good luck!!!!!!!!!!
  • Well if it's a log off event, does the form_unload event trigger? Maybe you could use that for the triggers that aren't registering? This is guess work because I've never worked with XP

    Hope that helps.
  • : Well if it's a log off event, does the form_unload event trigger? Maybe you could use that for the triggers that aren't registering? This is guess work because I've never worked with XP
    :
    : Hope that helps.
    :

    I think they are both trigered! Only form_unload doesn't include a variable wich tells you how the form was unloaded.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories