Results 1 to 5 of 5

Thread: ShowDialog in Splash Form

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    135

    ShowDialog in Splash Form

    Hello There,

    i have form1 and form splash..i used the splash as processing indicator i place gif in the splash form...and in form1 i call the splash in separate thread..

    like this..
    Code:
      Dim splashthread As Thread = New Thread(New ThreadStart(AddressOf SplashScreen.ShowSplashScreen))
            splashthread.IsBackground = True
            splashthread.Start()
    SplashScreen is another class and had a shared sub ShowSplashScreen()

    here:
    Code:
    Public Shared Sub ShowSplashScreen()
                If sf Is Nothing Then
                    sf = New SplashForm
                    sf.ShowSplashScreen()
                End If
            End Sub
    ShowSplashScreen() Method is the actual splash Form class

    here it is.
    Code:
    Public Sub ShowSplashScreen()
            If InvokeRequired Then
                ' We're not in the UI thread, so we need to call BeginInvoke
                BeginInvoke(New SplashShowCloseDelegate(AddressOf ShowSplashScreen))
                Return
            End If
            Me.ShowDialog()
            Application.Run(Me)
        End Sub
    now,my problem is when form1 is loaded and click button process in it..the splash form will not display modally...is it because i called the splash in separate thread?..

    please give some advice on this..thank you..

  2. #2
    Addicted Member
    Join Date
    Mar 2007
    Posts
    163

    Re: ShowDialog in Splash Form

    is it because i called the splash in separate thread?..
    I believe so...

    I am not sure if this will work but you can always try ...
    How about running the "processing" stuff in their own thread and then just displaying your splash screen modally to take control over from your main form...

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

    Re: ShowDialog in Splash Form

    You shouldn't be displaying the splash screen manually from Form1. Splash screen functionality is built into VB. On the Application page of the project properties there are two drop-downs: one for the Startup Form and one for the Splash Screen. It should be fairly obvious what gets selected in each.

    If you want to communicate with the splash screen at any stage, you do so using the My.Application.SplashScreen property. It returns a Form reference, because it could be any form. Also, the splash screen is created on a secondary thread, specifically so that the main form can keep loading while it's displayed. With that in mind, here's how you might call a method that you added to the splash screen class to update a ProgressBar:
    vb.net Code:
    1. Dim splashScreen = DirectCast(My.Application.SplashScreen, MySplashScreenForm)
    2.  
    3. splashScreen.BeginInvoke(New Action(Of Integer)(AddressOf splashScreen.SetProgress), 50)

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    135

    Re: ShowDialog in Splash Form

    Thank you for all your replies..sorry for the confuse of names..im not really using splash like built into VB..

    im using a borderless windows form and i place a gif image on it..whenever i run any long process..i called that form to present to the user knowing that there is something processed and they need to wait..

    can i do all this in simply displaying a second form that had gif image on it..if so,how the second form know that the processing is done in my main form and it needs to be disposed?..

  5. #5
    Addicted Member
    Join Date
    Mar 2007
    Posts
    163

    Re: ShowDialog in Splash Form

    I am not sure I understand what you mean here:
    can i do all this in simply displaying a second form that had gif image on it..if so,how the second form know that the processing is done in my main form and it needs to be disposed?..
    If you display a second form modally from the same thread then your code that comes after the showDialog will wait until the dialog is closed before it executes ...

    Do you have to do this with a "Splash Form"? You can always disable the controls on your form for the duration of the execution and then enable them again...

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