BINDEVENT( ) Function

Provides ability to execute user code (an object method) when an event occurs.

With the first form of the syntax below, you can use BINDEVENT( ) to bind events, properties, or methods from native Visual FoxPro objects to other Visual FoxPro objects.

With the second syntax variation below, you can bind to Windows Message (Win Msg) events.

NoteNote

If you want to bind to events from Component Object Model (COM) objects, use the EVENTHANDLER( ) function.

BINDEVENT(oEventSource, cEvent, oEventHandler, cDelegate [, nFlags])
BINDEVENT(hWnd | 0, nMessage, oEventHandler, cDelegate [, nFlags])

Parameters

oEventSource

Specifies the event source, which must be a valid Visual FoxPro object.

hWnd

Specifies the integer handle of the window that receives Windows Messages.

If a value of 0 is passed, the specified event (nMessage) is trapped for all windows.

You can use the hWnd Property (Visual FoxPro) to bind Windows Messages (events) received by _VFP, _SCREEN and instantiated form. ActiveX controls also have an hWnd property

cEvent

Specifies the name of the event, method, or property you want to bind.

nMessage

Specifies a valid Windows message that is trapped. See MSDN (the Microsoft Developer Network) for information about Windows messages.

oEventHandler

Specifies the object, which must be a valid Visual FoxPro object, handling the event.

cDelegate

Specifies the method, or "delegate", that handles the event for oEventHandler.

The delegate method must have the same parameters as the event specified in cEvent. You can call the AEVENTS( ) function to retrieve an object reference to the event source. If the delegate method does not have enough parameters to handle those passed by the event, Visual FoxPro generates an error.

When trapping for Windows Message (Win Msg) events, the cDelegate method must include a PARAMETERS statement to accept four parameters that get passed to the method. The format of the parameters is identical to the format of the Windows WindowProc function. See MSDN (the Microsoft Developer Network) for information about the Windows WindowProc function. The method must return an integer value.

nFlags

Specifies an additive bit flag you can set for the event binding operation.

The nFlags parameter is ignored when a Windows message event binding is created.

nFlags Bits Event Type Description

0

000

FoxPro object

Call delegate code before event code. (Default)

1

001

FoxPro object

Call event code before delegate code.

2

010

FoxPro object

Do not trigger event (call delegate code) by simple method call.

3

011

FoxPro object

Call event code before delegate code. Do not trigger event (call delegate code) when simple method calls occur.

4

100

Windows Message

Prevents recursion of similar events while user event code is executing.

The following table shows whether an event is raised when Bit 1 is off or on.

Event trigger OFF (Default) ON

Interactive

YES

YES

Programmatic

YES

NO

RAISEEVENT( )

YES

YES

Expand imageReturn Value

Expand imageRemarks

Expand imageExample

Expand imageSee Also


© , 1996-2020 • Updated: 11/10/20
Comment or report problem with topic