Z
zqw0117
Unregistered / Unconfirmed
GUEST, unregistred user!
我有一个控件,是从TGraphicControl继承下来的,但现在我需要将它转换成
ActiveX(.ocx)控件。但要把VCL控件转换成ActiveX控件的话必须保证被转换
的控件是从TWinControl继承的。这个继承关系我无法改变,于是我想用一个容器
控件(就是一个TWinControl控件)包含这个从TGraphicControl继承下了的控件
做成另外一个合成控件,然后再转换成ActiveX控件。
想法到可以,但出现的问题是,当点击new->acitve-ActiveX Control的时候,总是提示:
"Control '' has no parent window"错误
我不知该如何修正这个错误,请各位大虾指教一下,谢谢!
下面是我的部分代码:
type
TDropChangingEvent = procedure (Sender: TObject
var Allowed: Boolean) of Object;
TColorPicker = class(TWinControl)
private
{ Private declarations }
FButton: TColorPickerButton;//这个就是那个从TGraphicControl继承下来的控件
...
protected
{ Protected declarations }
procedure CreateParams(var Params: TCreateParams)
override;
...
procedure Loaded
override;
public
{ Public declarations }
constructor Create(AOwner: TComponent)
override;
destructor Destroy
override;
...
published
{ Published declarations }
...
end;
implementation
constructor TColorPicker.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Self.SetParent(AOwner as TWinControl);//这一句好像不能去掉,否则无法在窗体上放置该控件
Self.SetParentComponent(AOwner);//这个不知是否有用
Self.BevelInner := bvNone;
Self.BevelOuter := bvNone;
Self.Caption := '';
FButton := TColorPickerButton.Create(Self);
FButton.Parent := Self;
...
end;
destructor TColorpicker.Destroy;
begin
FButton.Free;
inherited Destroy;
end;
procedure TColorPicker.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
end;
差不多就只有这么一点点改动,但就是无法成功转换,请帮帮我,谢谢!
ActiveX(.ocx)控件。但要把VCL控件转换成ActiveX控件的话必须保证被转换
的控件是从TWinControl继承的。这个继承关系我无法改变,于是我想用一个容器
控件(就是一个TWinControl控件)包含这个从TGraphicControl继承下了的控件
做成另外一个合成控件,然后再转换成ActiveX控件。
想法到可以,但出现的问题是,当点击new->acitve-ActiveX Control的时候,总是提示:
"Control '' has no parent window"错误
我不知该如何修正这个错误,请各位大虾指教一下,谢谢!
下面是我的部分代码:
type
TDropChangingEvent = procedure (Sender: TObject
var Allowed: Boolean) of Object;
TColorPicker = class(TWinControl)
private
{ Private declarations }
FButton: TColorPickerButton;//这个就是那个从TGraphicControl继承下来的控件
...
protected
{ Protected declarations }
procedure CreateParams(var Params: TCreateParams)
override;
...
procedure Loaded
override;
public
{ Public declarations }
constructor Create(AOwner: TComponent)
override;
destructor Destroy
override;
...
published
{ Published declarations }
...
end;
implementation
constructor TColorPicker.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Self.SetParent(AOwner as TWinControl);//这一句好像不能去掉,否则无法在窗体上放置该控件
Self.SetParentComponent(AOwner);//这个不知是否有用
Self.BevelInner := bvNone;
Self.BevelOuter := bvNone;
Self.Caption := '';
FButton := TColorPickerButton.Create(Self);
FButton.Parent := Self;
...
end;
destructor TColorpicker.Destroy;
begin
FButton.Free;
inherited Destroy;
end;
procedure TColorPicker.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
end;
差不多就只有这么一点点改动,但就是无法成功转换,请帮帮我,谢谢!