• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

I want to know how to make an animated turning wait image for my program splash screen?

In my programs splash screen I have a label that says -- ".....Loading Application".  I want like to know how to make the 'turning bar" using the following characters -- \ | / --, that I could place in front of those words.  Thanks you.

Kevin

Also, please provide a software that might actually do these kinds of things, if you know one or two.  
0
kevin33809
Asked:
kevin33809
  • 4
  • 4
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You've tagged VB6 and VB.Net which are pretty different!

What VB are you using?
How are you displaying the splash form?
Is the splash form doing any actual processing?...or is it just eye-candy?
0
 
kevin33809Author Commented:
I'm using VS2008, and programming in Visual Basic.
I'm displaying the splash screen as 'Eye-Candy'.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Is it set via Project --> Properties or are you manually showing it with code?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Essentially you just use a Timer to update the Label:  
Public Class frmSplash

    Private WithEvents tmr As New System.Windows.Forms.Timer

    Private Sub frmSplash_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        tmr.Interval = 250
        tmr.Start()
    End Sub

    Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick
        Static chars() = {"|", "/", "--", "\"}
        Static index As Integer = 0
        Label1.Text = chars(index) & "...Loading Application"

        index = index + 1
        If index = chars.Length Then
            index = 0
        End If
    End Sub

End Class

Open in new window


To keep the splash screen open for your desired amount of time, override the OnInitialize() method and set My.Application.MinimumSplashScreenDisplayTime Property:
http://msdn.microsoft.com/en-us/library/ms234874(VS.80).aspx

Click on Project --> Properties, then "View Application Events" in the bottom right:  
Namespace My

    ' The following events are available for MyApplication:
    ' 
    ' Startup: Raised when the application starts, before the startup form is created.
    ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
    ' UnhandledException: Raised if the application encounters an unhandled exception.
    ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. 
    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    Partial Friend Class MyApplication

        Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
            Me.MinimumSplashScreenDisplayTime = TimeSpan.FromSeconds(5).TotalMilliseconds
            Return MyBase.OnInitialize(commandLineArgs)
        End Function

    End Class

End Namespace

Open in new window

0
 
kevin33809Author Commented:
Question:  In the first textbox is all this code put in the  Load Event in the frmSplashScreen form, or is all this meant to be put in a Class file.  I'm learning here.  It looks to me like it belongs to the Load Event in the frmSplashScreen form

How the code is setup is in the attachment.  This name of the label is Label2 on the Splash screen.  Is the placement of the code correct?

Thank you
Public NotInheritable Class frmSplashScreen 

    Private Sub SplashScreen_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 

        If My.Application.Info.Title <> "" Then 
            ApplicationTitle.Text = My.Application.Info.Description 
        Else 
            'If the application title is missing, use the application name, without the extension 
            ApplicationTitle.Text = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName) 
        End If 

        Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor)
        Copyright.Text = My.Application.Info.Copyright 

    End Sub 

    Public Class frmSplash 
         Private WithEvents tmr As New System.Windows.Forms.Timer 

         Private Sub frmSplash_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
             tmr.Interval = 250 
             tmr.Start() 

         End Sub 

         Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick 
             Static chars() = {"|", "/", "--", "\"} 
             Static index As Integer = 0 
             Label2.Text = chars(index) & "...Loading Application" 
             index = index + 1 
             If index = chars.Length Then 
                 index = 0 
             End If 

         End Sub 

     End Class 

End Class

Open in new window

0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You would just add the code to your existing frmSplashScreen() class.  So you'd just take everything between my "Public Class frmSplash" and "End Class" and insert into your code.  We'd also have to consolidate the Load() event code into your method.

It would look something like:
Public NotInheritable Class frmSplashScreen 

    Private WithEvents tmr As New System.Windows.Forms.Timer 

    Private Sub SplashScreen_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
        If My.Application.Info.Title <> "" Then 
            ApplicationTitle.Text = My.Application.Info.Description 
        Else 
            'If the application title is missing, use the application name, without the extension 
            ApplicationTitle.Text = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName) 
        End If 

        Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor)
        Copyright.Text = My.Application.Info.Copyright 

        tmr.Interval = 250 
        tmr.Start() 
    End Sub 

    Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick 
        Static chars() = {"|", "/", "--", "\"} 
        Static index As Integer = 0 
        Label2.Text = chars(index) & "...Loading Application" 
        index = index + 1 
        If index = chars.Length Then 
            index = 0 
        End If 
   End Sub 

End Class

Open in new window

0
 
kevin33809Author Commented:
Idle_Mind:
I'm writing back to let you know that the code works great.  Thank you for not only showing me HOW to do it, but EXPLAINING how/why it works.  You a good teacher.  Since I trying to mentally migrate from VB6 to VB.net, it hasn't been easy, but I'll get there.  Please, except the 500 point.
0
 
kevin33809Author Commented:
Idle_Mind is one of EE better and thorough trainers/instructors.  I'd keep him.  He doesn't mind teaching a Newbee how to do something, and he does it without complaining and sarcasim.  Great job!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now