JavaScript Editor js editor     Web development 

Main Page

You can use UNBINDEVENTS(В ) to unbind, or detach, an event that was originally bound to a Visual FoxPro object using BINDEVENT(В ). To detach events from Component Object Model (COM) objects, use the EVENTHANDLER(В ) function. There are three versions of the syntax.

UNBINDEVENTS(oEventSource, cEvent, oEventHandler, cDelegate)
UNBINDEVENTS(hWnd [, nMessage])



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

Specifies an object reference, which can be used as the event source or event handler.

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

Specifies the object that is handling the event.

Specifies the delegate method handling the event for oEventHandler.

Specifies the integer handle of the window for which events are unbound. If hWnd is 0, all hWnds are unbound. If the nMessage parameter isn't included, then all Windows message bindings for the window handle hWnd are unbound.

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

Return Value

Numeric data type. UNBINDEVENTS(В ) returns the number of events that are unbound if unbinding succeeds. UNBINDEVENTS(В ) returns a value of 0 if no events exist for unbinding. Visual FoxPro generates an error if UNBINDEVENTS(В ) fails to unbind events that are available for unbinding.


The following table describes the ways you can use UNBINDEVENTS(В ).

Syntax Action

UNBINDEVENTS(oEventSource, cEvent, oEventHandler, cDelegate)

Unbinds a specific event from an event handler.


Unbinds all events associated with this object. This includes events that are bound to it as an event source and its delegate methods that serve as event handlers.

UNBINDEVENTS(hWnd [, nMessage])

Unbinds all or specific Windows Message (Win Msg) events.

If an event is occurring, and UNBINDEVENTS(В ) or the delegate method handling the event is called, the event and its delegate method finish running before UNBINDEVENTS(В ) unbinds the event.

You can call the AEVENTS(В ) function retrieve information about all the events and delegate methods attached to a particular object.


The following example shows how to undo a BINDEVENTS(В ) call that keeps the Class Browser positioned to the right side of the Visual FoxPro desktop, regardless of how the desktop is resized. UNBINDEVENTS(В ) detaches the Resize event of the _SCREEN system variable from the object, oHandler:

В Copy Code
PUBLIC oHandler
DO (_browser)

DEFINE CLASS myhandler AS Session
   PROCEDURE myresize
   _obrowser.left = _SCREEN.Width - _obrowser.width

See Also

JavaScript Editor js editor     Web development