PDA

View Full Version : [TUT] Forms: TProgressBars



Da 0wner
02-01-2009, 10:00 AM
Today we will be learning how to use TProgressBars.

First, create a form that looks like this:

http://img.techpowerup.org/090201/Capture026.jpg
Without the label at the bottom of course :p.

Then, put the below procedure above the InitForm; procedure.


procedure Increase(Sender : TObject);
begin
if x.Position < 110 // Where x is the name of the progress bar.
x.StepIt;
end;


After that, attach the procedure to run when the button is clicked. To do so put


x.OnClick := @y; // Where x is the name of the button and y is the name of the procedure.


below where it says


x.TabOrder := y; // Where x is the name of the button and y is the tab order. You don't have to do anything to that line.


Then run the form. It should work now and the progress bar should increase by 1/10 of it's size each time you click the button.

Now let's explain the variables of the progressbar and what they do.


x := TProgressBar.Create(y); // x is the name of the progress bar.
x.Parent := frmDesign // y is the name of the form it's on.
x.Left := 16; // z is the number the progressbar increases each time
x.Top := 32; // x.StepIt; is called.
x.Width := 169; // a is the minium number that the progressbar can go.
x.Height := 17; // b is the maximum number the progressbar can go.
x.TabOrder := 9; // When StepIt; is called and the position of the
x.Step := z; // progressbar is already at maximum it will go back to
x.Min := a; // the minimum.
x.Max := b;


There is also another way to step the progressbar.


x.StepBy(y); // where x is the name of the progressbar and y is the amount to step by.


Progressbars can be used to create cool things like download progress bars and are great when combined with TTimers.

Thank you for reading my tutorial.
I hoped you learned something from reading it!

Don't forget to rate the thread 5 stars and rep me if you liked it!

The script used is attached below.

EvilChicken!
02-01-2009, 10:23 AM
It's a good tut, pretty simple to follow, just as it should be.
I don't think progress bards are too advanced, it would be nice if this thread stayed where it already is IMO.

I see you're really good with forms, why not make a massive tutorial that consists of a compilation of tutorials about all kinds of form-related subjects?

Da 0wner
02-01-2009, 10:25 AM
Yea maybe I will do that.

Naum
02-01-2009, 11:51 AM
Hey Umm, shouldn't this be in Tutorial Island :). Good Tutorial, Get on MSN

tarajunky
02-01-2009, 07:06 PM
I would move for you, but if you want to edit it and add more you might not be able to do so in another section. I'll leave it here until you complete it.

Da 0wner
02-02-2009, 03:20 PM
Updated. Added a picture and attached script and made it more detailed.

nickrules
10-22-2009, 09:31 PM
Oooo Thanks! very helpful, i was looking for a tut on this.