Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Object Within an Object???
Message
 
À
24/01/2001 19:05:10
Spencer Redfield
Managed Healthcare Northwest, Inc.
Portland, Oregon, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00468280
Message ID:
00468503
Vues:
12
>I really need some guidance. I have just recently begun creating
>custom objects. I thought I could create a custom object that
>itself contains several custom objects.
>
>Background:
>In the Watch Window oLkUpFormObj.oCol1 appears as an object and
>nicely displays its various properties.
>However, I have been unable to access properties such as
>oLkUpFormObj.oCol1.BaseClass using the following syntax from
> 1) My program code
> 2) Command Window or
> 3) Watch Window (oLkUpFormObj.oCol1.BaseClass)
>
>Question:
>Given that the Watch Window nicely displays the properties
>I'm confused. Please see the lines with comment && <----------
>
>Can anyone here set me straight??? Thanks!
>
>

>local oLkUpFormObj
>oLkUpFormObj = createobject( "LkUpParams" )
>
>oLkUpFormObj.FormCaption = "Group.GroupName" && ControlSource
>? oLkUpFormObj.FormCaption
>
>set step on
>? oLkUpFormObj.oCol1.BaseClass && <----------
>? oLkUpFormObj.oCol1.ColSource && <----------
>return && Main
>
>
>***********************************
>DEFINE CLASS "LkUpParams" AS Custom
> FormCaption = "Lookup:"
> * Column objects
> oCol1 = createobject( "GrdCols" )
> oCol1.ColSource = "Group.GroupName" && ControlSource
>ENDDEFINE
>
>
>DEFINE CLASS "GrdCols" AS Custom
> ColSource = ""
>ENDDEFINE
>***********************************
>


Hi Spencer,

I'm not sure I understand your problem, but perhaps the following points would be helpful.

You can create a custom object within another custom object, but not through VFP's Class Designer interface. For this you would use either the AddObject or the NewObject method, e.g. as in the following example:

x = newobject('custom')
x.newobject('y', 'custom')
x.addobject('z', 'custom')
? x.y.class, x.y.baseclass, x.z.class
(displays: Custom Custom Custom)

Note that NEWOBJECT is both a function and a method (as illustrated above), which were introduced in VFP 6.0 SP3, as I recall. The nice thing about NEWOBJECT, as opposed to CREATEOBJECT/ADDOBJECT, is that it allows you to specify the class library explicitly, avoiding SET CLASSLIB hassles.

Also I'm wondering if you're confusing the generic concept of "custom" with VFP's "Custom" base class. Do you really mean to DEFINE CLASS "GrdCols" AS Custom, instead of ... AS Column? Are you trying to create a column or just a description of a column? You realize that there is no native VFP "ColSource" property, right? (A Column class object has a "ControlSource" property, but a Custom class object does not.) I hope this is of some help.

Mike
Montage

"Free at last..."
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform