[RESOLVED] Form closing when it shouldn't be.
Hi all,
I have created a splash screen and it fades in. When the splash screen closes, the main form (MDI) should open. The main form opens but then immediately closes. I am not sure what's going on, any ideas? Here is my code. Thanks.
vb Code:
Public Class frmSplash
Private Sub frmSplash_FormClosing(ByVal sender As Object, _
ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
'Opem the MDI form.
frmMain.Show()
End Sub
Private Sub frmSplash_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
'Fade form in.
For i As Integer = 0 To 100 Step 1
Me.Opacity = i / 100
Me.Refresh()
Threading.Thread.Sleep(50)
Next i
Me.Close()
End Sub
End Class
Re: Form closing when it shouldn't be.
That would be because your splash screen is the startup form and your app is set to exit when the startup form closes. You could set the application to exit when all forms have closed but I would recommend doing things rather differently.
My first choice would be to display the splash screen not as the startup form but as the splash screen, as intended. You can then use my Window Animation thread in the CodeBank to learn how to fade a form in and out using the OS rather than a Timer.
Re: Form closing when it shouldn't be.
Try changing the shutdown mode in your project properties from "when startup form closes" to "when last form closes".
I was too slow....
Re: Form closing when it shouldn't be.