Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I have a true BASE class for everything?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
01375878
Message ID:
01376918
Vues:
21
>As you had probably hoped, you CAN do this in VFP. You can do almost anything in this wonderful language and by god, this too is doable.
>
>Here is what you do:
>
>1. Create a custom class with the properties and methods you would like to have added to all your controls. We will call this your "Decorator" class.
>
>2. In each of your base control classes, add the following to your init event:
>
>this.addproperty("decorator", createobject("myDecorator"))
>
>3. In each of your base control classes, add the following method and call it THIS_ACCESS.
>
>PROCEDURE THIS_ACCESS
>Lparameters MemberName
>
>If !PEMSTATUS(this, m.MemberName, 5)
> Return this.decorator
>Endif
>
>Return this
>ENDPROC
>
>I hope this helps. You can now use the methods and properties as if they are part of the control class. If there is a conflicting member name (e.g. init) then the original control class method/property is used. You can change this behavior by using more IF PEMSTATUS statements in THIS_ACCESS.

I'm not sure I follow. Which classes are you describing in step 2? -- the VFP base classes (Textbox, Grid, etc.) or user-defined classes derived from them? You cannot modify the VFP base classes so I don't understand how you can make them inherit from a universal base class, as Matt asked.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform