Solved

Set the owner part II

Posted on 2004-10-10
6
183 Views
Last Modified: 2013-11-23
My VCL have a TCollection property. The structure is:

TgnCollection1 = class(TCollection)
....
constructor TgnCollection1.Create(AOwner: TMyVCL);
begin
  inherited Create(TgnCollectionItem1);
...


TgnCollectionItem1 = class(TCollectionItem)
...
inherited Create(Collection); // in my case Collection1
FCollection2 := TgnCollection2.Create(Self);
...

in CollectionItem1 I have a TCollection property, too ( collection in Collection )

TgnCollection2= class(TCollection)
...
inherited Create(TgnCollectionItem2);
...
TgnCollectionItem2 = class(TCollectionItem)
...
inherited Create(Collection); // in my case Collection2
...

Now my problem.

Starting from myVCL I can get the Owner untill the first TCollectionItem with:

FOwner:=Self.Collection.Owner;

How to get the Owner to the last TCollectionItem ?

I wish to know the Owner ( Self .. myVCL ) into TCollectionItem2.




0
Comment
Question by:ginsonic
  • 3
6 Comments
 
LVL 7

Expert Comment

by:LRHGuy
ID: 12272048
If SELF is a collectionitem, and you want the collection of that item:

Self.Collection

Now, you want the first item in that collection:

Self.Collection.Items[0]

And that item has it's own collection:

Self.Collection.Items[0].Collection

Which, if that collection also has an owner, should be:

Self.Collection.Items[0].Collection.Owner

Is that what you want?
0
 
LVL 9

Author Comment

by:ginsonic
ID: 12273842
Dont't work :(
0
 
LVL 9

Author Comment

by:ginsonic
ID: 12273844
Self is now the second TCollectionItem
0
 
LVL 9

Author Comment

by:ginsonic
ID: 12273868
Done myself. I added a property to the first CollectionItem where I store the owner. Then just read with

  TgnCollectionItem1(Self.Collection.Owner).Owner;

Thanks!
0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 12321181
Question answered by asker or dialog valuable.
Closed, 500 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question