Results 1 to 11 of 11

Thread: Splash Form

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474

    Splash Form

    How can I show a splash form while my application loads? You know, I want it to be shown right after the running of program not as the first form of the program.

  2. #2
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    Dublin, Ireland
    Posts
    262
    I definately think that opacity is the best solution for this. In the form load event of your main form put this:-

    VB Code:
    1. Me.Opacity = 0
    2. Dim frmSplash As New splash()
    3. frmSplash.Show()
    4. 'put initializing code here or a delay of some kind
    5. frmSplash.Close()
    6. Me.Opacity = 1
    7. Me.Show()

    then in the splash form's load event put this:-

    Me.Show()
    Me.Refresh() 'if you have any buttons or progress bars the refresh is needed.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Thanks for your help, but i guess I couldnt convey exactly what i mean. You know usually on slow machines it takes a considerable time for a large application to load and run. I want the splash form to be shown in this period of time, but your code provieds a way of showing a splash form after the main form is loaded.

  4. #4
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    Dublin, Ireland
    Posts
    262
    Yes it does - I have indicated where you should place any code that has to run procedures that will take some time.
    You have to load your main form first. This is the way .net apps work.
    If you place any intensive code where I suggest then the splash should be visible while you do this code.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Maybe I am dumb, but i think there is no such type in .NET called 'splash', so maybe you mean 'New form()'

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Thanks,

    I used following code and it works fine. I put the code before and after initialization of form components.

    Public Sub New()
    MyBase.New()
    Me.Opacity = 0
    Dim frmsplash As New Form2()
    frmsplash.Show()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    frmsplash.Close()
    Me.Opacity = 1
    'Add any initialization after the InitializeComponent() call

    End Sub

    Do you think its a proper place to put the code?

  7. #7
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Where are you actually having the slow loading comming from? What I mean by that is there is two ways your forms can be slow loading.

    The first way, is right after you compile (build) your app to MSIL, the JIT compiler will then need to convert your app from MSIL to binary. This should only be the first time it is ran though. If you run it again after the first time, without rebuilding the solution, it should start up much faster.

    The second way it can be slow, is if you have a form with a lot of controls on it. Assuming this is the second time you ran the app, not from the IDE, from the bin directory by double clicking the exe, and it is taking a while, then I would go with the above code posted by Lunatic3.

  8. #8
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    Dublin, Ireland
    Posts
    262
    Sorry Splash() is just the name of the form I gave my splash form. I may be fussy but I like to call my forms by names that indicate what they are.

  9. #9
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    
            Me.Opacity += 0.1
            If Me.Opacity = 1 Then
                Button1.Visible = True
            End If
    
        End Sub
    another way !Hope you like it
    Attached Files Attached Files

  10. #10
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    Dublin, Ireland
    Posts
    262
    You might want to disable the timer when opacity gets to 1 too.

  11. #11
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    exactly what I thought . thanx for that .


    Code:
    code
    
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    
            Me.Opacity += 0.1
            If Me.Opacity = 1 Then
                Button1.Visible = True
                Timer1.enabled = False
            End If
    
        End Sub

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