Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Project Properties
Project Designer
 How to: Specify a Splash Screen for...

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual Studio 
How to: Specify a Splash Screen for an Application (Visual Basic) 

Splash screens are often used to display information to a user while an application is loading. Visual Basic provides a preconfigured Splash Screen form template that you can add to your Windows Application project, and a Splash Screen property in the Project Designer that allows you to specify a splash screen for your project.

To add a splash screen template

  1. Select a project in Solution Explorer, and then on the Project menu, click Add New Item.

  2. In the Add New Item dialog box, select the Splash Screen template, and then click Add. The template is added to your project.

To specify a splash screen

  1. Select a project in Solution Explorer, and then on the Project menu, click Properties.

  2. Click the Application tab.

  3. Under Windows application framework properties, in the Splash screen: list, click the form that you want to use as a splash screen.

See Also

Community Content   What is Community Content?
Add new content RSS  Annotations
How to control the duration of a splash screen      shoagMSFT   |   Edit   |   Show History

If your application doesn't contain much initialization code the splash screen may only flash briefly on screen before the main form loads, especially on faster computers. The default display time is 2000 milliseconds (2 seconds).

If you need to show the splash screen for a longer period of time you can override this by setting the MinimumSplashScreenDisplayTime property in the My.Application namespace, which takes an integer specify the number of milliseconds to display the splash screen. The code to display a splash screen for 10 seconds would look like this:

Me.MinimumSplashScreenDisplayTime = 10000

 

Of course, if the application takes longer than10 seconds to load the splash screen will stay up longer.

Tags What's this?: Add a tag
Flag as ContentBug
How to change a status label on the splash sceen from the main form's thread (safely)      Erik Pitti   |   Edit   |   Show History

This tip was written for Visual Basic.NET 2005 and assumes the Splash Screen is called using the Application's splash screen property.

If your application does a significant amount of initialization work (more than a second or two), you may want to tell the user that the app is making progress while executing the main form's Form_Load event. One method of doing this is by adding a label (or textbox) control to the splash screen form and updating it as parts of the application initalization start and finish.

Splash Screen form code changes

On the Splash Screen form you need to first create a delegate to be invoked later from the main thread.

   Delegate Sub UpdateStatusLabel()

Next, create a Sub in the Splash Screen form's code that takes no input parameters but updates your status label. This may not make sense and seem redundant now, but it will once we get into BeginInvoke().

   Public Sub UpdateLabelText1()
Dim msg As String = "Getting Computers from Active Directory..."
Me.lblStatus.Text = msg
End Sub
    
   Public Sub UpdateLabelText2()
Dim msg As String = "Getting Users from Active Directory..."
Me.lblStatus.Text = msg
End Sub


Code to put in Form_Load event on main form

Next, we need to call the code from our Form_Load event (or another sub or function called by Form_Load).

   Private Sub MyForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyForm.Load
       ...Do Something

We'll start by checking if the Spash Screen is on the screen

Next we call BeginInvoke on the Splash Screen object and store its outpuit in an IAsyncResult object

BeginInvoke takes two parameters: delegate and method, specified in the following format:

Delegate(AddressOf Method)

       If My.Application.SplashScreen.Visible = True Then
          Dim aResult As IAsyncResult = My.Application.SplashScreen.BeginInvoke( _
New SplashScreen.UpdateStatusLabel( _
AddressOf SplashScreen.UpdateLabelText1))
       End If
       ...Do Something Else
   End Sub

More

Thats all there is to it. If you're interested in more advanced info on BeginInvoke and its companion function EndInvoke it can be found here ( http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.begininvoke(VS.80).aspx ) in the MSDN library. Here's another example that checks for a return value from the cross-thread operation (BeginInvoke):

           If My.Application.SplashScreen.Visible = True Then
Dim aResult As IAsyncResult = My.Application.SplashScreen.BeginInvoke( _
New SplashScreen.UpdateStatusLabel( _
AddressOf SplashScreen.UpdateLabelText1))
Dim callResult As Integer = 0

callResult = My.Application.SplashScreen.EndInvoke(aResult)
               'call result should be 0 (NERR_SUCCESS)?

End If
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker