Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Splash screens

Status
Not open for further replies.

stealth998

Programmer
Apr 12, 2006
4
US
I'm somewhat new to VB.net. I've coded a splash screen and it runs fine, but I'd like to know if there's any way I can hide the main form while the splash screen is going. Any help would be appreciated!
 
There's two ways you can do that. Each depends on your personal preference and application needs.

1) Load the splash screen first. Then put a timer on it and load the main from from it.

2) Use Me.Hide before calling the splash screen. This is kinda clunky and the user will see the main form come up then disappear.
 
Here's another possiblity: Start the app from a module. Launch the slash screen in another thread. create a new main form object. Set the for object's visibility to false. Load the main form. Display the main form. unload the splash screen.

It's been a while since I've worked with our base splash screen, but I think it gets launched from the constructor of the main form. The main form is not visible until it is finished loading or the splash timer elapses (which ever is longer). I remember it being a pain in the hiney to get everything to work right, because if you launch a modal form and set it's visibility to false the app will consider it closed and return the execution to the calling method.

-rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Okay, here's the thing. I tried using me.hide before calling the splash screen but the main form still shows, doesn't disappear at all. Really hinky, can't figure it out. I'm trying out the other options right now, we'll see how it goes. Thanks for the tips!
 
I usually start the app from a Sub Main in a module, then create a new instance of the Main Form (not showing it yet). Then I show the Splash Form, which calls the Main Form's loading methods and then closes. Because the Splash Form is shown as a dialog, the code in Sub Main will continue only after the Splash screen has closed; from there I make the Main Form visible.

Example from the top of my head:

Code:
Public Module Module1
  Friend MF As MainForm

  Sub Main()
    MF = New MainForm()
    Dim SF As New SplashForm
    SF.ShowDialog()
    MF.ShowDialog()
  End Sub
End Module

MF.Showdialog will not be executed until SF has closed first. Since MF is defined here as a global friend variable, it is accessible from within the SF form and because I instantiated it before showing the SF form, it's methods can be called to load data, etc.

The SF form could thus have code like the following in it's Load event:

Code:
MF.LoadClients()
MF.LoadMoreData()
MF.DrawSomeThings()
Me.Dispose()

Even better would be to include error handling and return accordingly, so you can check wether the Main Form could be properly initialized or not. You should however not forget to Dispose of the Splash screen to free the memory.

Regards, Ruffnekk
---
Basic Instructions Before Leaving Earth (B.I.B.L.E.)
 
Thanks, I will try that! Will post if/when I get it working.
 
Adding the module to control the splash screen did the trick, it's working great now! Thanks for the help guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top