RSS订阅 | 匿名投稿
您的位置:网站首页 > 组件 > 正文

delphi 一个定时器Timer1相关的简单例子

作者:admin 来源:未知 日期:2010/5/3 22:19:15 人气: 标签:

代码文件:
--------------------------------------------------------------------------------

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
Timer1.Interval := 15000; {定时器每 15 秒执行一次}
Timer1.Enabled := False; {定时器默认是直接启动的, 先关闭它}
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
{启动定时器}
Timer1.Enabled := True;
{点击按钮是什么功能呢? 譬如是让按钮标题自动计数}
Button1.Caption := IntToStr(StrToIntDef(Button1.Caption, 0) + 1);
end;

{定时去执行 Button1Click}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Button1.Click;
end;

end.


读完这篇文章后,您心情如何?
0
0
0
0
0
0
0
0
本文网址: