CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2006
    Posts
    181

    Splash Screen Prevents App From Closing

    I added an splash screen to my app. Then in the project settings I selected it to be used for the splash screen. Now my app won't close when I try to exit my app.

    I have 'When Last Form Closes' selected for the shutdown mode. So I'm guessing the splash screen is calling Hide() instead of Close(). I can't find a way to get access to the splash screen object so I can try callling Close().

    Does anyone know what I need to do to get my app to close?


    Thanks,

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Splash Screen Prevents App From Closing

    I tried this with a new project and it is working as expected. When I close the form (other than splash), it actually closes the application.

    Is there anything different in your project. May be some other form is open. Put a break point on the main form's FormClosed event and check what is the count of My.Application.OpenForms.

  3. #3
    Join Date
    Oct 2006
    Posts
    181

    Re: Splash Screen Prevents App From Closing

    I also created a new project with absolutely no code in it and it doesn't close as I previously described. Did you set the shutdown mode to 'When Last Form Closes' like mine?

    Anyway, I checked My.Application.OpenForms and it is showing an open form and it is the splash screen.

    Since you mentioned My.Application.OpenForms, I thought I might be able to close the window from there however I get an exception when I tried that.

    Cross-thread operation not valid: Control 'SplashScreen1' accessed from a thread other than the thread it was created on.

    Any other thoughts?


    Thanks,

  4. #4
    Join Date
    Feb 2009
    Posts
    252

    Re: Splash Screen Prevents App From Closing

    I had the same problem too, well its similar i think in my case it was a login form.

    dont set the the splash as starting object since if its closed all your application will close and if it doesnt get closed ur application will remain in proceses, even if u terminate all other forms.


    my solution was putting the real Main form as starting object but starting with 0% opacity+Locked then after the login was successful y unlock and give 100% opacity and it works fine!.

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Splash Screen Prevents App From Closing

    Minimized is probably better. That way, the user knows it's there
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    Join Date
    Oct 2006
    Posts
    181

    Re: Splash Screen Prevents App From Closing

    I tried handling the VisibleChanged event and calling Close() is Visible = false. However, it never got called when the splash screen went away. It must be doing something other than calling Hide()

    I don't know why they would put in a splash screen option when it's not even going to work out-of-the box. Since apparently there's no standard solution I'll just have to think of a hack to close the splash screen.


    Thanks,

  7. #7
    Join Date
    Oct 2006
    Posts
    181

    Re: Splash Screen Prevents App From Closing

    In case your curious, this is what I decided to do.

    I added this to the splash screen

    Code:
        Delegate Sub CloseCallback()
    
        Public Sub CloseForm()
    
            If InvokeRequired Then
                Dim d As New CloseCallback(AddressOf Close)
                Invoke(d, New Object() {})
            Else
                Close()
            End If
    
        End Sub
    then at the end of Load() in my main form I added this
    Code:
    CType(My.Application.OpenForms("SplashScreen1"), SplashScreen1).CloseForm()

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