Da 0wner
2009-02-01 05:00:50
Today we will be learning how to use TProgressBars.
First, create a form that looks like this:
Without the label at the bottom of course :p.
Then, put the below procedure above the InitForm; procedure.
After that, attach the procedure to run when the button is clicked. To do so put
below where it says
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.
There is also another way to step the progressbar.
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.
First, create a form that looks like this:
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.