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 14:22:00
 
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00258800
Message ID:
00258987
Views:
15
>>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
>


A form cannot be a member of anything excpet a formset. Including _SCREEN.
Issuing _SCREEN.AddObject("MyForm","Form") gets you an error. Checking the name property of any Form.Parent gets you an error unless the form is a member of a formset (interestingly, checking the type of the parent property returns "U" at runtime). So, in most cases, you can't go all the way up the containership hierarchy, because form's don't really have one. Although _SCREEN has a forms collection, this seems to be more of a developer's helper than a real collection, because the members of hte collection aren't really members in the classic sense, because their parent property doesn't hold a reference to _SCREEN. So Vinod, you might want to rethink your need for such a function, and think about maybe trying to get what you want with SYS(1272).
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform