Author: Johnson, Fletcher S (N-Superior Technical Resources Inc.)
Posted: 2005-10-24 at 17:34:17
Grigore,
Warning, this concept can be rather mind bending. But if you choose to
continue, you do so at your own risk.....
Consider this. If you click on a button on a form, is that the same as
calling the forms click method?
If you turn on event tracking, you will see that not only does the click
event fire, but also the mouse enter, mouse over, mouse move, mouse
down, and mouse up (I am going from memory, forgive me if I made a
mistake) events fire.
Bindevents is used to change the method associated with an event. By
default, the click method of a button will call that buttons "Click"
method. You can use BindEvents to change it so some other code is
executed. This can be especially useful when it is hard to set default
methods (say for a grids column header, textbox, column, etc) in parent
classes.
Bindevents is also limited to native VFP objects/classes
RaiseEvents is used to actually raise the event. If you look at the
online help, you will find the following example:
Activating a form or using Form1.Show triggers the Activate event for
the form. However, calling the Activate event directly using a call such
as Form1.Activate does not trigger the Activate event. The following
example shows how you can use RAISEEVENT( ) to trigger the Activate
event:
RAISEEVENT( Form1, "Activate" )
You might also look at the foxWiki
<http://fox.wikis.com/wc.dll?Wiki~EventBindingSample> for some
additional information on this.
I believe you can also use Raiseevents to raise events in other COM
automation resources - but I can't quite recall for sure.
I haven't done much with this lately, I am sure that Nancy, Ted, Ed, and
a few others will chime in with something more clear.
Take care,
Fletcher
-----Original Message-----
From: profox-bounces@leafe.com [mailto:profox-bounces@leafe.com] On
Behalf Of Grigore Dolghin
Sent: Monday, October 24, 2005 1:26 PM
To: profox@leafe.com
Subject: BindEvent and RaiseEvent
Hello, everyone
I think I am missing the phylosophy here. What's the difference between
these two? As far as I can understand, I can raise an event from any
method;
in other words, RaiseEvent can cause a custom method to behave like an
event - to get executed when something happens. Well; let's assume in a
button Click() snippet I enter a RaiseEvent() and raise a custom method
as
event. The same can be achieved by binding through BindEvent my custom
method and button's Click(). Also, I can simply call my custom method
from
button Click().
What's the difference? what can be done thru RaiseEvent and cannot be
done
thru BindEvent()? a sample would be greatly appreciated. I don't
understand
what I am missing, although I am obviusly missing something.
Thank you.
[excessive quoting removed by server]