//呵呵,这是个笨办法,看看高手们还有没有更简单的方法.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure FormClick(Sender: TObject);
procedure FormDblClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
iCount:integer;
bClick:boolean;
bDblClick:boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
iCount:=0;
bClick:=False;
bDblClick:=False;
end;
procedure TForm1.FormClick(Sender: TObject);
begin
bDblClick:=False;
iCount:=0;
bClick:=True;
Timer1.Enabled:=True;
end;
procedure TForm1.FormDblClick(Sender: TObject);
begin
bDblClick:=True;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if bClick then Inc(iCount);
if iCount>20 then
begin
Timer1.Enabled:=False;
ShowMessage('Click');
end else
if bDblClick then
begin
Timer1.Enabled:=False;
ShowMessage('DblClick');
end;
end;
end.