-
Nov 22nd, 2016, 06:27 AM
#1
Thread Starter
Junior Member
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
-
Dec 13th, 2016, 11:03 AM
#2
Lively Member
Re: Startup Form shows same time as Splash Screen
Originally Posted by sgell
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:
System.Threading.Thread.Sleep(2000)
inside FormLoad
-
Dec 13th, 2016, 07:52 PM
#3
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.
-
Dec 14th, 2016, 05:31 AM
#4
Thread Starter
Junior Member
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
-
Dec 14th, 2016, 05:47 AM
#5
Lively Member
Re: Startup Form shows same time as Splash Screen
Originally Posted by sgell
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
-
Dec 14th, 2016, 06:05 AM
#6
Lively Member
Re: Startup Form shows same time as Splash Screen
Originally Posted by sgell
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:
If Form1.Visible = True Then Me.Visible = False Else Me.Visible = True End If
and, paste this coding in Form1 coding inside Form1_Load column ::
Vb.net Code:
SplashScreen1.Visible = True System.Threading.Thread.Sleep(2000) If SplashScreen1.Visible = True Then SplashScreen1.Visible = False 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
-
Dec 14th, 2016, 07:39 AM
#7
Re: Startup Form shows same time as Splash Screen
Originally Posted by sgell
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:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim frmSplash As frmSplash = Nothing Dim t As New System.Threading.Thread(Sub() frmSplash = New frmSplash frmSplash.ShowDialog() End Sub) t.Start() Dim st = Now 'Do stuff here 'make sure the spash screen shows for 2 seconds System.Threading.Thread.Sleep(Math.Max(0, 2000 - CInt(Now.Subtract(st).TotalMilliseconds))) Dim DisposeSplash = Sub() frmSplash.Dispose() SyncLock frmSplash If frmSplash.IsHandleCreated Then frmSplash.BeginInvoke(DisposeSplash) Else DisposeSplash() End SyncLock 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
Last edited by i00; Dec 14th, 2016 at 07:46 AM.
-
Dec 14th, 2016, 08:49 AM
#8
Thread Starter
Junior Member
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
-
Dec 14th, 2016, 09:43 AM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|