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(oEventObject) |
UNBINDEVENTS(hWnd [, nMessage]) |
Parameters
- oEventSource
- Specifies the event source, which must be a valid Visual FoxPro object.
- oEventObject
- Specifies an object reference, which can be used as the event source or event handler.
- cEvent
- Specifies the name of the event, method, or property you want to unbind.
- oEventHandler
- Specifies the object that is handling the event.
- cDelegate
- Specifies the delegate method handling the event for oEventHandler.
- hWnd
- 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.
- nMessage
- 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.
Remarks
The following table describes the ways you can use UNBINDEVENTS(В ).
Syntax | Action |
---|---|
|
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. |
|
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.
Example
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 oHandler=NEWOBJECT("myhandler") DO (_browser) BINDEVENT(_SCREEN,"Resize",oHandler,"myresize") UNBINDEVENTS(_SCREEN,"Resize",oHandler,"myresize") DEFINE CLASS myhandler AS Session PROCEDURE myresize _obrowser.left = _SCREEN.Width - _obrowser.width RETURN ENDDEFINE |
See Also
Reference
SYS(2325) - WCLIENTWINDOW from Visual FoxPro WHANDLESYS(2326) - WHANDLE from a Window's hWnd
SYS(2327) - Window's hWnd from Visual FoxPro WHANDLE
Other Resources
FunctionsEvent Binding for Visual FoxPro Objects
AEVENTS( ) Function
BINDEVENT(В ) Function
EVENTHANDLER( ) Function
RAISEEVENT(В ) Function