Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using BindEvent to close a form when parent closes
Message
 
À
13/07/2009 08:15:00
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01411652
Message ID:
01411856
Vues:
44
Hi Jim,

I'm probably misunderstanding something... As far as I understood form A is passing a reference to itself when it launches form B. Form B stores this reference to call methods on form A, or make some property changes, or perform some other action. Because form B holds a reference to form A or an object on form A, you cannot close form A. Hence, you need some sort of notification for form B so that form B can release its reference to form A when the user wants to close form A. At the same time you want to close form B, because it is dependent on form A.

So my conclusion was that it's this reference you would need to eliminate. The approach was that form B would use the reference to form A to add an object with a random name that is known by form B. This object would serve two purposes. First it would use the Windows API to close form B whenever form A closes. Since form B does not store the form reference to form A anymore, form A would release just fine, but form B would stay around. Sending the message WM_CLOSE fixes this. Secondly, because form B knows the name of the object which it has added directly to the form, form B can use code like this:
LOCAL loForm, lnForm
FOR lnForm=1 to _SCREEN.FormCount
  IF PEMSTATUS(_Screen.Form[m.lnForm],This.cName,5)
    loForm = _Screen.Form[m.lnForm]
    EXIT
  ENDIF 
ENDFOR
To get a reference to form A whenever it needs one for the call back. Hence, form B does not need to store the reference.
--
Christof
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform