TCustomPanel继承下的的控件不能响应OnClick事件 ( 积分: 100 )

  • 主题发起人 主题发起人 LanzeServer
  • 开始时间 开始时间
L

LanzeServer

Unregistered / Unconfirmed
GUEST, unregistred user!
我从TCustomPanel继承下的的控件不能响应OnClick事件,这是什么原因?我已把OnClick这个属性设置为PUBLIC。
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;

type
TMyControl = class(TCustomPanel)
public
property OnClick;
end;

TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }

procedure MyControlOnClick(Sender: TObject);
public
{ Public declarations }

MyControl: TMyControl;
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
MyControl := TMyControl.Create(Self);
MyControl.Parent := Self;
MyControl.Align := alClient;
MyControl.Show;
MyControl.OnClick := MyControlOnClick;
MyControl.Caption := 'sadasdasd';
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
FreeAndNil(MyControl);
end;

procedure TForm1.MyControlOnClick(Sender: TObject);
begin
ShowMessage('ok');
end;

end.
 
published
property onclick
 

Similar threads

后退
顶部