?
Solved

Splash Screen - how to?

Posted on 2004-10-12
9
Medium Priority
?
240 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

777 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