CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: App Closing

  1. #1
    Join Date
    Apr 1999
    Location
    Michigan, USA
    Posts
    29

    App Closing

    I have a function that is to run when my app is closed. I stuck it in the form's terminate event and it runs like it's supposed to when I use the menu to exit or a command button to exit. Now, when I try to use the close box at the top, it doesn't run. Is there a way I can get this to work? What kind of event happens when someone shuts down the app this way?


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: App Closing

    In the QueryUnload event of a form you can check to see if the X buton was pressed

    private Sub Form_QueryUnload(Cancel as Integer, UnloadMode as Integer)
    if UnloadMode=0 then
    'Do What You Like
    Cancel=true
    end if
    End Sub

    This will stop the form unloading if they press the "X". Unloadmode will also be 0 if they try to close
    the form from its own menu (By click on the icon in the top left corner)


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Apr 1999
    Location
    Michigan, USA
    Posts
    29

    Re: App Closing

    Now I have the problem that the program does not close when the x box is pushed. When I step through the program it runs my function when it is pushed, but the app does not close. What should I put in there to make it close the app?


  4. #4
    Join Date
    Apr 1999
    Location
    Michigan, USA
    Posts
    29

    Re: App Closing

    Nevermind, I figured out if you remove the
    Cancel = 0
    it quits the app. Thanks so much for your help!


  5. #5
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: App Closing

    rate it if it helped you

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured