Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Create member in code before other members instantiate
Message
 
 
À
31/08/2009 14:36:35
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01421954
Message ID:
01421978
Vues:
89
>Just the trouble of making a proper title for this suffices to show what sort of balancing act I am trying to pull.
>
>I'm trying to create a bizobject as a property (or member, if possible) of a container, such that it would exist before the controls on the container are instantiated. This bizobj would open the tables for the controls, so it's necessary that it is created before everything else.
>
>In earlier incarnations of VFP it was simple - in the base container class you have a dummy object, a loader (in VFE it was the DeLoader, a simple label) which would do something like
>
>this.parent.addobject("oBiz", this.cBizClass)
>
>and that would do it. The label would return .f. from its init, as it wasn't needed later. Any objects added to the descendants of such a container (or form or whichever composite object) would be instantiated after this. However, this doesn't work anymore, if you have a member which is a composite object with memberclass, like a pageframe or a grid. That object gets instantiated before anything else, and even its objects' .init()s run before the objects defined in the parent class are instantiated.
>
>The only workaround against this, that I was able to cook up, was to instantiate the bizobject via a function in the expression for its property. Either of these works as the property value for the oBiz:
>
>=newobject("mybiz", "mybiz.vcx")
>
>=oFactory.Create("mybiz")
>
>The trouble is that this attempts to create the damn bizobject at design time too. As the bizobject's instantiation may rely on pieces of the framework which aren't there at design time, I only need a way to prevent this. So, my question is what is the trick to have an expression in the property which will return an object at runtime, and yet do nothing when I Modify Class mycontainer?

Instead of direct newobject do something like

=myFunc()

or try

=IIF(_VFP.StartMode = 0,null, newobject())
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform