Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

splash screen with .showdialog in startup form

Status
Not open for further replies.

SavantMan

Programmer
Apr 17, 2002
165
US
I have an application written in VB 2K5 (don't think this functionality existing back in 2K3 edition). I have a splash screen set for the project, and in the startup forms load event I check to see if the user is registered and if not show a nag form modally (via .showdialog). The problem is when I do this the splash screen never closes. I think this is because the splash screen is on a seperate thread and never gets control back to close itself because I have a modal form shown. I've tried various solutions such as placing a timer on the splash to close after a period of time etc. with no success. Any suggestions would be greatly appreciated.
 
Mind you, I don't know a lot about VB .Net yet, but maybe you should set the timer in the form that currently has the focus, or set the splash screen to close in the form that currently has the focus??

If I'm wrong about this suggestion, would someone please correct me? Thanks,



Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
Hello,

I have a simiral functionallity to a project of mine.
Solution: Do not set to have a splash form. Set the splash form to be the startup object. Check if the user is registered; if not then show the nag form (.showdialog). The code should be like :

(code in splash form load event)

Code:
dim fNag as frmNag=nothing ' the nag fomr
dim fMain as frmMain= nothing ' The main form

application.doevents()
if not (registered) then
  fNamg = New frmNag
  fNag.ShowDialog()
End if

fMain = New  frmMain
f.Show
application.doevents()

me.dispose(false)
fNag=Nothing

Hope this helps
 
First of all... forget about the ShowDialog... It's not needed. VS2005 takes care of showing it for you so long as it the Splashscreen is set in the Project Properties--Application tab.

Second, put this in place in your splashscreen's code:

Code:
    Private Sub SplashScreen1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        'If Not bAuthorized Then
        Me.Refresh()
        System.Threading.Thread.Sleep(20000)  'make thread sleep for 20 seconds
        'End If
    End Sub

Senior Software Developer
 
If you encounter problems, write the above code in 'SplashForm_Shown' event and in the load event write 'application.doevents()'
 
Seems I wasn't quite clear. The .ShowDialog is on the nag screen, and the application framework handles showing and disposing of the splash screen. What I ended up doing is in taking the splash out of the application framework and showing it from the load event of the startup form. A timer on the splash screen handles closing it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top