Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Defining Methods in Classes for Objects Added at Runtime
Message
De
22/02/2006 17:02:45
 
 
À
18/02/2006 15:21:34
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01096949
Message ID:
01098280
Vues:
16
> There is a world of difference, it would seem, in VFP between ADD OBJECT at the class level,
>and .AddObject() at the implementation level. ADD OBJECT does indeed expose the methods of an
>the object being added.

Well, .AddObject() is done at runtime. ADD OBJECT at design time. That's why you can add code to objects added with ADD OBJECT and can not do so with objects added with .AddObject(). With .Addobject() you add an instance of the class and you must define code in that class definition.

As I also said in another of your threads you should base own controls on the "control" base class. This is a container hiding it's inner structure, even if inner objects and properties are public. So by default only properties and methods defined at the control level are public. Objects added at design and/or runtime remain protected.

So have a go at this:
create class myControl of "d:\test.vcx" as control
Now add a label control and in the label add
method MouseEnter:
this.fontbold = .t.
method MouseLeave:
this.fontbold = .f.
Save your control and instanciate it with:
_screen.newobject("mylabel","mycontrol","d:\test.vcx")
_screen.mylabel.Visible = .t.
And now inspect the visibility with intellisense:
_screen.mylabel.label1.
Every property and method/event of label1 is protected.

And even though _screen.mylabel.label1 seems visible by intellisense
? _screen.mylabel.label1
raises the error "property label1 was not found". While
? _screen.mylabel
prints (Object)

Bye, Olaf.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform