Actually I've done this in C#. I'll convert it to VB for this thread.
Some advice though: Both Microsoft and the .NET community are generally
going to be more proficient in C#, especially for advanced functionality.
Ideally, you're going to want to create a new form and show it in Main sub,
perform your application-wide options, and then start your main form on
Application.Run (a.k.a. The UI thread). Unfortunately, there's a bug in .NET
that minimizes all forms if a form is loaded before the UI thread is
finished constructing it's primary form.
I've created an example that builds in VB.NET. Make sure you've installed
SP1, though. Keep in mind you have to manually install SP1 on the emulator,
too.
The following example has 4 Classes: Form1.vb, Form2.vb, EntryPoint.vb, and
Splash.vb. In short, Form2.vb has your final Splash form Solution. Form1.vb
and EntryPoint.vb contain the Ideal code, because they better conform to OOP
standards: Application initialization is contained in the Entry Point. Form2
embeds the application initialization within its own code. Since application
initialization does not pertain directly Form2.vb, it's considered an OOP
standard violation. It's the only way around the bug, however, so both
examples are included. Hopefully this bug will be addressed in .NET CF 2.0,
or someone will discover a better workaround.
I'll post an article about this on code-project with more detailed
information soon.
On a side note: Spawning multiple threads in Windows Forms should be avoided
for "Smart Devices" as much as possible. Use Application.DoEvents whenever
possible. Two reasons: In order to alter a Windows Forms Control from a
background thread, you have to invoke control on the UI thread. Thread
invokation is pretty limited in CF 1.0. Secondly, low-power processors don't
a lot of resources dedicated to context-switching, so it's going to be much
easier to thrash your processor by spawning multiple threads.
Let me know if you have any more questions.
--------FORM2.VB-------
Public Class Form2
Inherits System.Windows.Forms.Form
Private p_Splash As Splash
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
MyBase.Dispose(disposing)
End Sub
'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.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.Text = "Form2"
End Sub
#End Region
#Region "Overrides"
Protected Overloads Overrides Sub OnClosing(ByVal e As
System.ComponentModel.CancelEventArgs)
MyBase.OnClosing(e)
End Sub
Protected Overloads Overrides Sub OnLoad(ByVal e As System.EventArgs)
p_Splash = New Splash
p_Splash.Show()
p_Splash.Status = "Loading..."
System.Threading.Thread.CurrentThread.Sleep(1000)
p_Splash.Status = "Connecting..."
System.Threading.Thread.CurrentThread.Sleep(1000)
p_Splash.Status = "Cleaning up..."
System.Threading.Thread.CurrentThread.Sleep(1000)
p_Splash.Hide()
p_Splash.Dispose()
Focus()
Show()
MyBase.OnLoad(e)
End Sub
#End Region
End Class
---------SPLASH.VB-------
Public Class Splash
Inherits System.Windows.Forms.Form
Friend WithEvents lblStatus As System.Windows.Forms.Label
#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
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
MyBase.Dispose(disposing)
End Sub
'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.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.lblStatus = New System.Windows.Forms.Label
'
'lblStatus
'
Me.lblStatus.Location = New System.Drawing.Point(8, 104)
Me.lblStatus.Size = New System.Drawing.Size(224, 20)
Me.lblStatus.TextAlign = System.Drawing.ContentAlignment.TopCenter
'
'Splash
'
Me.Controls.Add(Me.lblStatus)
Me.Text = "Splash"
End Sub
#End Region
#Region " Public Properties "
Public Property Status() As String
Get
Return lblStatus.Text
End Get
Set(ByVal Value As String)
If (Value = Nothing) Then
Throw New ArgumentNullException("Value")
End If
If (Value = String.Empty) Then
Throw New ArgumentException("Value cannot be empty")
End If
lblStatus.Text = Value
Application.DoEvents()
End Set
End Property
#End Region
End Class
--------ENTRYPOINT.VB-----
Public Class EntryPoint
Public Shared Sub Main()
Dim s As Splash
s = New Splash
s.Show()
s.Status = "Loading something..."
System.Threading.Thread.CurrentThread.Sleep(1000)
s.Status = "Connecting to Something..."
System.Threading.Thread.CurrentThread.Sleep(1000)
s.Status = "Cleaning it up..."
System.Threading.Thread.CurrentThread.Sleep(1000)
Application.Run(New Form1)
s.Close()
s.Dispose() 'Very important to call this! Application.Run usually
handles this.
End Sub
End Class
--------FORM1.VB--------
Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
Focus()
Show()
'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)
MyBase.Dispose(disposing)
End Sub
'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.
Private Sub InitializeComponent()
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.Label1 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox3 = New System.Windows.Forms.TextBox
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 24)
Me.Label1.Text = "Data Entry"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(16, 64)
Me.TextBox1.Text = "TextBox1"
'
'TextBox2
'
Me.TextBox2.Font = New System.Drawing.Font("Tahoma", 9.0!,
System.Drawing.FontStyle.Regular)
Me.TextBox2.Location = New System.Drawing.Point(16, 96)
Me.TextBox2.Text = "TextBox2"
'
'TextBox3
'
Me.TextBox3.Font = New System.Drawing.Font("Tahoma", 9.0!,
System.Drawing.FontStyle.Regular)
Me.TextBox3.Location = New System.Drawing.Point(16, 128)
Me.TextBox3.Text = "TextBox3"
'
'Form1
'
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label1)
Me.Menu = Me.MainMenu1
Me.Text = "Form1"
End Sub
#End Region
End Class