Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Splash Screen - how to?

Posted on 2004-10-12
9
Medium Priority
?
241 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
Technology Partners: 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

636 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