Solved

Splash Screen - how to?

Posted on 2004-10-12
9
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 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