-
March 31st, 2009, 12:19 PM
#1
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,
-
March 31st, 2009, 01:10 PM
#2
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.
-
March 31st, 2009, 01:21 PM
#3
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,
-
March 31st, 2009, 06:32 PM
#4
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!.
-
March 31st, 2009, 08:26 PM
#5
Re: Splash Screen Prevents App From Closing
Minimized is probably better. That way, the user knows it's there
-
April 1st, 2009, 08:38 AM
#6
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,
-
April 1st, 2009, 08:52 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|