unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
mmo1: TMemo;
mmo2: TMemo;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure Timerproc1( window : Hwnd ; message,idEvent :UInt; dwTime: dword);stdcall;
begin
Form1.mmo1.Lines.Add('Running1...'); //一直运行,直到关闭窗体
end;
procedure Timerproc2( window : Hwnd ; message,idEvent :UInt; dwTime: dword);stdcall;
begin
Form1.mmo2.Lines.Add('Running2...');
KillTimer(Form1.Handle,2); //只运行一次就停止下来。
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SetTimer(Handle,1,1000,@TimerProc1);
SetTimer(Handle,2,1000,@TimerProc2);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
KillTimer(Handle,1);
end;
end.
作者在 2014-05-12 00:00:53 发布以下内容