怎样做一个简单的计时器?可以控制开始和结束,如从20到0。
解决方案 »
- sql2008使用ado查询中途超时
- 老人家向大家问好,好久没来了,祝愿大家事事如意,一帆风顺。
- 真正做过三层商用程序的进来看一下这个Borland公布的bug.
- 将dbgrid中的数据导入到excel中后,数据不能进行累加,显示是文本类型,不是数字类型。
- 小问题请教!~以前做过,但忘了!!!
- 请问一个关于李维的《Delphi5.x MIDAS应用》一书上的问题,高手请进!!!
- 如何获取某个控件的键盘消息? Help!!!!!!!!!!!!!
- 如何限制edit只能接受数字、回车键、Del键以及BackSpace键?
- 类似于windows的注销
- 1stClassStudio控件
- TStoredProc返回的Dataset修改后未提交数据库!
- CPORT控件的问题,高手进
Form1: TForm1;
i:integer=20;
implementation{$R *.dfm}procedure TForm1.Timer1Timer(Sender: TObject);
begin
i:=i-1;
edit1.text:=inttostr(i);
end;procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled:=true; //开始
end;procedure TForm1.Button2Click(Sender: TObject);
begin
timer1.Enabled:=false; //停止
end;
http://lysoft.7u7.net
var
i:integer...........然后在timer事件中
begin
i:=i+1;
然后就可以使用这个i了
end;
这是一个最最简陋的定时器,不过可以精确到毫秒
------------------------------
unit Unit1;interfaceuses
windows,Classes;type
TimerThread = class(TThread)
private
{ Private declarations }
dBegin,dEnd : Dword;
protected
procedure Execute; override;
public
FCanClose : Boolean;
end;implementation{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example, Synchronize(UpdateCaption); and UpdateCaption could look like, procedure TimerThread.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }{ TimerThread }procedure TimerThread.Execute;
begin
{ Place thread code here }
dBegin := GetTickCount;
while not FCanClose do
begin
dEnd := GetTickCount;
if dEnd-dBegin>=1000 then
begin
//在这里写代码 dBegin := GetTickCount;
end;
end;
end;end.