如何在Timer中获得剩余时间? [英] How to get timeleft in Timer?

查看:154
本文介绍了如何在Timer中获得剩余时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

Delphi计时器:下一个事件之前的时间


如何

例如:



我创建一个间隔为60的计时器000

 程序TForm1.my_Timer(Sender:TObject); 
开始
//做点
结束;

然后我创建了另一个计时器(间隔1000),原因是要获取第一个计时器的剩余时间

 程序TForm1.second_Timer(Sender:TObject); 
开始
second_Timer.Interval:= 1000;
Label1.Caption:= IntToStr(my_Timer.timeleft); // 怎么样 ???
结尾;

谢谢。

解决方案

您无法从计时器获取此信息。您能做的最好的事情就是记下计时器的最后触发时间,然后自己解决。例如,您可以使用 TStopwatch 为此。


Possible Duplicate:
Delphi Timer: Time before next event

How to get current timeleft when timer will be executed ?

for example:

I create a timer with interval 60 000

procedure TForm1.my_Timer(Sender: TObject);
begin
  // do something
end;

Then I create another timer (interval 1000) which reason is to get the timeleft of the first timer

procedure TForm1.second_Timer(Sender: TObject);
begin
  second_Timer.Interval := 1000;
  Label1.Caption := IntToStr(my_Timer.timeleft); // How ???
end;

Thanks.

解决方案

You can't get this information from the timer. The best you can do is make a note of when the timer last fired and work it out for yourself. For example you can use TStopwatch to do this.

这篇关于如何在Timer中获得剩余时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆