本文整理自网络,侵删。
代码文件:
--------------------------------------------------------------------------------
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.
相关阅读 >>
Delphi 如何使用findfirst搜索不同的文件类型?
更多相关阅读请进入《Delphi》频道 >>