想从PageControl下继承个控件,不会加TabSheet了,大家帮帮忙啊(100分)

  • 主题发起人 主题发起人 Chen Yu
  • 开始时间 开始时间
C

Chen Yu

Unregistered / Unconfirmed
GUEST, unregistred user!
我打算做个控件,从PageControl下继承,想直接建立几个TabSheet,请问应该怎么做啊,
我加了 如下代码,却提示父类应该是个窗口,搞不明白了。。。。

type
tMyPage = class(TPageControl)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
end;
-------------------------------------------
constructor tMyPage.Create(AOwner: TComponent);
var aa:ttabsheet;
begin
inherited create(aowner);
aa:= ttabsheet.create(self);
aa.PageControl := self;
aa.caption:='test';
end;
--------------------------------------------
错误提示是:" Control '' has no parent window "
哪位大侠帮着看看啊
 
TPageControl这个是父控件
unit uTabSheetWithBrowser;

interface

uses
Windows,
Messages,
SysUtils,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
ComCtrls,
EmbeddedWB,
SHDocVw;
type
TTabSheetWithBrowser = class(TTabSheet)
private
{ Private declarations }
protected
{ Protected declarations }
public
WebBrowser:TembeddedWB;
Constructor Create(AOwner:TComponent);override;
procedure TabSheetWithBrowserResize(var amsg:TMessage); message WM_SIZE;
Destructor Destory;
{ Public declarations }
published
{ Published declarations }

end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('Samples', [TTabSheetWithBrowser]);
end;

{ TTabSheetWithBrowser }

constructor TTabSheetWithBrowser.Create(AOwner:TComponent);
begin
inherited;
self.WebBrowser:=TembeddedWB.Create(AOwner);
end;

destructor TTabSheetWithBrowser.Destory;
begin
self.WebBrowser.Destroy;
self.WebBrowser:=nil;
inherited;
end;

procedure TTabSheetWithBrowser.TabSheetWithBrowserResize(var amsg:TMessage);
begin
self.WebBrowser.SetBounds(0,0,amsg.LParamLo,amsg.LParamHi);
end;
end.
 
constructor tMyPage.Create(AOwner: TComponent);
var aa:ttabsheet;
begin
inherited create(aowner);
aa:= ttabsheet.create(nil);
aa.parent:= self;
aa.caption:='test';
end;
 
to JavaSun
还是出现一样的错误。。。。
 
汗。这个tMyPage你还没放到一个父窗口上就要加上一个tab,当然出错,可以在createwnd的事件里建立TAB
 
后退
顶部