如果做好一个继承就好办多了
还有,你想防止2次运行不应该是通过屏蔽双击,当然双击事件还是要屏蔽的....
重要是用laoyangzi的方法,执行完以前设置enabled:=false;
我代码里把这部分包括了
这样:
TNewButton = class(TButton)
private
procedure WndProc(var Message: TMessage); override;
protected
{ Protected declarations }
procedure SetEnabled(Value: Boolean); override;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Additional', [TNewButton]);
end;
procedure TNewButton.WndProc(var Message: TMessage);
begin
if not (csDesigning in ComponentState) then
case Message.Msg of
WM_LBUTTONDOWN:
begin
Enabled:=false;
inherited;
Enabled:=true;
end;
WM_LBUTTONDBLCLK:
Perform(WM_LBUTTONDOWN,Message.WParam,Message.LParam)
else
inherited ;
end;
else
inherited;
end;
end.