Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Child object accessing property on parent object?
Message
From
18/08/2009 01:27:32
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
18/08/2009 00:43:18
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01418582
Message ID:
01418584
Views:
73
Yes the "child" has no parent, because its not an object of the parent, its just a object bound to a property.

How do you instantiate your child? What class is parent, what class is child?

if parent can not contain child (let say a form in a form) then you might forward a reference of the parent to the child. You can do that in the init.

Remember that you have to clean up the child before the parent, or you will get a hanging reference.

If the parent can contain the child don't use a property, instantiate via ADDOBJECT. Then the "child" has a parent.

Agnes

>I have an object (oParent), which has a property named oChild. Once oChild is instantiated, it needs to read some properties from the parent to do his work.
>
>I can't just pass in the values as params to the child in his init() because the parent property values may change during the workflow, and the passed values will then be incorrect.
>
>I can't say "this.parent" from the child, because it just doesn't work.
>
>The only remedy I can think of is to pass a reference to the oParent into the oChild, then oChild will need to store that in a oParent property on himself so he can work from there to get the property values he needs. That just seems unnecessarily complicated in some regards, but that's the only way I can see it working.
>
>Any other ideas?
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Reply
Map
View

Click here to load this message in the networking platform