|
-
Jan 20th, 2006, 11:04 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Splash Screen Help
Hi,
How can I make a splash screen fade in, pause for a given seconds, fade out then call an application?
Actually, I have made a splash screen fade in and fade out using a sample code I got from the net but I cannot make it pause....
Last edited by phutie; Jan 21st, 2006 at 11:34 AM.
Multimedia Programmer
Uses VB.Net and MySQL
-
Jan 20th, 2006, 11:10 PM
#2
Re: Splash Screen Help
I would use a form. Remove the top bar and then use a timer to set its opacity. When it's at 100%, use the timer to wait like 5 seconds or so, then fade it back out.
-
Jan 20th, 2006, 11:15 PM
#3
Re: Splash Screen Help
You can make a form fade in and out using a Timer but, in my opinion, it is better to use the AnimateWindow API. I have made a submission in the VB.NET CodeBank (see my sig) that does just that. Using that method you can simply Start a Timer in the form's Load event handler with the desired Interval, then in the Timer's Tick event handler you would call Me.Close. It's that easy. If you want to use a Timer and the form's Opacity property to handle the fading, here's a code sample that uses a single Timer to fade in, pause, then fade out.
VB Code:
Private loaded As Boolean = False
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Opacity = 0.0
Me.Timer1.Interval = 50
Me.Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If loaded Then
'The form is being faded out.
Me.Opacity -= 0.05
Me.Timer1.Interval = 50 'In case we have just finished pausing.
If Me.Opacity <= 0.0 Then
Me.Close()
End If
Else
'The form is being faded in.
Me.Opacity += 0.05
If Me.Opacity >= 1.0 Then
Me.loaded = True
'Pause for 10 seconds.
Me.Timer1.Interval = 10000
End If
End If
End Sub
-
Jan 21st, 2006, 12:42 AM
#4
Thread Starter
Hyperactive Member
Re: Splash Screen Help
Thanks jmcilhinney! The code works great! One problem though.....
I have a form that suppose to call my splash screen. So when I use:
Dim fsplash As New frmsplash
fsplash.Show()
Me.Close() 'This closes the originating form that calls the Splash Screen
The whole program closes that it was not able to show the Splash Screen. I also tried the Me.Hide() but the form only stays on the background while displaying the splash screen....
Multimedia Programmer
Uses VB.Net and MySQL
-
Jan 21st, 2006, 01:07 AM
#5
Re: Splash Screen Help
You'll want Application.Run() then for the Splash Screen.
-
Jan 21st, 2006, 01:49 AM
#6
Thread Starter
Hyperactive Member
Re: Splash Screen Help
Application.Run() for my splash screen?
My splashscreen and the form that calls it are on the same project....can you give me a sample?
Multimedia Programmer
Uses VB.Net and MySQL
-
Jan 21st, 2006, 02:17 AM
#7
Re: Splash Screen Help
http://www.google.com/search?client=...utf-8&oe=utf-8
First hit on Google.
VB Code:
Application.Run(New Form1())
-
Jan 21st, 2006, 03:00 AM
#8
Thread Starter
Hyperactive Member
Re: Splash Screen Help
Thanks kasracer...however, when I put the code Application.Run(fsplash), the program gives an error and suggests that I use the .ShowDialog instead.
When I used the fsplash.ShowDialog, my originating form does not show anymore and the splash screen was displayed. After the splash screen fades out it will call another form. Another error is flashed telling me that I should set the form.visible to false..
I think by doing this, this will consume resources since the originating form was not unloaded....what to do?
Multimedia Programmer
Uses VB.Net and MySQL
-
Jan 21st, 2006, 03:22 AM
#9
Re: Splash Screen Help
Are you using VB.Net 2003 or 2005?
-
Jan 21st, 2006, 03:44 AM
#10
Fanatic Member
Re: Splash Screen Help
* Take a module in your form - say modMain
* Add a Sub Main into it. Set it as a startup object in your Project properties.
* Write the following code in Sub Main
VB Code:
Sub Main()
Dim frmSplash as new frmSplash
frmSplash.ShowDialog()
frmSplash.Dispose()
Application.Run(frmMain) 'Show your main form
End Sub
Hope it works
____________________________
If your problem is solved...add [RESOLVED] to the title
Dont forget to rate the post
-
Jan 21st, 2006, 03:49 AM
#11
Thread Starter
Hyperactive Member
Re: Splash Screen Help
I'm using VB.NET 2003....
Thanks pvbangera! I'll give it a try....
Multimedia Programmer
Uses VB.Net and MySQL
-
Jan 21st, 2006, 05:02 AM
#12
Re: Splash Screen Help
If you're going to use ShowDialog then there isn't a specific need to use a Main method. Just create and Show the splash screen in the Load event handler of the main form.
-
Jan 21st, 2006, 11:34 AM
#13
Thread Starter
Hyperactive Member
Re: Splash Screen Help
Ok, here's what I did....
fsplash.ShowDialog()
Me.Dispose()
And I think it works the way I wanted it to...
Thanks a lot guys! All your help is very much appreciated!
Multimedia Programmer
Uses VB.Net and MySQL
-
Jan 21st, 2006, 06:23 PM
#14
Fanatic Member
Re: [RESOLVED] Splash Screen Help
I am still waiting for my post to be rated :-w
-
Jan 21st, 2006, 10:23 PM
#15
Thread Starter
Hyperactive Member
Re: [RESOLVED] Splash Screen Help
Ok, got your post rated.....again thanks very much!!
Multimedia Programmer
Uses VB.Net and MySQL
-
Jan 21st, 2006, 11:45 PM
#16
Re: [RESOLVED] Splash Screen Help
 Originally Posted by pvbangera
I am still waiting for my post to be rated :-w 
Don't ask for ratings or the mods/admins will give you negative ratings.
Just fyi
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
|