locked
Splash Screen... Delay?

    Question

  • Hello,
    I made this splash screen and since I just started working on my project,
    the app takes less than two seconds to load and the time for splash screen...
    .....is not enough....?

    I have tried to put

    System.Threading.Thread.Sleep(5000)

    but where?

    I put it in the code of the splash screen, then it waits 5 seconds before showing the splashscreen

    and I put it in the main program, then the
    splash screen is out THEN it waits 5 seconds after the splash screen is gone
    THEN it loads....

    I am very lost...

    Thank You for any reply!
    Keehun Nam

    Saturday, October 29, 2005 2:29 AM

Answers

  • If you want to change the default splash screen display time, then in the project property's Application page, click on "View Application Events".  This will create a new file ApplicationEvents.vb.  Open the Partial Friend Class MyApplication in that file, add this code:

    Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean

    'Set the splash screen timeout.

    Me.MinimumSplashScreenDisplayTime = 5000
    Return MyBase.OnInitialize(commandLineArgs)

    End Function

    Cathal

    Saturday, October 29, 2005 3:33 PM
    Moderator

All replies

  • If you want to change the default splash screen display time, then in the project property's Application page, click on "View Application Events".  This will create a new file ApplicationEvents.vb.  Open the Partial Friend Class MyApplication in that file, add this code:

    Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean

    'Set the splash screen timeout.

    Me.MinimumSplashScreenDisplayTime = 5000
    Return MyBase.OnInitialize(commandLineArgs)

    End Function

    Cathal

    Saturday, October 29, 2005 3:33 PM
    Moderator
  • If you really want to put your wait code in the splash form, you would put your sleep call in Form_Load, but call Me.Show first.
    Sunday, October 30, 2005 9:55 PM
  • Well, I tried to put the system.sleep thing but
    I either delays before the splash comes up
    or, after splash, or either when drawing the splash
    so that the splash it all jurky at the beginning because
    it seems like it takes like a two second break after like fifty pixels it drew on the screen...

    Thank you anyway!
    Keehun Nam
    Tuesday, November 22, 2005 4:24 AM
  •  Cathal Connolly wrote:
    If you want to change the default splash screen display time, then in the project property's Application page, click on "View Application Events".  This will create a new file ApplicationEvents.vb.  Open the Partial Friend Class MyApplication in that file, add this code:

    Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean

    'Set the splash screen timeout.

    Me.MinimumSplashScreenDisplayTime = 5000
    Return MyBase.OnInitialize(commandLineArgs)

    End Function

    Cathal

     

    I have tried this and it does not work. What is the correct solution to display a splash screen for longer than 2 secs?

     

     

    Thanks.

    Wednesday, December 28, 2005 4:12 PM
  • Your code to delay the splash screen works great. Thanks!

    How do I make the splash screen to sit there until the user clicks on it?

    Thanks in advance!

    JE

     

    Thursday, March 23, 2006 6:13 AM
  • This works in VB 2005, all SKU's from Express to VSTS

    Whats not working ?

    You are using 2005 ?

     

    Thursday, March 23, 2006 5:43 PM
  • I would like to know this as well.  The other posts were not very helpful to me.
    Tuesday, April 25, 2006 1:10 AM
  •  TedWagner wrote:
    I would like to know this as well.  The other posts were not very helpful to me.

     

    Ahhhhhh, Ok.  Sorry, I figured it out.  Works very nice.

    From the solutions explorer, right click on your project and chose properties.

    To the left are your properties tabs.

    Top one is application.  Click on it.

    (make sure you've added the splash screen item)

    Near the bottom is the splash screen selector.  Select the splash screen vb item you just added.

    Click on the "view application events" button.

    Code should look like this:

    Namespace My

    ' The following events are availble 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

    'Begin code paste below

    Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean

    'Set the splash screen timeout.

    Me.MinimumSplashScreenDisplayTime = 5000

    Return MyBase.OnInitialize(commandLineArgs)

    End Function

    'End code paste

     

    End Class

    End Namespace

    Tuesday, April 25, 2006 1:16 AM
  • This code realy help me.

    I have change the delay time to 5 sec using the MinimumSplashScreenDisplayTime property. However, the splash screen and the mainform show up almost at the same time. The splash screen site on top of the main form for 5 sec then disappear. What I'd like to do is to show the splash screen for 5 sec, then make it disappear, then show the mainForm. Any advice?

    Thanks

     

    Thursday, July 27, 2006 12:20 AM
  • This code realy help me.

    I have change the delay time to 5 sec using the MinimumSplashScreenDisplayTime property. However, the splash screen and the mainform show up almost at the same time. The splash screen site on top of the main form for 5 sec then disappear. What I'd like to do is to show the splash screen for 5 sec, then make it disappear, then show the mainForm. Any advice?

    Thanks

    Thursday, July 27, 2006 12:22 AM
  • This is all well and good, but what happens if opening the ApplicationEvents.vb does nothing?  The file opens, but it is blank.  Any help would be appreciated.

    Cheers
    Jacob

    Monday, July 31, 2006 8:42 AM
  • On the solutions explorer, look for the Application.Designer.vb under Application.myapp, which is under the My Project folder.  Paste the code there.  It should work as well.

    The code should look something like this.  Look for the splash screen delay code at the bottom:

     

    '------------------------------------------------------------------------------

    ' <auto-generated>

    ' This code was generated by a tool.

    ' Runtime Version:2.0.50727.42

    '

    ' Changes to this file may cause incorrect behavior and will be lost if

    ' the code is regenerated.

    ' </auto-generated>

    '------------------------------------------------------------------------------

    Option Strict On

    Option Explicit On

     

    Namespace My

    'NOTE: This file is auto-generated; do not modify it directly. To make changes,

    ' or if you encounter build errors in this file, go to the Project Designer

    ' (go to Project Properties or double-click the My Project node in

    ' Solution Explorer), and make changes on the Application tab.

    '

    Partial Friend Class MyApplication

    <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _

    Public Sub New()

    MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)

    Me.IsSingleInstance = true

    Me.EnableVisualStyles = true

    Me.SaveMySettingsOnExit = true

    Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses

    End Sub

    <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _

    Protected Overrides Sub OnCreateMainForm()

    Me.MainForm = Global.MyApp1.Form1

    End Sub

    <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _

    Protected Overrides Sub OnCreateSplashScreen()

    Me.SplashScreen = Global.MyApp1.SplashScreen1

    End Sub

    Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean

    'Set the splash screen timeout.

    Me.MinimumSplashScreenDisplayTime = 4000

    Return MyBase.OnInitialize(commandLineArgs)

    End Function

    End Class

    End Namespace

     

    I hope it helps.  It works on Visual Studio 2005.

    Monday, July 31, 2006 7:05 PM
  • If you'd like to see how to bypass the splash screen

    during program start-up, see:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=768807&SiteID=1

    Saturday, September 30, 2006 6:16 AM
  • As to Aaron076 post ,
     I used his methode to change the delay time and had the problem of my forms coming up over the splash screen due to the setting I have to use on the forms. So what I did to over come this is to use the previous sulution post by Aaron and added the following in my start up form.

     

     

    Imports System.Threading
    
    Public Class User
            Private Sub User_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            Me.DesktopLocation = New Point(0, 0)
            Form1.TopMost = False
            Form1.Hide()
            Thread.Sleep(5000)
    end sub 
    
    end class


    Thread.sleep(5000) allows your startup form to wait 5 seconds while the splash screen is displayed. then display the startup form.


    Always Lost in Code
    Sunday, January 03, 2010 10:35 PM
  •  I used his methode to change the delay time and had the problem of my forms coming up over the splash screen due to the setting I have to use on the forms. So what I did to over come this is to use the previous sulution post by Aaron and added the following in my start up form.

    What setting was it that have used on the forms to do this cause i have the same problem of the form loading over the splash screen?

    Edit:

    I found that if i selected splashscreen1 in splashscreen1[design].vb and set the property "Top Most" to be true then this overcame the problem. Now the splash screen loads, then the form (but behind the splash screen), the splash screen displays for the 5 seconds then closes.

    • Edited by joneschrisan Tuesday, September 21, 2010 6:15 PM Found a work around
    Tuesday, September 21, 2010 6:04 PM
  • Me.MinimumSplashScreenDisplayTime = 5000
    

    Hi jonechrisan,

    I used the following to prevent this problem. I believe if I remember this is the splash screen form called user that the code is in. The form1.hide hides form1 to prevent it showing then the Thread.Sleep (5000) causes the the form1 to sleep for 5 second while the splash screen is displayed. After this you can use form1 show and continue with your application. The statement Me.MinimumSplashScreenDisplayTime = 5000 does the same thing as sleep(5000)

    Imports System.Threading
    
    Public Class User
        Private Sub User_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        Me.DesktopLocation = New Point(0, 0)
        Form1.TopMost = False
        Form1.Hide()
        Thread.Sleep(5000)
    end sub 
    
    end class
    

    Hope this helps

    Curtis


    Always Lost in Code, Always mark answers as correct if they answer you question and solve your problem. This way others when searching for similar problems can find the answer faster.
    Tuesday, September 21, 2010 6:22 PM
  • If the Form1 shows before the SplashScreen closes, Form1 is jumping out of the Load event, either because of an error or a change in WindowState.  To single-step through the Load event, comment out the Debugger statements in the Designer.  The SplashScreen should remain visible until Form1 completes the Load event.  As an example:  Start a new WF app, add a SplashScreen and set the SplashScreen on  the Project.Properties Application tab.  Add this code to Form1:

    Public Class Form1
      
    Private Sub Form1_Load(ByVal sender As ObjectByVal e As EventArgs) Handles Me.Load
        Threading.Thread.Sleep(10000)
      
    End Sub
    End
     Class

    The SplashScreen will show for 10 seconds even though the SplashScreen delay is the default 2 seconds.  Form1 won't show until the SplashScreen closes.

    Tuesday, September 21, 2010 8:04 PM