user1707916
user1707916

Reputation: 31

How to set 5 second timing of a splash screen in VB.NET

I have used this code to set 5 second time of my vb.net's project's splash screen.

Imports System.Collections.ObjectModel
Namespace My

    Partial Friend Class MyApplication
        Protected Overrides Function OnInitialize(ByVal commandLineArgs As ReadOnlyCollection(Of String)) As Boolean
            Me.MinimumSplashScreenDisplayTime = 5000
            Return MyBase.OnInitialize(commandLineArgs)
        End Function
    End Class

End Namespace

This code is fully working but as my project takes no time to load so as soon the splashscreen is getting loaded the 1st form is also getting loaded, and it is hiding the splash screen.

I want that the 1st form will load after the splash screen gets closed. Can any one help me out in this?

Upvotes: 3

Views: 16279

Answers (1)

tHand
tHand

Reputation: 301

You could try setting your application to use a 'Sub Main' as its startup object rather then either form. In the 'Sub Main' you can show your splash screen as a modaless form while you do your initialization, then hide it when you you are ready to show your main form. Something like:

Sub Main

    Dim slash as new SpashScreenForm
    slash.Show()

    <do the initialization for several seconds>

    slash.Hide()

    Dim mainForm as new TheMainForm
    mainForm.ShowDialow()

 End Sub

You may need to throw in a few Application.DoEvents() calls to get the splash screen to refresh.

Upvotes: 1

Related Questions