Closing Event in MDI Child Forms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff Olding

    Closing Event in MDI Child Forms

    In VB.Net, What events (if any), does an MDI child form
    get when the application closes, which I can use to cancel
    the close?
    I am relying on the Closing event, which fires when the
    form itself closes, however this doesn't fire when the
    application closes. I can't find any alternative.
  • Armin Zingler

    #2
    Re: Closing Event in MDI Child Forms

    "Geoff Olding" <Geoff.Olding@C ityComputers.co .uk> schrieb[color=blue]
    > In VB.Net, What events (if any), does an MDI child form
    > get when the application closes, which I can use to cancel
    > the close?
    > I am relying on the Closing event, which fires when the
    > form itself closes, however this doesn't fire when the
    > application closes. I can't find any alternative.[/color]

    It does fire when the application closes - unless you kill your app the hard
    way by using "End" or "Application.Ex it".


    --
    Armin




    Comment

    • Geoff Olding

      #3
      Re: Closing Event in MDI Child Forms


      I don't get this result, I cannot get the event to fire whichever way I
      close down the application


      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: Closing Event in MDI Child Forms

        * Geoff Olding <geoff.olding@c itycomputers.co .uk> scripsit:[color=blue]
        > I don't get this result, I cannot get the event to fire whichever way I
        > close down the application[/color]

        Maybe you want to "subscribe" to the 'MdiParent''s 'Closing' event using
        'AddHandler'/'RemoveHandler' .

        --
        Herfried K. Wagner [MVP]
        <http://www.mvps.org/dotnet>

        Comment

        • Armin Zingler

          #5
          Re: Closing Event in MDI Child Forms

          "Geoff Olding" <geoff.olding@c itycomputers.co .uk> schrieb[color=blue]
          >
          > I don't get this result, I cannot get the event to fire whichever way
          > I close down the application[/color]

          _How_ do you close the application? Is there an End statement or
          Application.Exi t anywhere? What if you set a breakpoint in the MDI
          container's closing and/or closed events? Are they hit? What does the
          callstack say when they are?

          Can you reproduce it in a new project?


          --
          Armin




          Comment

          • Geoff Olding

            #6
            Re: Closing Event in MDI Child Forms

            In response to your questions:

            The application is closed in two ways: - the user can either close down
            the MDI form from the control box, or use an "Exit" menu item, which
            just does the following:
            Me.Close

            The application stops on breakpoints in the Closing and Closed Events
            (in th elater case, provided I temporarily remove some code I have on
            the MDI form's "onClosed" event)
            The Callstack on "Closing" is as follows:[color=blue]
            > Polygonal.exe!P olygonal.frmMdi .frmMdi_Closing (Object sender =[/color]
            {Polygonal.frmM di}, System.Componen tModel.CancelEv entArgs e =
            {System.Compone ntModel.CancelE ventArgs}) Line 1450 Basic
            [<Non-user Code>]
            Polygonal.exe!P olygonal.basGlo bal.Main() Line 39 + 0xb bytes Basic

            The problem can be reproduced in a new project - I have created a simple
            project with an MDI form and an MDI child form and get the same problem

            *** Sent via Developersdex http://www.developersdex.com ***
            Don't just participate in USENET...get rewarded for it!

            Comment

            • Geoff Olding

              #7
              Re: Closing Event in MDI Child Forms

              Thanks - this has done the trick



              *** Sent via Developersdex http://www.developersdex.com ***
              Don't just participate in USENET...get rewarded for it!

              Comment

              • Armin Zingler

                #8
                Re: Closing Event in MDI Child Forms

                "Geoff Olding" <geoff.olding@c itycomputers.co .uk> schrieb[color=blue]
                > Thanks - this has done the trick[/color]

                I don't understand this. You wrote:

                "I am relying on the Closing event, which fires when the
                form itself closes, however this doesn't fire when the
                application closes."

                Now the Closing event does fire?


                --
                Armin




                Comment

                Working...