Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using BindEvent to close a form when parent closes
Message
From
11/07/2009 21:51:15
 
 
To
11/07/2009 20:47:17
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01411652
Message ID:
01411653
Views:
52
>I have the following case:
>
>FormA opens FormB, passing an object reference to FormB.
>
>Thus the Init in FormB looks like this
>
>Lparam toObject
>This.oObject = toObject
>
>I would like to use BindEvent here so that closing FormA close will close FormB. (This is essential, since the object reference keeps FormA from closing..)

Don't need to use bindevents here. Instead define a custom property in FormA -- call it oFormB and set value to NULL. Then in calling FormB from FormA use the following syntax:
DO FormB Name thisform.oFormB
Now in the Destroy event method for FormA put the following:
IF !ISNULL(thisform.oFormB)
  thisform.oFormB.Release()
ENDIF
In the Destroy event of FormB put the following (this is to reset the property if the user closes FormB):
thisform.oObject.oFormB = .NULL.
I have used this a number of places without problems.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform