sorry 各位大侠,我说的是在制作一个新的控件时,在新控件里的onclick事件里怎么添加自己的代码
(最好有原码)!!!!!!!
请看以下代码毛病在哪里?为什么点了按钮之后没有反应呢?
unit button2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
tbutton2 = class(tbutton)
private
Fonclick:tnotifyevent;
procedure Fmyonclick(Sender: TObject);
{ Private declarations }
protected
{ Protected declarations }
public
constructor create(aowner:tcomponent);override;
{ Public declarations }
published
property onclick:tnotifyevent read fonclick write fonclick;
{ Published declarations }
end;
procedure Register;
implementation
constructor tbutton2.create(aowner:tcomponent);
begin
inherited;
onclick:=fmyonclick;
end;
procedure tbutton2.fmyonclick(Sender: TObject);
begin
if assigned(fonclick) then begin fonclick(self);end;
application.messagebox('','',mb_ok);//自己的代码
end;
procedure Register;
begin
RegisterComponents('Samples', [tbutton2]);
end;
end.