Article View: comp.lang.pascal.delphi.misc
Article #503TComponent Sub-Property
From: Pieter A. Myburgh
Date: Thu, 10 Jul 1997 00:00
Date: Thu, 10 Jul 1997 00:00
61 lines
2247 bytes
2247 bytes
Hi there,
Does anybody know how to make a class derived from TComponent a
persistent sub-property of another component using the TClassProperty
property editor? If you declare a class derived from TPersistent, e.g.
TMyClass = class(TPersistent)
end;
and another class which has the above class as a public property
TOtherClass = class(TComponent)
public
property MyProp: TMyClass read ...
end;
then MyProp expands in the object inspector showing the sub-properties
whether you register the property editor or not:
RegisterPropertyEditor(TypeInfo(TMyClass), TOtherClass, 'MyProp',
TClassProperty);
However, if you declare TMyClass to be a descendant of TComponent
instead of TPersistent, MyProp expands correctly in the object inspector
showing the sub-properties if you register the property editor as above,
but none of the sub-properties of MyProp is saved to the stream, even
though TComponent is derived from TPersistent.
Have anybody managed to get this working? I also tried to define the
property by overriding the DefineProperties method of OtherClass, but it
doesn't seem to work:
procedure TOtherClass.ReadProperties(Reader: TReader);
begin
Reader.ReadComponent(Hstmt);
end;
procedure TOtherClass.WriteProperties(Writer: TWriter);
begin
Writer.WriteComponent(Hstmt);
end;
procedure TOtherClass.DefineProperties(Filer: TFiler);
begin
inherited DefineProperties(Filer);
Filer.DefineProperty('MyProp', ReadProperties, WriteProperties, True);
end;
Any help is appreciated!
Pieter
DataSoft
ODBCExpress at http://www.odbcexpress.com
ADAM at http://www.adam.co.za
GhostWare at http://www.ghostware.com
Technical Details
Message-ID:
<33C4FC33.590CCA66@iafrica.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 112b07,92d3ac223f794f2c,start X-Google-Attributes: gid112b07,public X-Google-Thread: 10baee,92d3ac223f794f2c,start X-Google-Attributes: gid10baee,public From: "Pieter A. Myburgh" <pieterm@iafrica.com> Subject: TComponent Sub-Property Date: 1997/07/10 Message-ID: <33C4FC33.590CCA66@iafrica.com> X-Deja-AN: 255969036 X-Priority: 3 (Normal) Organization: DataSoft Reply-To: pieterm@iafrica.com Newsgroups: comp.lang.pascal.delphi.misc,borland.public.delphi.vcl.components.writing