Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Closing From

Closing From

Scheduled Pinned Locked Moved Visual Basic
csharp
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lespaul36
    wrote on last edited by
    #1

    I remember that in vb6 there was a way to get where a form close was called from (ie. clicked x, computer shut down etc.) Is there a way to get this in .net.

    C L 2 Replies Last reply
    0
    • L lespaul36

      I remember that in vb6 there was a way to get where a form close was called from (ie. clicked x, computer shut down etc.) Is there a way to get this in .net.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      How on earth would you get the fact that the form had been shut down by the computer shutting down ? A modal form has a DialogResult, which is some help, but not as much as you're hoping, I don't think. Christian Graus - Microsoft MVP - C++

      L S 2 Replies Last reply
      0
      • C Christian Graus

        How on earth would you get the fact that the form had been shut down by the computer shutting down ? A modal form has a DialogResult, which is some help, but not as much as you're hoping, I don't think. Christian Graus - Microsoft MVP - C++

        L Offline
        L Offline
        lespaul36
        wrote on last edited by
        #3

        The form QueryUnload has a variable called UnloadMode As Integer that could be used to tell you where the unload was called..check it out. It seems they removed this in .Net, bummerr.

        S 1 Reply Last reply
        0
        • L lespaul36

          I remember that in vb6 there was a way to get where a form close was called from (ie. clicked x, computer shut down etc.) Is there a way to get this in .net.

          L Offline
          L Offline
          lespaul36
          wrote on last edited by
          #4

          I have started a project to do it. I am overriding WndProc and catching some of the messages. I am having trouble figuring out which ones though. I have this so far. MyBase.WndProc(m) Select Case m.Msg Case Is = Win32.WindowsMessages.WM_QUERYENDSESSION f = New UnloadModeEventArgs(ECloseMode.AppWindows, False) Case Is = Win32.WindowsMessages.WM_SYSCOMMAND If m.WParam.ToInt32 = Win32.WindowsMessages.SC_CLOSE Then f = New UnloadModeEventArgs(ECloseMode.FormControlMenu, False) End If End Select

          1 Reply Last reply
          0
          • C Christian Graus

            How on earth would you get the fact that the form had been shut down by the computer shutting down ? A modal form has a DialogResult, which is some help, but not as much as you're hoping, I don't think. Christian Graus - Microsoft MVP - C++

            S Offline
            S Offline
            StylezHouse
            wrote on last edited by
            #5

            Windows sends a message to all open applications on the event of a shutdown.

            C 1 Reply Last reply
            0
            • L lespaul36

              The form QueryUnload has a variable called UnloadMode As Integer that could be used to tell you where the unload was called..check it out. It seems they removed this in .Net, bummerr.

              S Offline
              S Offline
              StylezHouse
              wrote on last edited by
              #6

              You can do this by overriding the wndproc method and checking for WM_QUERYENDSESSION

              1 Reply Last reply
              0
              • S StylezHouse

                Windows sends a message to all open applications on the event of a shutdown.

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                Yeah, I know that. But I read the question to be, how to tell how something WAS shut down, not how to tell that something is BEING shut down. So, a child dialog is closed, and the parent works out why. Christian Graus - Microsoft MVP - C++

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups