看看我写的按钮组件为什么不能响应onClick事件

superxwx 2003-08-21 01:48:26
代码有问题吗?为什么OnMouseDown可行,OnClick就不行了呢?
谢谢指教。

unit FlatButton;

interface

uses
SysUtils, Classes, Controls, StdCtrls, Messages, Graphics, windows, ExtCtrls, buttons,forms,CommCtrl;

type
TFlatButton = class(TCustomControl)

private
{ Private declarations }

protected
{ Protected declarations }

public
{ Public declarations }
constructor Create(AOwner:TComponent);override;
destructor Destroy;override;
procedure Click;override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;

published
{ Published declarations }
property OnClick;
property OnMouseDown;

end;

procedure Register;



implementation

constructor TFlatbutton.Create(AOwner:TComponent);
begin
inherited create(AOwner);
ControlStyle := [csOpaque, csDoubleClicks];
end;

destructor TFlatbutton.Destroy;
begin
inherited Destroy;
end;

procedure TFlatButton.Click;
begin
inherited Click;
end;

procedure TFlatButton.MouseDown (Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
inherited MouseDown(Button, Shift, X, Y);
end;

procedure Register;
begin
RegisterComponents('Samples', [TFlatButton]);
end;


end.

...全文
47 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
superxwx 2003-08-21
  • 打赏
  • 举报
回复
解决了。
谢谢。

另:这里的发贴、加分是怎么回事??
lxpbuaa 2003-08-21
  • 打赏
  • 举报
回复
constructor TFlatbutton.Create(AOwner:TComponent);
begin
inherited create(AOwner);
ControlStyle := [csOpaque, csDoubleClicks, csClickEvents];
end;

—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧