|
-
Jul 14th, 2003, 10:52 AM
#1
Thread Starter
Hyperactive Member
Closing Forms
I have a splash screen form (frmSplash) and also a MDI Form (frmMain).
frmSplash loads first and has a timer on it (tmrSplash) it runs the following code on the tick event :
VB Code:
Private Sub tmrSplash_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrSplash.Tick
Dim objMain As New frmMain()
tmrSplash.Enabled = False
objMain.Show()
Me.Close()
End Sub
But the Me.Close() closes the entire application.
What am I doing wrong?
Regards,
Matt.
-
Jul 14th, 2003, 11:01 AM
#2
Frenzied Member
Thats the way it should be, cause the splash form controls the life cycle of your application. Try starting your application from a Sub Main and then after closing the splash form show the main form.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Jul 14th, 2003, 11:03 AM
#3
Fanatic Member
Sounds like you might have your spalsh screen as the startup form.
I think a better way to do it is have your MDI form call the splash screen and then close it when the MDI form has finished loading. I am sure there are other ways to do it as well.
-
Jul 14th, 2003, 11:05 AM
#4
Frenzied Member
Originally posted by VBCrazyCoder
I think a better way to do it is have your MDI form call the splash screen and then close it when the MDI form has finished loading. I am sure there are other ways to do it as well.
But you know that you can not start the main form -better say startup form - of your project hidden, right?
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Jul 14th, 2003, 11:19 AM
#5
-
Jul 14th, 2003, 11:33 AM
#6
Frenzied Member
Originally posted by VBCrazyCoder
But I was not aware of not being able to have a hidden form as a startup form
Is that a bug?
Seems like a feature.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Jul 14th, 2003, 11:38 AM
#7
Thread Starter
Hyperactive Member
Thanks
Thanks for your help.
I ended up using the MDI form as the startup form and loading the Splash Screen, Setting the Opacity to 0% of the MDI form then changing it back to 100% after the splash screen had been closed.
Thanks Again.
-
Jul 14th, 2003, 11:39 AM
#8
Fanatic Member
So in essence, it was hidden. Cool!
-
Aug 5th, 2004, 09:36 AM
#9
Addicted Member
Can anyone help me with an extension of this problem?
I've a MDI app with a start up Child form (splash) which closes whenever another Child (user type) form is opened.
I'd like the splash Child form to return when all other Child forms are closed.
How will I know if the last Child form has gone and I can show the splash again?
Raising events is no use either because I've already built about 20 forms
I've tried an array but some of the child forms have sub forms of their own.
Looked at the properties of MIDlist menu without success.....
Any ideas?
-
Aug 6th, 2004, 04:33 AM
#10
Thread Starter
Hyperactive Member
What about the following :
Pop this in a module :
VB Code:
Module Module1
Public Forms As New FormsCollectionClass()
End Module
Class FormsCollectionClass : Implements IEnumerable
Private c As New Collection()
Sub Add(ByVal f As Form)
c.Add(f)
End Sub
Sub Remove(ByVal f As Form)
Dim itemCount As Integer
For itemCount = 1 To c.Count
If f Is c.Item(itemCount) Then
c.Remove(itemCount)
Exit For
End If
Next
End Sub
ReadOnly Property Item(ByVal index) As Form
Get
Return c.Item(index)
End Get
End Property
Overridable Function GetEnumerator() As _
IEnumerator Implements IEnumerable.GetEnumerator
Return c.GetEnumerator
End Function
End Class
Then on the closed event on the forms (not great I know) put the following :
VB Code:
Dim i As Integer = 0
Dim f As Form
For Each f In Forms
If f.IsMdiChild Then
i = i + 1
End If
Next
If i = 0 Then
' Open Another Form
End If
Hope this is of use.
Matt.
-
Aug 6th, 2004, 03:58 PM
#11
PowerPoster
Originally posted by Steven McGarva
Can anyone help me with an extension of this problem?
I've a MDI app with a start up Child form (splash) which closes whenever another Child (user type) form is opened.
I'd like the splash Child form to return when all other Child forms are closed.
How will I know if the last Child form has gone and I can show the splash again?
Raising events is no use either because I've already built about 20 forms
I've tried an array but some of the child forms have sub forms of their own.
Looked at the properties of MIDlist menu without success.....
Any ideas?
Why not just make sure the position and size of the SplashChild is such that it is hidden behind any other child form visible?
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
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
|