am looking for a way to count down from 30 seconds using a timer and updating a Gauge using Progress to reflect the time remaining.
I know this is very simple code but my brain is some what dead here my bad code.

procedure FreeTimerTimer(Sender: TObject);
begin
  TotalTime := GetTickCount() - FreeTimer.Interval; // 30000 int
  //
  Gauge.MaxValue := 100;
  Gauge.MinValue := 0;
  Gauge.Progress := TotalTime;
  //
  if Gauge.Progress = 100 then
  begin
      FreeTimer.Enabled := False; // stop timer when done
  end;
end;

Thanks.

The GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days
Your comment suggests FreeTimer.Interval is 30000.
So you set TotalTime, and hence the gauge progress, to the number of milliseconds that have elapsed since the system was started, less 30000. For your gauge to work, Gauge.Progress must be between Gauge.MinValue (0) and Gauge.MaxValue (100). This is only true for 1 tenth of a second every 49.7 days. Probably not what you want.

I suggest you set Gauge.MaxValue to 30000. Use a CountdownStarted variable and set this to GetTickCount whenever the countdown starts. Your timer event should again call GetTickCount and subtract CountdownStarted from this. That will be the number of milliseconds since the countdown started and you can use this for Gauge.Progress.

Geeze - people are still using Pascal these days? Are you running a P-machine, or some version of Turbo Pascal? Ok. Better to use a timer interrupt instead of a constant loop, and if you need to do stuff before the timer kicks, then use a loop and check the bit as shown here: http://www.ibrtses.com/embedded/avrtimer.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.