Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using BindEvent to close a form when parent closes
Message
De
13/07/2009 09:45:08
 
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:
01411903
Vues:
33
Christof --

If there was anything you didn't understand, it was because I did not fully explain how the reference on FormB was to be used.

I think that your proposed solution takes care of the problem, or at least would take care of the problem except for my intended use.

First of all, the referenced passed from FormA to FormB is actually not the form, but an object (FoxCharts) on the form.

And that reference is used on FormB to set all the various FoxCharts properties. Thus, there's a whole bunch of controls on FormB where the controlsource is actually a reference to a property in the FoxCharts object (using BindControls late).

So, it's not a matter of simply finding the reference back to FormA whenever I need it -- its referenced all over the place.

Thanks

>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.
Jim Nelson
Newbury Park, CA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform