Results 1 to 16 of 16

Thread: [RESOLVED] Splash Screen Help

  1. #1

    Thread Starter
    Hyperactive Member phutie's Avatar
    Join Date
    Jan 2002
    Location
    Somewhere in Asia
    Posts
    295

    [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

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    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.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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:
    1. Private loaded As Boolean = False
    2.  
    3.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         Me.Opacity = 0.0
    5.         Me.Timer1.Interval = 50
    6.         Me.Timer1.Start()
    7.     End Sub
    8.  
    9.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    10.         If loaded Then
    11.             'The form is being faded out.
    12.             Me.Opacity -= 0.05
    13.  
    14.             Me.Timer1.Interval = 50 'In case we have just finished pausing.
    15.  
    16.             If Me.Opacity <= 0.0 Then
    17.                 Me.Close()
    18.             End If
    19.         Else
    20.             'The form is being faded in.
    21.             Me.Opacity += 0.05
    22.  
    23.             If Me.Opacity >= 1.0 Then
    24.                 Me.loaded = True
    25.  
    26.                 'Pause for 10 seconds.
    27.                 Me.Timer1.Interval = 10000
    28.             End If
    29.         End If
    30.     End Sub
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Hyperactive Member phutie's Avatar
    Join Date
    Jan 2002
    Location
    Somewhere in Asia
    Posts
    295

    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

  5. #5
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Splash Screen Help

    You'll want Application.Run() then for the Splash Screen.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  6. #6

    Thread Starter
    Hyperactive Member phutie's Avatar
    Join Date
    Jan 2002
    Location
    Somewhere in Asia
    Posts
    295

    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

  7. #7
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Splash Screen Help

    http://www.google.com/search?client=...utf-8&oe=utf-8

    First hit on Google.
    VB Code:
    1. Application.Run(New Form1())
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  8. #8

    Thread Starter
    Hyperactive Member phutie's Avatar
    Join Date
    Jan 2002
    Location
    Somewhere in Asia
    Posts
    295

    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

  9. #9
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Splash Screen Help

    Are you using VB.Net 2003 or 2005?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  10. #10
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    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:
    1. Sub Main()
    2.   Dim frmSplash as new frmSplash
    3.   frmSplash.ShowDialog()
    4.   frmSplash.Dispose()
    5.   Application.Run(frmMain) 'Show your main form
    6. End Sub

    Hope it works
    ____________________________
    If your problem is solved...add [RESOLVED] to the title
    Dont forget to rate the post

  11. #11

    Thread Starter
    Hyperactive Member phutie's Avatar
    Join Date
    Jan 2002
    Location
    Somewhere in Asia
    Posts
    295

    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

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  13. #13

    Thread Starter
    Hyperactive Member phutie's Avatar
    Join Date
    Jan 2002
    Location
    Somewhere in Asia
    Posts
    295

    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

  14. #14
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    Re: [RESOLVED] Splash Screen Help

    I am still waiting for my post to be rated :-w

  15. #15

    Thread Starter
    Hyperactive Member phutie's Avatar
    Join Date
    Jan 2002
    Location
    Somewhere in Asia
    Posts
    295

    Re: [RESOLVED] Splash Screen Help

    Ok, got your post rated.....again thanks very much!!
    Multimedia Programmer
    Uses VB.Net and MySQL

  16. #16
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [RESOLVED] Splash Screen Help

    Quote 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
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

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