Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to Get the Top Most Parent Class ??
Message
From
29/08/1999 10:22:54
 
 
To
29/08/1999 02:12:58
Vinod Parwani
United Creations L.L.C.
Ad-Dulayl, Jordan
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00258800
Message ID:
00258963
Views:
13
>>>How to Get the Top Most Parent Class ?? i.e.
>>>
>>>Suppose
>>>
>>>oPara=Thisform.pageframe.page1.textbox
>>>
>>>Then it shud return Thisform
>>>
>>>Same way if
>>>
>>>oPara=_screen.Myobject
>>>
>>>Then it shud return _screen...
>>
>>There's a problem here; there may be a reference at an even higher level that can't be found this way. Let's take the case where you think that thisform would be correct. Depending on how you've instantiated things, you might have an even higher level of containership (eg, this could be part of a FormSet, or the form might be instantiated from another form (until VFP6 SP3, people who needed in-proc COM servers who needed a Private datasession derived their class from the base class Form, and the form reference might be embedded in the property of another form or some other object...) and if you've got a Form and the VFP main screen, it's contained in both the _screenoForms collection and the _VFP.Forms collection. How do you resolve the following example:
>>
>>DEFINE CLASS Foo AS FORM
>>*
>>* stuff
>>*
>>ENDDEFINE
>>
>>_SCREEN.AddObject('Foo','Foo') && we've instantiated Foo as part of _screen
>>
>>Within the Foo object, it can resolve itself back to Thisform; outside Foo, it resolves via _screen.Foo. if Foo can be made visisble, it may be referencable as _VFP.ActiveForm when it's active.
>>
>>Clearly, the runtime reference thisform is never correct, since it's only applicable when the form is active and in scope. If something is contained in a member property or collection, it may be very difficult to determine that from within the object itself. And in the case of forms especially, there may ewell be multiple, completely correct top-level references, both at the same time (_VFP.Forms and _Screen.Forms, which is the correct one to derive to? Application.Forms? And if you've created an external reference by CREATEOBJ() of a CLASS or the NAME clause of DO FORM, what's right?)
>>
>>I think the simplest way to do this is to traverse the Object's .parent property tree recursively. At the top that can be resolved uniformly, the .Parent will either be NULL or undefined.
>>
>>IOW, if TYPE('oObject.Parent') = 'O' AND NOT ISNULL(oObject.Parent), then you need to check it recursively as well. You need to get back something meaningful to the current reference point. The stringified name (I couldn't think of a good word; suggestions?) isn't going to give you a good clue, since the reference point for the string may be an intermediate, or may not be in scope outside of the current context; there's nothing wrong with assigning an object reference to an intermediate object point (eg, thisform.pageframe.page.container.control has valid objects up the food chain at a minimum, and maybe up from thisform as well.) And in the case of contained object references, you can move up the chain in several ways.
>>
>>IAC, you'll get back an object reference and not a string.
>
>Thnks for the detailed reply, which has given me lot of new info...
>
>I'll use the object.parent and go back upwards...

You might also want to look at SYS(1272)
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform