Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing Params in Form Classes
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
01216407
Message ID:
01216672
Vues:
13
Hi Tommy.

>>The most general solution is to pass FormA to FormB, eg. Thisform.oFormB=createobject("FormB",Thisform). Now both forms know of each other and can work together.

The easiest way to accomplish the general case of FormA calling FormB to perform some task and returning a value back to FormA is:

- Make FormB modal or call its Show method as Show(1) so it runs as a modal form.

- There's no need to store a reference to FormB in a FormA property; since FormB is called modally, the FormA method calling FormB doesn't terminate until FormB closes, so using a variable to hold the reference is fine.

- In FormB, have an OK button with code like this in its Click method:
Thisform.SomeProperty = TheReturnValue
Thisform.Hide()
Have a Cancel button with Thisform.Release() in its Click method. If the user clicks Cancel, FormB is released. If the user clicks OK, FormB is hidden and control returns to FormA, which can then check FormB.SomeProperty for the return value. Example code in FormA:
loForm = createobject('FormB')
loForm.Show(1)
if vartype(loForm) = 'O'
  lcReturn = loForm.SomeProperty
else
* user cancelled FormB
endif
Doug
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform