Aracılığıyla paylaş


UNBINDEVENTS( ) Function

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

UNBINDEVENTS(oEventSource, cEvent, oEventHandler, cDelegate)

Unbinds a specific event from an event handler.

UNBINDEVENTS(oEventObject)

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.

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:

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

Concepts

Event Binding for Visual FoxPro Objects

Reference

AEVENTS( ) Function

BINDEVENT( ) Function

EVENTHANDLER( ) Function

RAISEEVENT( ) Function

SYS(2325) - WCLIENTWINDOW from Visual FoxPro WHANDLE

SYS(2326) - WHANDLE from a Window's hWnd

SYS(2327) - Window's hWnd from Visual FoxPro WHANDLE

Other Resources

Functions