J
jxsbb
Unregistered / Unconfirmed
GUEST, unregistred user!
我想做一个控件,继承自TWinControl,做一个复合控件,就是panel上有一个speedbutton,但却无法显示出来,请高手看一下问题在哪儿?
谢谢了!
源码:
unit WWinControl1;
interface
uses
SysUtils, Classes, Controls, ExtCtrls, Buttons, Graphics;
type
TWWinControl1 = class(TWinControl)
private
{ Private declarations }
F1:TPanel;
F2:TSpeedButton;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner:TComponent);override;
destructor Destroy;override;
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TWWinControl1]);
end;
{ TWWinControl1 }
constructor TWWinControl1.Create(AOwner: TComponent);
begin
inherited;
F1:=TPanel.Create(nil);
F1.Parent:=self;
F1.Align:=alLeft;
F1.Width:=self.Width div 2;
F1.Color:=clRed;
F1.Visible:=true;
F2:=TSpeedButton.Create(nil);
F2.Parent:=F1;
F2.Height:=28;
F2.Width:=28;
F2.Top:=0;
F2.Left:=10;
end;
destructor TWWinControl1.Destroy;
begin
F1.Free;
inherited;
end;
end.
谢谢了!
源码:
unit WWinControl1;
interface
uses
SysUtils, Classes, Controls, ExtCtrls, Buttons, Graphics;
type
TWWinControl1 = class(TWinControl)
private
{ Private declarations }
F1:TPanel;
F2:TSpeedButton;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner:TComponent);override;
destructor Destroy;override;
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TWWinControl1]);
end;
{ TWWinControl1 }
constructor TWWinControl1.Create(AOwner: TComponent);
begin
inherited;
F1:=TPanel.Create(nil);
F1.Parent:=self;
F1.Align:=alLeft;
F1.Width:=self.Width div 2;
F1.Color:=clRed;
F1.Visible:=true;
F2:=TSpeedButton.Create(nil);
F2.Parent:=F1;
F2.Height:=28;
F2.Width:=28;
F2.Top:=0;
F2.Left:=10;
end;
destructor TWWinControl1.Destroy;
begin
F1.Free;
inherited;
end;
end.