The same way. Just use the different property names for TGauge
(and remove the setting of MinValue
and MaxValue
from the timer event):
procedure TForm1.tmr1Timer(sender: TObject);
begin
gauge.Progress := (gauge.Progress + 1) mod (gauge.MaxValue - gauge.MinValue);;
end;
@DavidHeffernan points out in a comment that my calculation will never reach a full 100%
value, and suggests an alternative:
gauge.Progress := gauge.MinValue + (gauge.Progress + 1) mod
(gauge.MaxValue - gauge.MinValue + 1);
It has different issues: the progress display does not start at 0
, and it increments in steps of 2. However, it indeed does reach 100%
.
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
gauge.Progress := gauge.MinValue +
( gauge.Progress + 1 - gauge.MinValue ) mod
( gauge.MaxValue - gauge.MinValue + 1 );