lidds Posted July 26, 2005 Posted July 26, 2005 I know this subject has been asked lots of times on this forum, but I have a slightly different situation and need a bit of guidance (as always :p) I have an application that when loaded, opens up a login form that just loads connection settings and checks connection to the database. The form obviously loads quickly. This login form allows the user to load two different forms depending on the selection of a combobox, either "Main App" or "Admin App". Now the problem is that both these forms "Main App" and "Admin App" take awhile to load. The way that I can see to get around this is to: 1) Load splash screen 2) somehow load login form (not visible) 3) somehow load "Main App" form (not visible) 4) somehow load "Admin App" form (not visible) 5) close splash screen 6) show login form then when the user logs in the forms should load quickly. The problem is, that I am unsure whether this is the best way to do this??? or how to go about doing this in vb.net. Thanks Simon Quote
rot13 Posted July 26, 2005 Posted July 26, 2005 (edited) That will just move the time it takes to load the forms from after login, to before login. I would set the login form as the startup form, when the application runs, it quickly pops up and the user logs in... then, it decides what form to load, and loads it... in both of the other forms, you show a splash screen on load so that there is a splash screen between login and when the form is done loading. If you load both while splash screen is up, then let them login... it will take more time than necesarry because you are loading a form that you don't need to... The code would look like this: Public Class frmLogin Public Sub bttnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bttnLogin.Click Dim frmToLoad As Form If cmboUsers.text = Whatever.for.admin Then frmToLoad = New frmAdmin else frmToLoad = New frmMain End If frmToLoad.Show End Sub End Class Public Class frmWhicheverIsLoading Public Sub frmWhicheverIsLoading_Load(blah blah) Handles MyBase.Load Me.Visible = False Dim fSplash As New frmSplash fSplash.Show Application.DoEvents() 'All the stuff you need to do in here fSplash.Close Me.Visible = True End Sub End Class That's off the top of my head... might not all be perfect... but you get the idea Hope that helps... Edited July 26, 2005 by rot13 Quote
lidds Posted July 26, 2005 Author Posted July 26, 2005 rot13, At the moment I am doing it exsacually the way that you said, login form startup form, and then loads the relavent form depending on selection. Did think about what you suggested of showing splash screen after login form, suppose I'm just thinking about the way other software displays there splash screen (normally right at the beginning). I think I am going to need a splash screen before the login form, because if my app can't connect to the database (changed on purpose for testing) then it hangs for awhile (waiting for server response) before it displays an error message, the user does not know what is going on. Therefore would notify the user on the splash screen that the app is trying to connect to the database. However I can't display a splash screen just for the login as it would just flash up and close. Hope that made sense, not to sure the way to go with this one..... Suggestions anyone.... Thanks Simon Also thanks for the code snippet will give that a go... Quote
rot13 Posted July 26, 2005 Posted July 26, 2005 Splash screen after the login form is fine... As far as the login form hanging... maybe you can connect in another thread or something and if they try to login while it isn't connected yet, just let them know that it's still trying to connect, but if it is connected by time they type in their information (most likely it will connect, or reject connection before they type in their information) then they will never know the difference... Quote
lidds Posted July 26, 2005 Author Posted July 26, 2005 Thanks rot13, Have given me another way forward. Think I will try what you suggested, but just disable the login button, and add a statusbar to the login form to notify them if it is connected or not connected to the database. When it connects activate the login button. Got a couple more questions on the .NET general forum if you fancy the task.... Thanks for your help Simon Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.