Results 1 to 9 of 9

Thread: Startup Form shows same time as Splash Screen

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2014
    Posts
    24

    Startup Form shows same time as Splash Screen

    Application Properties
    Startup Form is Menu.frm which is an MDI Form.
    Splash is SplashScreen1.
    Code in Application Events is:
    Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
    Me.MinimumSplashScreenDisplayTime = 2000
    Return MyBase.OnInitialize(commandLineArgs)
    End Function

    When I run the project the MDI form shows with the Splash Screen.
    After 2 seconds the Splash Screen disappears

    I would like just to see the Splash Screen and then after 2 seconds the MDI Form.

    Thanks
    Stephen

  2. #2
    Lively Member darkbb's Avatar
    Join Date
    Jan 2016
    Posts
    91

    Re: Startup Form shows same time as Splash Screen

    Quote Originally Posted by sgell View Post
    Application Properties
    Startup Form is Menu.frm which is an MDI Form.
    Splash is SplashScreen1.
    Code in Application Events is:
    Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
    Me.MinimumSplashScreenDisplayTime = 2000
    Return MyBase.OnInitialize(commandLineArgs)
    End Function

    When I run the project the MDI form shows with the Splash Screen.
    After 2 seconds the Splash Screen disappears

    I would like just to see the Splash Screen and then after 2 seconds the MDI Form.

    Thanks
    Stephen
    U can use
    Vb.net Code:
    1. System.Threading.Thread.Sleep(2000)
    inside FormLoad

  3. #3
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    Re: Startup Form shows same time as Splash Screen

    You can either use Post#2 or you can use a timer control and time a progress bar or something similar. Undesired consequences occur when you delay the start up form sometimes though - and I even had mine not to work before (the progressbar)

    A background worker can also count and when it reaches 100 you can then show the form -

    Its really just for looks - If you need a initilization then you will have to do more than just this.

    Good luck!
    Disclaimer: When code is given for example - it is merely a example.




    Unless said otherwise indicated - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Feb 2014
    Posts
    24

    Re: Startup Form shows same time as Splash Screen

    Added System.Threading.Thread.Sleep(2000) to the Load event of the Startup form and it just delays the form completing the load.
    The splash screen still shows at the same time as the start up form.

    When I start Visual Studio the splash screen displays over my desktop and then a few seconds later the program starts - this is what I would like to achieve.

    Stephen

  5. #5
    Lively Member darkbb's Avatar
    Join Date
    Jan 2016
    Posts
    91

    Re: Startup Form shows same time as Splash Screen

    Quote Originally Posted by sgell View Post
    Added System.Threading.Thread.Sleep(2000) to the Load event of the Startup form and it just delays the form completing the load.
    The splash screen still shows at the same time as the start up form.

    When I start Visual Studio the splash screen displays over my desktop and then a few seconds later the program starts - this is what I would like to achieve.

    Stephen
    If u really concern about splash screen timing & 2sec delay & WindowsForm show after closing Splash screen... U could always set the form1's FormBorderStyle to None & design the splash on form1 & use form2 for ur program... U could use Timer & progressbar to delay/show as you like...

    Please see this Tutorial :
    How to make a Splash Screen in Visual Basic 2010

  6. #6
    Lively Member darkbb's Avatar
    Join Date
    Jan 2016
    Posts
    91

    Re: Startup Form shows same time as Splash Screen

    Quote Originally Posted by sgell View Post
    Added System.Threading.Thread.Sleep(2000) to the Load event of the Startup form and it just delays the form completing the load.
    The splash screen still shows at the same time as the start up form.

    When I start Visual Studio the splash screen displays over my desktop and then a few seconds later the program starts - this is what I would like to achieve.

    Stephen
    OR

    U can do like this... go to Splashscreen Coding window paste the following code in the SplashScreen1_Load column :

    Vb.net Code:
    1. If Form1.Visible = True Then
    2. Me.Visible = False
    3. Else
    4. Me.Visible = True
    5. End If

    and, paste this coding in Form1 coding inside Form1_Load column ::

    Vb.net Code:
    1. SplashScreen1.Visible = True
    2. System.Threading.Thread.Sleep(2000)
    3. If SplashScreen1.Visible = True Then
    4. SplashScreen1.Visible = False
    5. End If

    and, please, tell which trick worked for U..? #5 Solution or #6 Solution...?!?!
    Last edited by darkbb; Dec 14th, 2016 at 06:08 AM. Reason: *missed some comment

  7. #7
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Startup Form shows same time as Splash Screen

    Quote Originally Posted by sgell View Post
    Application Properties
    Startup Form is Menu.frm which is an MDI Form.
    Splash is SplashScreen1.
    Code in Application Events is:
    Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
    Me.MinimumSplashScreenDisplayTime = 2000
    Return MyBase.OnInitialize(commandLineArgs)
    End Function

    When I run the project the MDI form shows with the Splash Screen.
    After 2 seconds the Splash Screen disappears

    I would like just to see the Splash Screen and then after 2 seconds the MDI Form.

    Thanks
    Stephen
    You mean don't show the mdi while the splash screen is showing?

    I propose this instead of what is suggested here:

    vb.net Code:
    1. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    2.     Dim frmSplash As frmSplash = Nothing
    3.     Dim t As New System.Threading.Thread(Sub()
    4.                                              frmSplash = New frmSplash
    5.                                              frmSplash.ShowDialog()
    6.                                          End Sub)
    7.     t.Start()
    8.     Dim st = Now
    9.  
    10.     'Do stuff here
    11.  
    12.     'make sure the spash screen shows for 2 seconds
    13.     System.Threading.Thread.Sleep(Math.Max(0, 2000 - CInt(Now.Subtract(st).TotalMilliseconds)))
    14.  
    15.     Dim DisposeSplash = Sub() frmSplash.Dispose()
    16.     SyncLock frmSplash
    17.         If frmSplash.IsHandleCreated Then frmSplash.BeginInvoke(DisposeSplash) Else DisposeSplash()
    18.     End SyncLock
    19. End Sub

    I am assuming that you splash screen is not close-able here btw... if you can close it you will have to wait for the 2 seconds for the interface to appear ... let me know if you want to do something else if this happens ... such as show the interface when loaded if the splash is closed.

    This has a few advantages as it is threaded so if your app takes 1.5 seconds to load it will load in the background as your splash is showing... so that your splash screen will still be shown for 2 seconds.
    Also if your app takes longer on some pc to load than 2 seconds ... lets say 4, the splash will show for 4 seconds instead to cover the loading time.

    Kris

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Feb 2014
    Posts
    24

    Re: Startup Form shows same time as Splash Screen

    Thanks for all your suggestions but they all seem rather complex.
    I have now solved my problem by creating a normal form as start up form.
    Adding a timer to show it for 2 seconds then loading my MDI form.
    Stephen

  9. #9
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,191

    Re: Startup Form shows same time as Splash Screen

    I'll add my solution as a different take on it which you could modify for your needs if you're really set on a 2 second showing. Note that I create my own Splash form rather than using the canned one VS offers.

    In my splash form's Load I do pretty much all the initializing for the program and report progress as needed. The last thing is to call my main form.
    Code:
                Dim Main As New frmMain
                If Main.Initialize Then
                    Me.Hide()
                    Main.ShowDialog()
                End If
    The last thing I do in the main form's Initialize function is set Opacity to 100, thus making it "visible". I do this since there are some things you can't do with controls when a Form's Visible property is False. Opacity = 0 (set at design time) effectively hides the form. So once everything is fully initialized, my main form "appears" and splash is hidden.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width