Solved

Splash Screen - how to?

Posted on 2004-10-12
9
230 Views
Last Modified: 2010-04-23
How do I make a splash screen that shows while app is starting or for a few seconds?

It should just be a jpeg (no borders, title bar, icon etc) with some (variable) text labels on it.

After app has finished loading (or after 3-4 seconds) the first form should be showed.
0
Comment
Question by:netslt
9 Comments
 
LVL 28

Expert Comment

by:iboutchkine
ID: 12291797
'add new form fmSplash ( it will be your splash screen)

Imports System.Threading

Public Class Form1
    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

    '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 Button1 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(120, 108)
        Me.Button1.Name = "Button1"
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "Button1"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Controls.Add(Me.Button1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region
    Shared thrSplash As Thread


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim clsSplash As New cThreadSplash
        thrSplash = New Thread(New ThreadStart(AddressOf clsSplash.thSplashDisplay))
        thrSplash.Start()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MsgBox("main form")
    End Sub
End Class
Public Class cThreadSplash
    Public Sub thSplashDisplay()
        Dim f As New fmSplash
        f.Text = "Splash Screen"
        Try
            f.ShowDialog()
        Catch es As ThreadAbortException
            Thread.ResetAbort()
        Catch
        End Try
    End Sub
End Class
0
 
LVL 10

Expert Comment

by:Hans Langer
ID: 12292316
a little modification with a timer.

Public Class cThreadSplash

   Dim WithEvents T As New Timers.Timer
   Dim f As New fmSplash

   Public Sub thSplashDisplay()

      T.Interval = 3000 ' 3 seconds
      T.Start()

      f.Text = "Splash Screen"
      Try
         f.ShowDialog()
      Catch es As ThreadAbortException
         Thread.ResetAbort()
      Catch
      End Try
   End Sub
   Private Sub T_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles T.Elapsed
      f.Close()
   End Sub
End Class

GL
0
 
LVL 10

Expert Comment

by:Hans Langer
ID: 12292327
Sorry i forgget "t.stop"

Private Sub T_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles T.Elapsed
      f.Close()
      t.stop
   End Sub
0
 

Author Comment

by:netslt
ID: 12292408
Thanks!

So do I have to call

  Public Sub thSplashDisplay()

from my main form, it will display the splash form, and then after defined time the main form will show again?

And I also put   Public Sub thSplashDisplay() etc. in my main form?

And how does thSplashDisplay show a form instead of text?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 10

Expert Comment

by:Hans Langer
ID: 12292586
you have to add to project a new form called "fmSplash "

For hide border add this line into "fmSplash"
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None

f.Text = "Splash Screen" <- Mean the title of form "Splash Screen"

If you put the thSplashDisplay method on FORM_LOAD event  it will just showed on load.
GL
0
 

Author Comment

by:netslt
ID: 12292829
When I add

thSplashDisplay()

within the  Form1_Load

I get an error that it can not access a member that has not been declared as "shared" and that I have to use an object reference.

So what do I do?
0
 
LVL 10

Accepted Solution

by:
Hans Langer earned 200 total points
ID: 12293206
Where you got this error?

you have to add those line

'This line in the class declaration
Private thrSplash As Thread

'in FORM1_LOAD
Dim clsSplash As New cThreadSplash
thrSplash = New Thread(New ThreadStart(AddressOf clsSplash.thSplashDisplay))
thrSplash.Start()
0
 

Author Comment

by:netslt
ID: 12295761
This works perfectly - thanks a lot!

One last question - do you know how to center the splash screen on the screen?

0
 
LVL 18

Assisted Solution

by:armoghan
armoghan earned 50 total points
ID: 12295952
that is how you center a form
this.StartPosition = FormStartPosition.CenterScreen;


also see the following link
http://www.csharphelp.com/archives2/archive355.html
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now