Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Create member in code before other members instantiate
Message
De
04/09/2009 12:53:47
 
 
À
31/08/2009 14:36:35
Dragan Nedeljkovich (En ligne)
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:
01422694
Vues:
251
I wonder if you can solve all your problems via THIS_ACCESS.

This is late binding as in any access method, but you could set controlsources to eg This.Parent.oBiz.alias and that would trigger oBiz to be created before the controlsource is set.

I'm thinking of the following THIS_ACCESS methodology in the container class:
Lparameters        tcMember

Local              luValue, lcMember
lcMember = "THIS."+tcMember

If Type(lcMember)#"U"
   * name convention: names of object properties must always begin with "O"
   If Upper(Left(tcMember,1))=="O" And Vartype(Getpem(This,tcMember))=="C" ;
         AND Left(Getpem(This,tcMember),2)=="<-"

      Try
         luValue = Evaluate(Substr(Getpem(This,tcMember),3))
         Store luValue To (lcMember)
      Catch
         * debug message to the developer using this:
         Debugout "Error in ", Sys(16), ": The expression of member ", tcMember, ;
            " could not be evaluated or the result could not be stored."
      Endtry
   Endif
Endif
Return This
It works this way: You define a property oBiz in your container and set it's value to "<-expression", the method above will evaluate the expression. So a simple expression could be "<-Createobject('bizclass')".

The idea you already used with a factory has the problem of the datasession, but that could also be solved by passing in THISFORM or THIS to the factory as an toParent parameter and the factory could use toParent.Addobject() to instanciate some class and voila, it's part of the form's session, not of the session the factory is in.

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

Click here to load this message in the networking platform