Unload Form does not always terminate program execution
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 29

Thread: Unload Form does not always terminate program execution

Hybrid View

  1. #1
    Join Date
    Apr 2003
    Posts
    322

    Unload Form does not always terminate program execution

    I've seen several cases where all of the forms in my app are closed, yet dialog boxes still pop up, indicating a problem.

    This makes the users feel uneasy :-)

    What is the proper way to COMPLETELY terminate execution in a VB app, after all the forms have been unloaded ?

  2. #2
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487
    Just make sure that after you have unloaded the form there shoud be no code in the program that makes use of the form.
    Busy

  3. #3
    Join Date
    Jun 2004
    Location
    Philippines
    Posts
    31
    I agree with Thread1. If there is a need for a form to call an object in another form, programmer must explicitly define a way so that the calling form first check if the owner of the object to be called is loaded or not.
    I am inviting you to join GreenZap. It is just like PAYPAL but it is more rewarding! You get $25 when you join (FREE to sign up) AND you get rewarded also when someone opened an account using your GreenZap promo code! GreenZap is launching June 1st.

    Click here and PREREGISTER

    Have a break. Visit JonelsPlace

  4. #4
    Join Date
    Dec 2001
    Posts
    6,332
    Oddly enough, I've seen cases where a simple single-form program won't completely unload on a system running winME, but on other OS's it's ok. I used End as the last line of code after the form unloads, which seems to have solved the problem.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  5. #5
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    Well...are you sure that all forms are unloaded...? You can check it within the 'Query_Unload' evetn of the main dialog...add the following
    Code:
    Dim FormX as Form
    For Each FormX in Forms
      if FormX.hWnd<> Me.hWnd then
        Debug.Print "Form is still loaded"
        Unload FormX
      End If
    Next
    Ciao, Andreas

    "Software is like sex, it's better when it's free." - Linus Torvalds


    Article(s): Allocators (STL) Function Objects (STL)

  6. #6
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Avoid End command

    Now, read these threads

    http://www.codeguru.com/forum/showth...ight=avoid+end

    http://www.codeguru.com/forum/showth...ight=avoid+end

    and avoid "End" (unless on a very bugged Os...)



    Ps:
    Andreas, nice snippet
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center