A
Adnil
Unregistered / Unconfirmed
GUEST, unregistred user!
可视控件的继承问题
TMyPanel = class(TPanel)
private
FEdit: TEdit;
public
property Edit: TEdit read FEdit write FEdit;
property BevelOuter default bvNone;
property BorderStyle default bsSingle;
constructor Create(AOwner: TComponent); override;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Sample', [TMyPanel]);
end;
constructor TMyPanel.Create(AOwner: TComponent);
begin
inherited;
BevelOuter := bvNone;
BorderStyle := bsSingle;
FEdit := TEdit.Create(Self);
FEdit.Height := 16;
FEdit.Width := 60;
FEdit.Parent := Self;
end;
然后将控件注册,新建工程,拖入一个TMyPanel命名MyPanel1,发现两个错误:
1.属性编辑器中不能找到Edit;
2.查看Form1的dfm文件,发现BevelOuter属性和BorderStyle属性还是写入了,虽然已经设置了Default值
object MyPanel1: TMyPanel
Left = 128
Top = 96
Width = 80
Height = 20
BevelOuter = bvNone
BorderStyle = bsSingle
...
end
哪位朋友能帮我看看?如何解决这两个问题。非常感谢!
TMyPanel = class(TPanel)
private
FEdit: TEdit;
public
property Edit: TEdit read FEdit write FEdit;
property BevelOuter default bvNone;
property BorderStyle default bsSingle;
constructor Create(AOwner: TComponent); override;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Sample', [TMyPanel]);
end;
constructor TMyPanel.Create(AOwner: TComponent);
begin
inherited;
BevelOuter := bvNone;
BorderStyle := bsSingle;
FEdit := TEdit.Create(Self);
FEdit.Height := 16;
FEdit.Width := 60;
FEdit.Parent := Self;
end;
然后将控件注册,新建工程,拖入一个TMyPanel命名MyPanel1,发现两个错误:
1.属性编辑器中不能找到Edit;
2.查看Form1的dfm文件,发现BevelOuter属性和BorderStyle属性还是写入了,虽然已经设置了Default值
object MyPanel1: TMyPanel
Left = 128
Top = 96
Width = 80
Height = 20
BevelOuter = bvNone
BorderStyle = bsSingle
...
end
哪位朋友能帮我看看?如何解决这两个问题。非常感谢!