使用timer遇到的问题,请赐教(100分)

  • 主题发起人 delphikings
  • 开始时间
D

delphikings

Unregistered / Unconfirmed
GUEST, unregistred user!
首先显示一串字母(asdf)56毫秒,隔50毫秒再显示这串字母,这次显示42ms,再隔98ms显示一个形容词,这个形容词显示500ms
这是一次循环,一共循环8次,每次只是形容词不同,其他都一样
我的困惑就是timer本身就是循环执行,而且每个阶段的时间间隔不同,请赐教!
 
timer在不同系统上的准确度是不同的。如果要求控制时间很准确建议用系统的毫秒级时间
timegettime 取系统的毫秒时间。
 
多用几个timer试试
 
哪位大哥能给我个解决的办法,时间要求不用太精确,差不多就行,最好详细点,呵呵[:D][:D][:D]
 
拉一个Timer1;在Interval设置第一次的56然后在OnTimer中写(不过先搞一个全局变量n来
控制循环次数)
然后: if n=1 then
Timer1.Interval:=42;
.......{you want to do}
if n=2 then
Timer1.Interval:=98:
...... {you want to do }
.
....
 
你这个问题用 Timer 不方便,不如另外开个线程,简单得多:

procedure MyThread.Execute;
begin
while not Terminated do
begin
DisplayStr(str); // 显示字符串
Sleep(56);
DisplayStr(''); // 清空 50ms
Sleep(50);
DisplayStr(str);
Sleep(42);
....
end;
end;
 
Timer 没有那么高的精度,大小在 1/18.?? 秒左右。
 
设个全局变量count表示循环次数,然后在timer的timer时间中写。
procedure TForm1.Timer1Timer(Sender: TObject);
begin
case count of
1:
begin
Label1.Caption := 'asdf' ;
Timer1.Interval :=50;
count := count + 1 ;
end;
2:
begin
Label1.Caption := 'asdf' ;
Timer1.Interval :=42;
count := count + 1 ;
end;
3:
.
.
.
.
end;
 
自己写延时函数,然后在程序中处理
——————————————————————————————
Procedure TimeDelay(NumSec :Integer);//NumSec ->毫秒
var
StartTime: Double;
begin
StartTime := now;
repeat
Application.ProcessMessages;
until Now > StartTime + NumSec * (1/24/60/60/1000);
end;
————————————————————————————————
 
达不到这样的精度啊,

我还是同意用不同的线程吧
 
弄影,我采纳你的方法,可是不知道怎样实现8次循环阿,能不能详细点写写

谢谢,有更多的分等着你
 
这个容易,再设个变量,循环一次增1,满8退出
 
顶部