Displaying progress bar

sudhanshu22

Member
Joined
Nov 8, 2006
Messages
20
Programming Experience
Beginner
Hi all,
I would like to display an infinite message progress bar on desktop till some form comes up. After the form appears I would like to close that progress bar.
How can I do so ?
 

LeonR

Well-known member
Joined
Nov 2, 2006
Messages
139
Location
UK
Programming Experience
10+
You mean you want to have a progess bar increment in value forever until a form loads?

Sorry im a little confused , could you please explain what its for? Im being thick today, lol

A progess bar needs a maximum value/limit, so that when you set its current value, it knows what % of the bar to highlight.

If its infinite, then the value wont ever make the bar highlight?

At a guess you are trying to make some kind if loading bar for a form?
 

sudhanshu22

Member
Joined
Nov 8, 2006
Messages
20
Programming Experience
Beginner
Hi all,
Thanks for the reply.
I got what I wanted to achieve. What I did was create a new form inside a function. The form contains a continuously looping progressbar. Now i called this function inside a new thread.

I start the thread before calling the show() of main form. Once the main form is displayed, I abort() that thread.
Now I have a problem that after I call the abort(), the main form gets minimized. I mean it stays on the taskbar and not on the screen.
Why does it happen ?
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,726
Location
Sydney, Australia
Programming Experience
10+
You're going about this the wrong way. Add a form to your project and add a ProgressBar to that form. Set the ProgressBar's Style property to Marquee. There's your infinite progress bar. Now go to the Application tab of the project properties and select that form as the Splash Screen for the app. Now all you have to do is close the splash screen when the main form is displayed. If you want the splash screen to disappear just before the main form appears then do it last thing in the Load event handler. If you want the main form to appear before the splash screen disappears then do it first thing in the Shown event handler. Either way use this code:
VB.NET:
My.Application.SplashScreen.Invoke(New MethodInvoker(AddressOf My.Application.SplashScreen.Close))
That may look odd but the splash screen is created on a different thread to allow the main form to be constructed at the same time. For that reason you have to use a delegate to call its Close method.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,726
Location
Sydney, Australia
Programming Experience
10+
Actually, I'm getting myself confused there. You don't need to explicitly close the splash screen anyway. It will be displayed for a minimum length of time, 2 seconds being the default. If the main form is ready to display before that it will wait at least that long. If the main form takes longer than that to construct and load then the splash screen will remain visible until its ready to display and then it will close on its own.
 

sudhanshu22

Member
Joined
Nov 8, 2006
Messages
20
Programming Experience
Beginner
Hi JMC,
Thanks,
But you got to tell me what is wrong in the way I am doing ?
1> suppose I abort() a thread, then the thread called a function where a form was created. once I abort() the thread, the form.dispose() should be called automatically. Is it true ?
2> tell me to solve this problem. If a form is minimized, then using the code, can I bring the form to focus ( I mean it is brought to screen for the user)
 
Top Bottom