I want to replace my progress bar with gauge. Here is version on progress bar:
procedure TForm1.tmr1Timer(sender: TObject);
begin
pb0.Position := (pb0.Position + 1) mod pb0.Max;
end;
And this is on gauge
procedure TForm1.tmr1Timer(sender: TObject);
begin
gauge.MinValue := 0;
gauge.MaxValue := 100;
gauge.Progress := gauge.Progress + 1;
end;
How to make it start over every time it reach 100 ? As i tried with button to test, i can not make it looping just like on progress bar.
procedure TForm1.btn6Click(sender: TObject);
begin
tmr1.Enabled := not tmr1.Enabled;
begin
gauge.Progress := 0;
tmr1.Enabled := True
end;
if Form1.gauge.Progress = 100 then // is this correct ?
// what to do to make it looping ?
end;
How to make same the function on gauge as replacement for progress bar + timer above?
The same way. Just use the different property names for
TGauge
(and remove the setting ofMinValue
andMaxValue
from the timer event):@DavidHeffernan points out in a comment that my calculation will never reach a full
100%
value, and suggests an alternative:It has different issues: the progress display does not start at
0
, and it increments in steps of 2. However, it indeed does reach100%
.As @TLama pointed out in a comment, neither of the above work if the
MinValue
can be negative.This calculation has no issues (loops from MinValue to MaxValue, and both can be negative) if
MinValue < MaxValue