我创建了一个类。
由于装配,我收到了警告。
FormInfo = class (TComponent)
private
FLeftValue : Integer;
FTopValue : Integer;
FHeightValue : Integer;
FWidthValue : Integer;
public
constructor Create(
AOwner : TComponent;
leftvalue : integer;
topvalue : integer;
heightvalue : integer;
widthvalue : integer);
protected
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
function GetChildOwner: TComponent; override;
//procedure SetParentComponent(Value : TComponent); override;
published
property LeftValue : Integer read FLeftValue write FLeftValue;
property TopValue : Integer read FTopValue write FTopValue;
property HeightValue : Integer read FHeightValue write FHeightValue;
property WidthValue : Integer read FWidthValue write FWidthValue;
end;
该方法用于进一步的表单序列化。Create 方法的实现如下:
constructor FormInfo.Create(AOwner: TComponent; leftvalue, topvalue, heightvalue,
widthvalue: integer);
begin
inherited Create(AOwner);
FLeftValue := leftvalue;
FTopValue := topvalue;
FHeightValue := heightvalue;
FWidthValue := widthvalue;
end;
由于装配,我收到了警告。
[dcc32 Warning] SerialForms.pas(17): W1010 Method 'Create' hides virtual method of base type 'TComponent'
如何在不影响应用程序功能的情况下消除此警告?
TComponent
中引入的虚拟构造函数。当窗体从 .dfm 文件中加载时,你的构造函数不会被调用。如果你的构造函数创建了任何对象,那么就会出现问题。你的设计可能是错误的。 - David HeffernanTComponent
虚拟构造函数是一个不好的主意,如果你想要有额外的构造函数,请使用另一个名称,比如CreatePos
。 - kludg