1,184
社区成员
发帖
与我相关
我的任务
分享unit Unit11;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm11 = class(TForm)
btn1: TButton;
btn2: TButton;
tmr1: TTimer;
procedure btn1Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
private
{ Private declarations }
procedure TimerProc5(var Message: TWMTimer); message WM_TIMER;
public
{ Public declarations }
end;
var
Form11: TForm11;
i : integer = 0;
implementation
{$R *.dfm}
procedure TimerProc(hwnd:HWND;uMsg,idEvent:UINT;dwTime:DWORD); stdcall;
begin
inc(i);
Form11.Caption := IntToStr(i);
end;
procedure TimerProc2(hwnd:HWND;uMsg,idEvent:UINT);
begin
inc(i);
Form11.Caption := IntToStr(i);
end;
function TimerProc3 : Integer;
begin
Result := 0;
inc(i);
Form11.Caption := IntToStr(i);
end;
procedure TimerProc4(hwnd:HWND;uMsg,idEvent:UINT;dwTime:DWORD; iTest, iTest2 : Integer); stdcall;
begin
//iTest, iTest2的值无意义
inc(i);
Form11.Caption := IntToStr(i);
end;
procedure TForm11.TimerProc5(var Message: TWMTimer);
begin
inc(i);
Form11.Caption := IntToStr(i);
end;
procedure TForm11.btn1Click(Sender: TObject);
begin
// SetTimer(Handle,10,500,@TimerProc);
// SetTimer(Handle,10,500,@TimerProc2);
// SetTimer(Handle,10,500,@TimerProc3); //调用函数
// SetTimer(Handle,10,500,@TimerProc4);
SetTimer(Handle,10,500,nil); //调用TimerProc5
end;
procedure TForm11.btn2Click(Sender: TObject);
begin
KillTimer(Handle,10);
end;
end.