Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Return Value from VCX
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00491003
Message ID:
00491028
Vues:
14
An approach that I've used is that when the user tries to close the form, I hide it instead of closing it. Then, when the control returns to the caller program I grab the values from the form (since it is still alive) and then I kill it. For example:
procedure CallerProgram

   oMyForm = createobject("frm_MyForm", lnParm1, ...) 
   oMyForm.Show() && control passes to oMyForm
   ? oMyForm.cRetVal1, oMyForm.cRetVal2 && control returns to CallerProgram
   oMyForm.Release()

endproc
Of course, this only works with modal forms.


>I am looking for suggestions on returning a value from a VCX based form. As you already know, a VCX form instantiated with loMyObject = createobject("frm_MyForm", lnParm1, ...) cannot be told to capture a return value (as with SCX based DO FORM WITH ... TO ...).
>
>Here are some notes regarding the issue as I currently understand it. Your feedback is appreciated.
>
>1. One solution I see is that the Client module (the class issuing the createobject instruction) passes the Supplier form class object an object reference with a Client command method to run upon completion. Thus:
>
>Client Method Code says:
>
>local loMyObject
>loMyObject = createobject("frm_MyForm",[THIS|THISFORM],"cmReturnMethod")
>
>The Supplier Form Init says:
>
>lparameters loClientObject, lcReturnMethod
>THIS.cmSetClientObject(loClientObject)
>THIS.cmSetReturnMethod(lcReturnMethod)
>
>...
>
>Later, the Supplier executes the following code as it is exiting:
>
>local loClientObject, lcReturnMethod, luReturnValue
>loClientObject = THIS.qoClientObject()
>lcReturnMethod = THIS.qcReturnMethod
>lcReturnValue = qcReturnValue()
>
>evaluate("loClientObject." + lcReturnMethod + "(" + lcReturnValue + ")")
>
>return
>
>There are advantages and disadvantages to this method:
>
>Advantages:
>
>1. It provides that the Client form retains a level of genericity in that there is a generic Client Object reference with a generic return value method.
>
>Disadvantages:
>
>1. The return method MUST exist in the calling Client class object.
>
>2. The return method of the Client is restricted to the character or string data type of the return value without complex data type management coding in either the Client or in the Supplier.
>
>I know there is probably a flaw in this thinking somewhere, but I cannot see it.
>
>Thanks in advance for you assistance.
>
>Larry
Hector Correa
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform