unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure MyOnIdle(Sender:TObject;var Done:Boolean);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
IdleBegin
Word;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.MyOnIdle(Sender: TObject; var Done: Boolean);
begin
if IdleBegin=0 then
IdleBegin:=gettickcount();
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:=IntToStr(GetTickCount-IdleBegin);
IdleBegin:=0;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnIdle:=MyOnIdle;
end;
end.