Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BindEvent Gotcha - Fires Twice
Message
From
05/10/2006 13:28:38
 
 
To
05/10/2006 08:50:59
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01158912
Message ID:
01159783
Views:
20
>
>Not agree.
>
>Destroy happen when the object it is released.
>With Bindevent is not possible to known if the object is released.

Just try this: create a new empty form, add a TestDestroyBind method, then:

Init:
Bindevent(This, [Destroy],This, [TestDestroyBind])
TestDestroyBind:
Messagebox([Destroy!])
Now run the form, then close it with the X close button, the event handler did not fire.

Open the form, add this:

Destroy:
*!* Now Bindevent will work
Run the form again, now the event handler fires.

I understand that when an event fires, first your event code gets executed, then the default VFP event processing of the event gets executed.

Why would the destroy event be any different than other form events? The help file says of the Destroy event: "Occurs when an object is released"

"When" means before or after? Lets see, change Messagebox([Destroy!]) to Messagebox(ThisForm.Name).

It works, the form is still there when the event hanlder fires.

So i would say this is a bug, VFP should either never fire the event handler of the Destroy event, or it should always fire the event handler of the Destroy event.

But it should not base it's decision on the presence of absence of user code (or user comments) in the event.

Carlos
Previous
Reply
Map
View

Click here to load this message in the networking platform