I need your assistence with a Splash Screen and A timer. I would like the timer to control how long the Splash Screen is Visable. I am using VB.net so I am not sure if the code for VB6 would work. Below is the code for my MDI Parent and if anyone could perhaps show me or tell me where the requested code is supposed to be I would greatly appriciate it. By the way the name of my Splash Screen form is "WelcomeScreen"
Public Class Main
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
Private Sub MenuItemCascade_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuItemCascade.Click
Me.LayoutMdi(MdiLayout.Cascade)
End Sub
Private Sub MenuItemClose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuItemClose.Click
Dim frm As Form
For Each frm In Me.MdiChildren
frm.Close()
Next
End Sub
Private Sub MAINForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ctl As Control
Dim ctlMDI As MdiClient
' Loop through all of the form's controls looking
' for the control of type MdiClient.
For Each ctl In Me.Controls
Try
' Attempt to cast the control to type MdiClient.
ctlMDI = CType(ctl, MdiClient)
' Set the BackColor of the MdiClient control.
ctlMDI.BackColor = Me.BackColor
Catch exc As InvalidCastException
' Catch and ignore the error if casting failed.
End Try
Next
End Sub
Private Sub MenuItemOpen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuItemOpen.Click
Dim openFileDialog1 As New OpenFileDialog()
If openFileDialog1.ShowDialog() = DialogResult.OK Then
openFileDialog1.OpenFile()
End If
End Sub
Private Sub MenuItemPrintPreview_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuItemPrintPreview.Click
PrintPreviewDialog1.ShowDialog()
End Sub
Here you go, I did a simple little example for you. form1 is the main form for your app, form2 will be your splash screen. You need to add a timer to form1. form1 should be the start up form.
There are other ways to do this, this is just one.
VB Code:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Dim frmTemp As Form2 'Make a reference to the splash here.
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
frmTemp = New Form2() 'Create an instance of the splash
Timer1.Interval = 4000 'Set how long you want it to show for.
Timer1.Start() 'Start the timer.
frmTemp.ShowDialog() 'Show the form modally.
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Timer1 As System.Windows.Forms.Timer
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
'
'Timer1
'
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Name = "Form1"
Me.Text = "Form1"
End Sub
#End Region
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Stop() 'Stop the timer
frmTemp.Hide() 'Hide the splash
frmTemp.Dispose() 'Now dispose of the splash, no longer needed.
That is easy, but the whole purpose of the splash screen is to give the user something to look at while your app is loading. So loading your app after you get rid of the splash screen isn't good because the user now has to wait longer when you could have been taking care of it in the background.
Sorry if this doesn't make sense. I am really hung over from last night.
Question on your response with the simple example. I'm trying to show a splash screen as a combobox is being filled. Where exactally would I put the call to the sub that fills the combo? Presently I have the splash screen showing for the interval of the timer and then the splash closes and the app just hangs until the fillcombo processes. I'm missing something & hope you can help.
#Region " Windows Form Designer generated code "
Dim frmSplash As New Splash()
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
frmSplash = New Splash()
Timer1.Interval = 40000
Timer1.Start()
frmSplash.ShowDialog()
'Add any initialization after the InitializeComponent() call
Call subFillCombo() 'Where does this go??
End Sub
(Rest of Windows Form Designer generated code)
# End Region
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick