Is there any way to get the time left before a TTimer is due to fire?

952 views Asked by At

Possible Duplicate:
Delphi Timer: Time before next event

Using C++ builder XE on Windows 7 Pro (64 bit) :

I have a TTimer on a form.

What I want to do is to update a progress bar to show how long the TTimer has left before it calls the OnTimer event handler.

Is there any way to find out low long it will be until the TTimer's interval fires the OnTimer event ?

1

There are 1 answers

3
Rob Kennedy On

No, Windows timers provide no interface for that.

Since you're going to be updating a progress bar anyway, you'll already have some periodic code that's running more frequently than the timer that you want to track. That code will be triggered by a timer, so in that timer code, check the current time and compare out to the due time you previously calculated for the timer you wanted to track.

Then, get rid of the first timer since you no longer need it. Instead, just use the "tracking" timer to trigger the original code when it's time. Ultimately, you'll have one timer that continuously checks whether it's time to run the code. If it's time, then run the code; otherwise, update the progress bar instead.