Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BindEvent()
Message
From
26/05/2017 04:12:30
 
 
To
25/05/2017 23:11:59
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
01651515
Message ID:
01651521
Views:
69
>Hello all.
>
>Is there examples of how to use BindEvent() functon?
>I know the VFP help has one example. I would like to see a few more.
>
>thanks in advance....

Most examples show how to bind one event to another event. For instance you can bind the click event of an object on the form to a method:

BINDEVENT(THISFORM.cmdSave,"Click",THISFORM,"DoSave")

The advantage of doing that is that there is no code in the click event of the button. That means you can drop the button from the form and replace it with another object (maybe a Hyperlink) and you don't need to retype the code in the click or other events of that control (but you need to keep the same name).

But even more importantly you can create the button on the fly, and you can let the form (or better a controller object) do the binding:
THISFORM.Newobject("cmdSave","Commandbutton")
BINDEVENT(THIS.cmdSave,"Click",THISFORM,"DoSave")

Of course this is a very trivial exercise, but you get most out of bindevent when you allow multiple listeners subscribe to an event. You can create an eventhandler were any object can publish or subscribe to any other event. To accomplish that you need a global collection object where you can add objects that regulate the events. By calling those events they can be forwarded to any number of listeners who have subscribed to these events.
Christian Isberner
Software Consultant
Previous
Reply
Map
View

Click here to load this message in the networking platform