Y
yf168
Unregistered / Unconfirmed
GUEST, unregistred user!
我想做一个控件,形式是在edit旁边放一个button按钮,功能是点击button弹出来我自己的form,
unit winControl1;
interface
uses
SysUtils, Classes, Controls,stdctrls,ExtCtrls,Graphics,unit1;
type
TwinControl1 = class(TWinControl)
private
Fedit:TEdit;
Flist:Tstringlist;
Fbtn:Tbutton;
{ Private declarations }
protected
procedure btnClick(Sender: TObject);
{ Protected declarations }
public
constructor create(Aowner:Tcomponent);override;
{ Public declarations }
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TwinControl1]);
end;
{ TwinControl1 }
procedure TwinControl1.btnClick(Sender: TObject);
begin
createform(Flist);//(createform过程在unit1里面)
end;
constructor TwinControl1.create(Aowner: Tcomponent);
begin
inherited;
Flist:=Tstringlist.Create;
self.Height :=21;
Fedit:=Tedit.Create(self);
Fedit.Top:=0;
Fedit.Parent:=self;
Fedit.Width :=121;
Fedit.Height :=21;
Fbtn:=Tbutton.Create(self);
// Fspeedbutton.Parent:=self;
Fbtn.Left :=Fedit.Left +Fedit.Width +2;//edit与Fspeedbutton的距离
Fbtn.Top:=0;
Fbtn.Width:=23;
Fbtn.Caption :='...';
Fbtn.OnClick :=self.btnClick ;
self.Width := Fedit.Width +Fbtn.Width;
end;
end.
现在的问题是这个button显示不出来,只有edit显示出来了,但是button的位置确实存在
也就是说控件长度是edit+button的宽度.
各位大虾!!!!,help
unit winControl1;
interface
uses
SysUtils, Classes, Controls,stdctrls,ExtCtrls,Graphics,unit1;
type
TwinControl1 = class(TWinControl)
private
Fedit:TEdit;
Flist:Tstringlist;
Fbtn:Tbutton;
{ Private declarations }
protected
procedure btnClick(Sender: TObject);
{ Protected declarations }
public
constructor create(Aowner:Tcomponent);override;
{ Public declarations }
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TwinControl1]);
end;
{ TwinControl1 }
procedure TwinControl1.btnClick(Sender: TObject);
begin
createform(Flist);//(createform过程在unit1里面)
end;
constructor TwinControl1.create(Aowner: Tcomponent);
begin
inherited;
Flist:=Tstringlist.Create;
self.Height :=21;
Fedit:=Tedit.Create(self);
Fedit.Top:=0;
Fedit.Parent:=self;
Fedit.Width :=121;
Fedit.Height :=21;
Fbtn:=Tbutton.Create(self);
// Fspeedbutton.Parent:=self;
Fbtn.Left :=Fedit.Left +Fedit.Width +2;//edit与Fspeedbutton的距离
Fbtn.Top:=0;
Fbtn.Width:=23;
Fbtn.Caption :='...';
Fbtn.OnClick :=self.btnClick ;
self.Width := Fedit.Width +Fbtn.Width;
end;
end.
现在的问题是这个button显示不出来,只有edit显示出来了,但是button的位置确实存在
也就是说控件长度是edit+button的宽度.
各位大虾!!!!,help