Z
zjmaskman
Unregistered / Unconfirmed
GUEST, unregistred user!
如题。我正在写一个继承自TEdit的带有一个 BitBtn 按钮的控件,遇到上述问题。
另外,这个动态添加的 BitBtn 按钮,其 OnClick事件怎么与新的控件的事件关联?我自定义了一个事件。部分代码如下:
unit ButtonEdit;
interface
uses
Windows, Messages, SysUtils, Classes,
Graphics,Controls, StdCtrls, ExtCtrls,
Dialogs,Buttons;
type
TLabelEditButton = class(TLabeledEdit)
CmdButton:TBitBtn;
private
{ Private declarations }
OriSize:TSize; //Initial Size of the BitBtn component
FOnBtnClick:TNotifyEvent;
protected
{ Protected declarations }
public
{ Public declarations }
Constructor Create(AOwner:TComponent);override;
Destructor Destroy;override;
published
{ Published declarations }
Property OnBtnClick:TNotifyEvent read FOnBtnClick write FOnBtnClick;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyComponent', [TLabelEditButton]);
end;
Constructor TLabelEditButton.Create(AOwner:TComponent);
begin
Inherited;
CmdButton:=TBitBtn.Create(Self);
CmdButton.Parent:= Self;
FOnBtnClick:=OnBtnClick; //此处无效
CmdButton.OnClick:= FOnBtnClick;
CmdButton.Align:=alRight; //正方型按钮
CmdButton.Height:=Height;
CmdButton.Width:=Height;
end;
请各位大侠帮忙。
另外,这个动态添加的 BitBtn 按钮,其 OnClick事件怎么与新的控件的事件关联?我自定义了一个事件。部分代码如下:
unit ButtonEdit;
interface
uses
Windows, Messages, SysUtils, Classes,
Graphics,Controls, StdCtrls, ExtCtrls,
Dialogs,Buttons;
type
TLabelEditButton = class(TLabeledEdit)
CmdButton:TBitBtn;
private
{ Private declarations }
OriSize:TSize; //Initial Size of the BitBtn component
FOnBtnClick:TNotifyEvent;
protected
{ Protected declarations }
public
{ Public declarations }
Constructor Create(AOwner:TComponent);override;
Destructor Destroy;override;
published
{ Published declarations }
Property OnBtnClick:TNotifyEvent read FOnBtnClick write FOnBtnClick;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyComponent', [TLabelEditButton]);
end;
Constructor TLabelEditButton.Create(AOwner:TComponent);
begin
Inherited;
CmdButton:=TBitBtn.Create(Self);
CmdButton.Parent:= Self;
FOnBtnClick:=OnBtnClick; //此处无效
CmdButton.OnClick:= FOnBtnClick;
CmdButton.Align:=alRight; //正方型按钮
CmdButton.Height:=Height;
CmdButton.Width:=Height;
end;
请各位大侠帮忙。