Introduction:
When developing heavy program under any platform you will notice that the program requires a lot of time to start. So what the programmers are doing is that they introduce a screen just before displaying the Main Form which indicates you have started the program and it is loading. So to have modern look and to indicate the user that the program is being loaded we must include Splash Screen in our programs. Designing the Splash Screen is an easy task and requires very little skill.
Designing a Splash Screens
Generally a Splash Screen includes Image/Logo that resembles your program. The Splash Screen is generally displayed on the centre of the Screen. So when you have started designing the Splash Screen. Set the properties of the Splash Screen Form as given below
frmSplashScreen.frm
Properties:
·StartUpPosition: 2 – Centre Screen
·BorderStyle: None
·ShowInTaskbar: False
Now to add a Image/Logo on the Splash Screen drag a Image Control on to the Screen. You may use a PictureBox to do the same. But the Stretching property will not be allowed in PictureBox. Here I used a Image Control and set the properties to…
Image
Properties:
·Picture: Put the path of your Logo/Image
·Stretch: True
Now add the label displaying the name of your program and your identity and assign the colors and fonts as your require. Now the main phase of designing the Splash Screen comes in.
As till now your designing part is completed. Now take the Timer Control and place it on your form. Place it anywhere on your form as it will not be displayed at run time. Decide the time for which you want the user to view your splash screen. If you will be adding a progress bar then close splash screen as soon as the entire program loading process is completed. Set the timer Interval to about 1000 seconds. At the Timer event (i.e Timer1_Timer) of your Timer add the following code which will unload the splash screen and then display the Main Form(Named as frmMain.frm).
Private Sub Timer1_Timer()
Unload Me ‘Unload the Splash Form
frmMain.Show ‘Load the Main Form
End Sub
Also don’t forget to set Splash Screen Form (frmSplashScreen.frm) as your startup form in your project properties. After you have done all with this run your program and watch the difference you get. In later section I will discuss how to add a progress bar effect on the SplashScreen. Do post comments and your designed screens.s
I am interested in how to put a progress bar up on a splash screen and how to let the splash screen know that the main form is finished loading.
it is really help full and easy to understand.
It worked well.Thanks
However, in my application the work is done as part of loading the main form so I opened the splash and after one second opened the main form followed by i=unload me
This did the job
Private Sub Timer1_Timer()
frmMain.Show
Unload Me
End Sub
Now I woiuld like the code for progress bar effect on the SplashScreen
Yes, it works..however I am interested in using a progress bar dynamically showing the status of progress!
it’s superb….Thanx. I think microsoft should learn….how to put articles on websites…….
Of Great Help!…Thanxs. The way it was explained was superb.
Thanks for appreciating my work….
Ok I use Visual Studio 2005. I’m not sure how to move the splash screen in the code but you can do it in the poperties box.
Thanks
The way of you coding is very nice.however I am interested in using a progress bar.howing the status of progress!
Hello
I am a student studing programming and would like to know how to animate buttons when a mouse is brought over it.
animatio like constant colour changing, changing the shape of the button e.t.c
please assist me as this is a project i am working on and am really stranded with such code.
thank you.
Very nice indeed,
I’m looking just like “Adult visuals” for a way to make the position of the splash screen relative as I don’t want it to be at the center of the monitor, settings things to “Manual” wouldn’t help much because if users have got different resolutions, the splash may not be visible at all
OK, I think I found it,
More info: http://vbcity.com/forums/topic.asp?tid=3486
Yow this Bazzel Thanx, I really appreciate it
its works …………….
thanks a lot………
How one can know the actual time the main form would take to load?And show the actual progress throught progress bar.
Very good and simple to understand. Thank you for explication.
Hi,
its working perfect. i was reading the article before but tried it now step by step and its great. thank you for the great guidance!
regards,
james
Thanks it worked well. Will be very helpful if u can specifytutorial for VB to database communication that is taking data from database and sending data to database.
Good work…..very easy to understant…Thank’s a lot
i have spalsh screen created & in timer event i have put code:
splashscreen.hide
form1.show
timer event has set time to 1sec.
now the form1 is displayed in interval of every 1 second
what should i do??
Please append the following code to your rimer code…
timer.enabled=false;
This line while disable the timer and thus your splash screen won’t show up again and again after every 1sec…
tc…
I need to know, what is the code for progress bar in Visual Basic 6.0?
thankyou the code was helpful so lets see about the progress bar!!!
Very very helpful. pleas help for progress bar
very very helpful
very helpful
very much helpful… when can i get the progress bar bit here???
Ok.. I think i should carry forward the flag now.. as there are many people waiting for the progress bar set up. i know this is not one of the best code but at least does the job.
I will start by explaining where to find the progress bar from.
In the Vb6 IDE, click Project -> components. Now look for, Microsoft Windows Common Controls 6.0 (SP6). This should add the progress bar button in the General Tab.
Can you find it yet? If not then try looking for other Microsoft Windows Common Controls, for example Microsoft Windows Common Controls-2(SP6). Or (SP5)
Ahaann, I guess you have added it successfully…
Now, put it on the splash screen described by Sandeep (at the beginning of this blog)
I have added a LABEL on the form called label2. This label will let the user know about what is actually happening in the background. This gives a better feel.
Oh yeah, don’t forget to set the interval of the TIMER CONTROL to 1. I know it’s a short delay, but once you get to the code part of this blog, you will realize why I m doing that.
Next, I declared a variable ‘aa’, the value of which will be embedded in the progress bar’s meter. (Don’t get confused yet, I will explain it soon)
So in the code, declare a global variable
Public aa As Integer
And in the form_load event, I initialized the value of this variable.
Aa = 0
Now,
In the timer1_timer(), add the following code (Depending on the type of work you are doing)
Private Sub Timer1_Timer()
‘ To give the user a feel that the system is working now..
Screen.MousePointer = 13
‘Generate Random Numbers, so that every time you run this page, the progress bar ‘doesn’t process the same. That’s the reason, why timer control’s interval was set to 1.
aa = aa + (Math.Rnd(1000) Mod 5)
‘now set the progress bar’s value
progressbar1.Value = aa
‘Once the progress bar reaches half way, start to establish a connection with the database, ‘and while its been done, notify the user that an attempt is being made
If progressbar1.Value = 50 Then
Label2.Caption = “Establishing Database Connection…”
‘Here I am trying to open the database connection, CON is the connection string
‘declare it too. Public con As New ADODB.Connection
If con.State = 1 Then con.Close
‘Change these settings depending on your server configurations
con.Open “Driver={SQL Server};Server=fileserver\finos53;Database=asytm;Uid=myuser;Pwd=mypassword;Language=British”
ElseIf progressbar1.Value = 80 Then
Screen.MousePointer = 13
Label2.Caption = “Opening Application…”
ElseIf progressbar1.Value = 100 Then
mainform.Show
Unload Me
Screen.MousePointer = 0
End If
End Sub
YOU ARE DONE NOW… RUN IT… and hey… like I said, I know its not the best approach, but for the time being, and the User-level I assume you have, it’s a better off.
For more advance features, tips & tricks and troubleshooting, you can email me anytime on athar_anis@nrlpak.com.