控件编写问题(100)

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

liuguilg

Unregistered / Unconfirmed
GUEST, unregistred user!
我想写以个控件,panel上面放一个edit, 下面是我的代码, 加载后panel上面没有edit ?unit My_panel_edit;interfaceuses SysUtils, Classes, Controls, ExtCtrls, StdCtrls;type TMy_panel_edit = class(TPanel) private { Private declarations } FEdit:TEdit; protected { Protected declarations } public { Public declarations } constructor Create(AOwner: TComponent); override; destructor Destroy; override; published { Published declarations } end;procedure Register;implementationprocedure Register;begin RegisterComponents('Standard', [TMy_panel_edit]);end;{ TMy_panel_edit }constructor TMy_panel_edit.Create(AOwner: TComponent);begin inherited Create(AOwner); width := 100; height := 100; FEdit := Tedit.Create(self); FEdit.Left := 2; FEdit.Top := 2; FEdit.Width := 50; FEdit.Height := 20;end;destructor TMy_panel_edit.Destroy;begin FEdit.Free; inherited Destroy;end;end.
 
加上 FEdit.parent := self
 
果然,多谢多谢
 
后退
顶部