Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Protected property is italics
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00608655
Message ID:
00608803
Vues:
18
Dave,

PROTECTED means that only the class or it's subclasses have access to the PEM. It means that it can not be accessed from outside of the class itself:
oX = createobject( "x1" )
ox.PrintIt() && works ok because the class is doing the access
? ox.MyProperty && errors out

define class x1 as Custom
protected MyProperty

function Init()
this.MyProperty = 1
endfunc

function PrintIt()
? this.MyProperty
endfunc
enddefine
When you drop your class on the form you are in effect creating a subclass and you can override PEMs. Any code you add to this instance can access the protected property. But code in the form or other objects on the form don't have access to it.

>Any protected properties of classes that I drag onto a form show as italics in the property sheet and therefore, are non-editable on the form. For example, I put a subclass of commandbutton on a form with a protected property called MyProperty. If I put code in a method of that class on the form that tries to access the property, I get an error saying the property is not found. For example, I add
>
>This.Myproperty ="New Val"
>
>in the click method of the command button on the form. "This" would refer to the command button object which I would expect would be able to see the protected property, but it doesn't.
>
>Why does code in an instance of my class on a form execute as a client to my class instead of a subclass?
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform