Results 1 to 8 of 8

Thread: Splash Screen [RESOLVED]

Hybrid View

  1. #1

    Thread Starter
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537

    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.

  2. #2

    Thread Starter
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537

    Unhappy 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.

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Re: Splash Screen

    Try this instead:

    In your "Splash Screen" Form Add the Following:
    VB Code:
    1. Private Shared _SplashScreen As frmSplashScreen
    2.  
    3.    Public Shared Sub ShowSplashScreen()
    4.       If Not _SplashScreen Is Nothing Then
    5.          CloseSplashScreen()
    6.       End If
    7.  
    8.       _SplashScreen = New frmSplashScreen
    9.       _SplashScreen.Show()
    10.    End Sub
    11.  
    12.    Public Shared Sub CloseSplashScreen()
    13.       If Not _SplashScreen Is Nothing Then
    14.          Try
    15.             _SplashScreen.Close()
    16.             _SplashScreen = Nothing
    17.          Catch
    18.  
    19.          End Try
    20.       End If
    21.    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:
    1. Module modStartup
    2.    Sub Main()
    3.       frmSplashScreen.ShowSplashScreen()
    4.       Application.Run(New Form1) ' Where "Form1" is the main form that takes a while.
    5.    End Sub
    6. End Module
    To close the SplashScreen, do so in at the end of the main form's
    Load event, i.e.
    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.       For i As Integer = 1 To 5000
    3.          ' Simulate a load delay
    4.          Console.WriteLine(i)
    5.       Next
    6.       frmSplashScreen.CloseSplashScreen()
    7.    End Sub
    Regards,

    - Aaron.

  4. #4

    Thread Starter
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537

    Resolved 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:
    1. SplashScreenThread = New System.Threading.Thread(AddressOf SplashScreen.ShowSplashScreen)
    2.             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:
    1. Private Sub SplashScreen_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
    2.         MainForm.BringToFront()
    3.     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
  •  



Click Here to Expand Forum to Full Width