unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
btn1: TButton;
mmo1: TMemo;
procedure btn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
FBtnLastClickTime: Cardinal;
procedure ResetBtnLastClickTime;
procedure OnBtnClicked;
procedure OnBtnDblClicked;
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
const
cBtnDblClickTimeout = 1000;
procedure TForm1.btn1Click(Sender: TObject);
begin
if FBtnLastClickTime + cBtnDblClickTimeout > GetTickCount
then
begin
OnBtnDblClicked;
ResetBtnLastClickTime;
end
else
begin
OnBtnClicked;
FBtnLastClickTime := GetTickCount;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ResetBtnLastClickTime;
end;
procedure TForm1.ResetBtnLastClickTime;
begin
FBtnLastClickTime := 0;
end;
procedure TForm1.OnBtnClicked;
begin
mmo1.Lines.Add('
Click');
end;
procedure TForm1.OnBtnDblClicked;
begin
mmo1.Lines.Add('
Doubleclick');
end;
end.