|
-
Apr 4th, 2005, 06:26 PM
#1
Thread Starter
Fanatic Member
Re: Splash Screen
That doesn’t quite do what I am looking for though as the load method is called after all of the dll's have been loaded and all of the form layout code has been hashed through.
This is the part that takes the time, not any routine that I have of my own.
That's why I was trying to do it with a separate thread in the startup sub so that the splash screen gets launched before any other code is executed, thus spanning the bridge in time between user double clicking on the program and the application actually loading.
Thanks.
In life you can be sure of only two things... death and taxes. I'll take death.
-
Apr 19th, 2005, 06:22 PM
#2
Thread Starter
Fanatic Member
Re: Splash Screen {UNRESOLVED}
Hate to do this but still no luck with this. Does anybody have any idea how to create a splash screen simlar to Microsoft Outlook or Adobe Reader...?
It needs to load first before any other code is executed or parsed.
Thanks.
In life you can be sure of only two things... death and taxes. I'll take death.
-
Apr 19th, 2005, 07:39 PM
#3
Re: Splash Screen
Try this instead:
In your "Splash Screen" Form Add the Following:
VB Code:
Private Shared _SplashScreen As frmSplashScreen
Public Shared Sub ShowSplashScreen()
If Not _SplashScreen Is Nothing Then
CloseSplashScreen()
End If
_SplashScreen = New frmSplashScreen
_SplashScreen.Show()
End Sub
Public Shared Sub CloseSplashScreen()
If Not _SplashScreen Is Nothing Then
Try
_SplashScreen.Close()
_SplashScreen = Nothing
Catch
End Try
End If
End Sub
Assuming your splash screen form is called frmSplashScreen you'd make
your startup object Sub Main which would be in a module:
VB Code:
Module modStartup
Sub Main()
frmSplashScreen.ShowSplashScreen()
Application.Run(New Form1) ' Where "Form1" is the main form that takes a while.
End Sub
End Module
To close the SplashScreen, do so in at the end of the main form's
Load event, i.e.
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i As Integer = 1 To 5000
' Simulate a load delay
Console.WriteLine(i)
Next
frmSplashScreen.CloseSplashScreen()
End Sub
Regards,
- Aaron.
-
Apr 20th, 2005, 12:43 PM
#4
Thread Starter
Fanatic Member
Re: Splash Screen
Aaron,
Ok great, I had to make some changes but was able to get it to work. Your example worked except that the SplashForm would not show any controls just white space where the controls should have been. I was able to get around this by using ShowDialog instead of Show in the ShowSplashScreen sub.
This though introduced a new problem, code execution stopped in the StartUp sub. To get around this I started a new thread:
VB Code:
SplashScreenThread = New System.Threading.Thread(AddressOf SplashScreen.ShowSplashScreen)
SplashScreenThread.Start()
This works great and accomplished just what I needed.
Thank you for your help!!!

**Edit**
If you use this you will also need to bring to front the main form after the SplashScreen form closes.
VB Code:
Private Sub SplashScreen_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
MainForm.BringToFront()
End Sub
Last edited by cpatzer; Apr 20th, 2005 at 12:46 PM.
In life you can be sure of only two things... death and taxes. I'll take death.
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
|