Index
2005-10-24 15:25Grigore Dolghin : BindEvent and RaiseEvent
2005-10-24 15:41Matthew Jarvis : Re: BindEvent and RaiseEvent
2005-10-24 16:29allen : RE: BindEvent and RaiseEvent
2005-10-24 17:34Johnson, Fletcher S (N-Superior Technical Resources Inc.): RE: BindEvent and RaiseEvent
2005-10-24 18:59Johnson, Fletcher S (N-Superior Technical Resources Inc.): RE: BindEvent and RaiseEvent
2005-10-24 19:37Eugene Vital : Re: BindEvent and RaiseEvent
2005-10-25 01:06Bill Arnold : RE: BindEvent and RaiseEvent
2005-10-25 01:24Sietse Wijnker : RE: BindEvent and RaiseEvent
2005-10-25 01:28Sietse Wijnker : RE: BindEvent and RaiseEvent
2005-10-25 02:14Bill Arnold : RE: BindEvent and RaiseEvent
Back to top
BindEvent and RaiseEvent

Author: Grigore Dolghin

Posted: 2005-10-24 15:25:47   Link

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.

©2005 Grigore Dolghin
Back to top
Re: BindEvent and RaiseEvent

Author: Matthew Jarvis

Posted: 2005-10-24 15:41:02   Link

Grigore Dolghin wrote:

> <snipped>

> 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.

>

BindEvent supports both Early and Late binding - not too sure about what

RaiseEvent does.

Matthew S. Jarvis

IT Manager

Bike Friday - "Performance that Packs."

www.bikefriday.com

541/687-0487 x140

mattj@bikefriday.com

©2005 Matthew Jarvis
Back to top
RE: BindEvent and RaiseEvent

Author: allen

Posted: 2005-10-24 16:29:24   Link

Maybe I got this wrong. I have played with binevents and windows api but not

raiseevents

If I have it right Bindevents causes a method to action when the event its

bound to occurs where raiseevents causes an event to take place.

Allen

-----Original Message-----

From: profoxtech-bounces@leafe.com [mailto:profoxtech-bounces@leafe.com] On

Behalf Of Matthew Jarvis

Sent: 24 October 2005 21:41

To: profoxtech@leafe.com

Subject: Re: BindEvent and RaiseEvent

Grigore Dolghin wrote:

> <snipped>

> 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.

>

BindEvent supports both Early and Late binding - not too sure about what

RaiseEvent does.

©2005 allen
Back to top
RE: BindEvent and RaiseEvent

Author: Johnson, Fletcher S (N-Superior Technical Resources Inc.)

Posted: 2005-10-24 17:34:17   Link

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]

©2005 Johnson, Fletcher S (N-Superior Technical Resources Inc.)
Back to top
RE: BindEvent and RaiseEvent

Author: Johnson, Fletcher S (N-Superior Technical Resources Inc.)

Posted: 2005-10-24 18:59:30   Link

Sietse,

I guess my wording was poor. I was trying to point out that calling the

click method is not the same as clicking on the button.

And I forgot about the fact that the code in the method still fires,

even if I bind the event to a different method. Thanks for making that

clear.

Let me try explaining the difference again and let me know if this is

better.

I can bind an event to a method. The example is that if I bind the

doubleClick event for all the columns, headers, and text1 items in a

grid to the grids doubleClick method, then I don't need to have any code

in doubleClick for those items.

However, if I have some code that is supposed to call the doubleClick

method of a textbox in that grid, I couldn't just call

grid1.column1.text1.doubleClick() because there is no code there.

I could use RaiseEvent to raise the doubleclick event of that textbox

which would then result in the doubleclick code in the grid firing (just

as it would if the user doubleclicked on it.)

How does this sound?

Fletcher

-----Original Message-----

From: profox-bounces@leafe.com [mailto:profox-bounces@leafe.com] On

Behalf Of Sietse Wijnker

Sent: Monday, October 24, 2005 4:21 PM

To: profox@leafe.com

Subject: RE: BindEvent and RaiseEvent

> -----Original Message-----

> From: profoxtech-bounces@leafe.com

> [mailto:profoxtech-bounces@leafe.com] On Behalf Of Johnson,

> Fletcher S (N-Superior Technical Resources Inc.)

> Sent: dinsdag 25 oktober 2005 0:34

> To: profoxtech@leafe.com

> Subject: RE: BindEvent and RaiseEvent

>

> 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.

Actually, The click event you can edit in the code editor is the Click

method. The Click event is handled internally in VFP and isn't open for

editing. When you bind another method to the click event you can set the

bindlevel using the earlier mentioned parameter. This way you can set it

at event-level or at the codebehind level (click-method). The raiseevent

actually triggers the internal click-event. The commandbtn.Click() call

only fires the codebehind method. Actually you can

>

> 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.

You don't change the code that was originally executed. The original

click-method is still fired. The bound method is fired prior or

afterwards (depening on, again, parameters in the bindevent-call). So it

doesn't override code already in the cmdbutton.click()!! The

Grid-header, textbox and other classes used in the grid are indeed

especially a good use of the bindevent. In the Init of the grid you can

bind all the controls dblClick events to the grid's custom

ControlDblClick() method and you'll never have to write code in any of

the controls used in the grid to handle doubleclicking. Good example!

Regards,

Sietse Wijnker

[excessive quoting removed by server]

©2005 Johnson, Fletcher S (N-Superior Technical Resources Inc.)
Back to top
Re: BindEvent and RaiseEvent

Author: Eugene Vital

Posted: 2005-10-24 19:37:12   Link

Johnson, Fletcher S (N-Superior Technical Resources Inc.) wrote:

>Bindevents is also limited to native VFP objects/classes

>

>

I wanted to point out 2 things.

In VFP 9 you can bind events to Windows Messages

You can use the EventHandler() function to bind COM server events

to interface methods of VFP objects

--

It's all relative

Eugene Vital

EGN-Tech www.egntech.com

©2005 Eugene Vital
Back to top
RE: BindEvent and RaiseEvent

Author: Bill Arnold

Posted: 2005-10-25 01:06:53   Link

Coming in late ... Looks like the original question was answered (and

then some!)

I'd just like to add my impression that Bindevents is a 'megatool'. In

the archives you'll find a discussion where I mentioned now being able

to add a single line of code to INIT for each new grid/class to add

column sorting to every column in the grid in one stroke, uniformly and

with assurance that later changes to the grid will not mess this feature

up in any way.

I think that, like every other tool in our bag, we need to know when to

use it and when not to. One concern I feel is that we also need to pay

special attention to documenting the use bindevents so we don't drive

Joe Maintainer nuts ("where the heck did THAT come from?").

Okay, just thought of this, but maybe similar to using an 'object

factory' to create objects, a 'bindevents factory' can handle

bindevents. The object factory (if I'm using the term correctly)

maintains a cursor of currently active objects. Similarly, the

bindevents factory can maintain a cursor all active bindevents, and that

way Joe can have diagnostics showing all current objects and active

bindevents (viewable in a separate diags screen, of course). Be a good

reminder they are active in the system.

Bill

> 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]

©2005 Bill Arnold
Back to top
RE: BindEvent and RaiseEvent

Author: Sietse Wijnker

Posted: 2005-10-25 01:24:23   Link

Hi Fletcher,

Better but not quite there yet;-)

> However, if I have some code that is supposed to call the

> doubleClick method of a textbox in that grid, I couldn't just call

> grid1.column1.text1.doubleClick() because there is no code there.

>

> I could use RaiseEvent to raise the doubleclick event of that

> textbox which would then result in the doubleclick code in

> the grid firing (just as it would if the user doubleclicked on it.)

This depends on the binding params. If you set it up to bind it at the

code-behind level (default), then calling just the

grid1.column1.text1.doubleClick() will do the trick triggering the grid's

doubleclick. If you bound it at event-level you indeed have to use the

RaiseEvent() to trigger the grid's dblClick.

Regards,

Sietse

©2005 Sietse Wijnker
Back to top
RE: BindEvent and RaiseEvent

Author: Sietse Wijnker

Posted: 2005-10-25 01:28:43   Link

Hey Bill,

> Okay, just thought of this, but maybe similar to using an

> 'object factory' to create objects, a 'bindevents factory'

> can handle bindevents. The object factory (if I'm using the

> term correctly) maintains a cursor of currently active

> objects. Similarly, the bindevents factory can maintain a

> cursor all active bindevents, and that way Joe can have

> diagnostics showing all current objects and active bindevents

> (viewable in a separate diags screen, of course). Be a good

> reminder they are active in the system.

>

You off-course can provide in a tool thet uses the Sys(1270) and the

AEVENTS(laBind, oObject) to provide Joe in a method of 'reading' which

methods are delegated to others.

Sietse

©2005 Sietse Wijnker
Back to top
RE: BindEvent and RaiseEvent

Author: Bill Arnold

Posted: 2005-10-25 02:14:35   Link

> > Okay, just thought of this, but maybe similar to using an

> > 'object factory' to create objects, a 'bindevents factory'

> > can handle bindevents. The object factory (if I'm using the

> > term correctly) maintains a cursor of currently active

> > objects. Similarly, the bindevents factory can maintain a

> > cursor all active bindevents, and that way Joe can have

> > diagnostics showing all current objects and active bindevents

> > (viewable in a separate diags screen, of course). Be a good

> > reminder they are active in the system.

> >

> You off-course can provide in a tool thet uses the Sys(1270)

> and the AEVENTS(laBind, oObject) to provide Joe in a method

> of 'reading' which methods are delegated to others.

Hi Sietse,

True, but by using a 'control point' other information can be collected

as well, such as who issued the bindevents, when, and perhaps even why.

Bill

> Sietse

>

©2005 Bill Arnold