Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do you return data from a modal Form object?
Message
De
18/03/1998 12:34:58
 
 
À
17/03/1998 14:06:48
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00085149
Message ID:
00085397
Vues:
28
>I have been trying unsuccessfully to get a return value from a form created with createobject(""). An example of what I am trying to do: display a form and allow the user to select or enter a value from then return the value selected. This is a no brainer with a standard form but I have been trying it with a form object created from a class library and cannot figure how to get the value back to the calling program.
>
>Is there a way to designate a return variable like " DO FORM x WITH varx TO varz? I have tried passing variable by reference. I have tried modeless forms and can't seem to get control back to the calling program. If I use properties in a modal form the property is destroyed prior to returning to the calling program. I have finally sunk to creating a global variable prior to creating the form and releasing it immediately after.
>
>I know there must be a better way.

Frank:

Stephen Despres's response outlines what is probably the best way solving your
problem. We use much the same method as follows:

Derive a form from the VFP form class which has a propery toParent. When you
call the form, call it with a reference to the form from which it is called:

for example, lets call the calling form oCaller and the form you are creating
oChildform. Call oChildForm from oCaller as follows:

DO FORM oChildForm WITH thisform

In the Init() event handler of oChildForm, put the following code:

LPARAMETER oParent
IF TYPE("oParent") = "O"
this.toParent = oParent
ENDIF

Now you can access any property, event handler or method of oCaller from
oChildForm with an instruction like this:

oParent. =
or
oParent.

In effect, this process eliminates any need to return a value from oChildForm
since anything in oParent you want to change can be changed from oChildForm.
You are correct that the reference to oParent will be destroyed when oChildForm
is released, but it makes no difference since any updates are already done.

An additional advantage of this logical structure is that you can nest forms
in a hierarchy and can update any property or use any event handler or method
of any form in the hierarchy. If you have three levels of forms active, you
can

oParent.oParent.

to call a method of the grandfather form.

Good luck with it.

Jim
Jim Edgar
Jurix Data Corporation
jmedgar@yahoo.com

No trees were destroyed in sending this message. However, a large number of electrons were diverted from their ordinary activities and terribly inconvenienced.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform