Thread View: comp.lang.pascal.delphi.components.writing
3 messages
3 total messages
Started by dnote
Thu, 17 Dec 1998 00:00
Streaming a dynamic list of component references
Author: dnote
Date: Thu, 17 Dec 1998 00:00
Date: Thu, 17 Dec 1998 00:00
33 lines
1977 bytes
1977 bytes
To all Delphi guru's
I want my component to store a list of component references (on the same or
linked form). To do this the component contains a custom made list class in
which you can add, delete and query the component references. This list
class is derived from TComponent. A pretty silly example of such a component
could be: a TEdit control which stores the references to multiple TFields in
order to react to their events.
Example code:
TMyEdit = class(TCustomEdit) private mFields: TFieldList; ... published {
references are edited through a property editor, the property write specifier
is used to allow delphi-form-streaming to take place. } property Fields:
TFieldList read mFields write SetFields; end;
TFieldList = class(TComponent)
private
mItems: TList; { of TField }
...
public
procedure Add(aField: TField);
...
property Items[aIndex: integer]: TField read GetItems;
end;
Any suggestions on how to do this (an example DefineProperty, Read and Write
sheme would be great)?
Dave de Jong - Dnote Software
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Re: Streaming a dynamic list of component references
Author: Krzysztof Borys (Bask)
Date: Fri, 18 Dec 1998 00:00
Date: Fri, 18 Dec 1998 00:00
37 lines
2150 bytes
2150 bytes
On Thu, 17 Dec 1998 13:13:38 GMT, dnote@my-dejanews.com wrote:
>To all Delphi guru's
>
>I want my component to store a list of component references (on the same or
>linked form). To do this the component contains a custom made list class in
>which you can add, delete and query the component references. This list
>class is derived from TComponent. A pretty silly example of such a component
>could be: a TEdit control which stores the references to multiple TFields in
>order to react to their events.
>
>Example code:
>
>TMyEdit = class(TCustomEdit) private mFields: TFieldList; ... published {
>references are edited through a property editor, the property write specifier
>is used to allow delphi-form-streaming to take place. } property Fields:
>TFieldList read mFields write SetFields; end;
>
>TFieldList = class(TComponent)
>private
> mItems: TList; { of TField }
> ...
>public
> procedure Add(aField: TField);
> ...
> property Items[aIndex: integer]: TField read GetItems;
>end;
>
>Any suggestions on how to do this (an example DefineProperty, Read and Write
>sheme would be great)?
Try looking into TCollection from Classes unit or TStrings - it can bring some
ideas. Another way is to use TCollection - you must create class which derives
from TCollectionItem and has a property with TComponent type IMHO this could be
better.
UIN:3620584 Bask
mailto:bask@kis.p.lodz.pl
Re: Streaming a dynamic list of component references
Author: dnote
Date: Fri, 18 Dec 1998 00:00
Date: Fri, 18 Dec 1998 00:00
16 lines
1545 bytes
1545 bytes
> Try looking into TCollection from Classes unit or TStrings - it can bring some > ideas. Another way is to use TCollection - you must create class which derives > from TCollectionItem and has a property with TComponent type IMHO this could be > better. The problem is that TCollection and TStrings do not store component references. I need some mechanism in Delphi with which I can resolve component name into component objects. It is not an option to uses TCollection itself, since I need to store references to TComponents like TFields. Dave -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads