Cross Point


IEventBase Interface Reference

Inheritance diagram for IEventBase:

IApplication IMemoryAccess IReaderNetwork IXMLBase IEvent IEventDatabase IParameter IParameterDatabase IProximityReader ITimeBlock ITimeScheme IUser IUserDatabase IUserGroup List of all members.

Detailed Description

Base interface for all objects that generate events.

Since the event handling model is different in scripting than in other languages such as for instance C++ and VB, an interface has been added to allow scripting users to handle events more easily. This interface contains 2 methods, one to attach to an event and one to detach from an event.

Attaching to an event is done using the following method: when an event fires, let the API call a specific method/sub/function in a script. After detaching an event, the API will not call the method/sub/function in the script anymore.

To attach, use AttachEvent. Detach using DetachEvent.

See the detailed sections of the methods/properties for more information.


Public Member Functions

HRESULT AttachEvent ([in] VARIANT vtEvent,[in] VARIANT vtFunctionPointer,[out, retval] VARIANT_BOOL *pfSucceeded)
 Attach an event to a function or sub.

HRESULT DetachEvent ([in] VARIANT vtEvent,[in] VARIANT vtFunctionPointer,[out, retval] VARIANT_BOOL *pfSucceeded)
 Detach an event from a function/sub.


Member Function Documentation

IEventBase::AttachEvent [in] VARIANT  vtEvent,
[in] VARIANT  vtFunctionPointer,
[out, retval] VARIANT_BOOL *  pfSucceeded
 

Attach an event to a function or sub.

Use this method to subscribe/attach to an event on this object. Whenever the event fires on this object the supplied function will be called. In VBScript, use the "GetRef" to get a pointer to a function. In JScript, the function can be passed directly into the vtFunctionPointer argument.

The following example shows how to attach to a OnProcessStarted event of the application object in VBScript:

Sub OnProcessInfo(ProcessType, objBase, SubProcessType, Info)
        If SubProcessType = 4 Then ' 4 indicates the sptItemFound sub process
                MsgBox "Found a new network on port " & Info
        End If
End Sub

Dim objApp
Set objApp = CreateObject("TalosAPI.Application")

' Attach the event
objApp.AttachEvent 0x03, GetRef("OnProcessInfo") ' 0x01 is the ID of the OnProcessInfo event

' Execute the scan
objApp.ScanReaderNetworks

When the each found network, the 'OnProcessInfo' method will now be called, showing a messagebox with the port number (= default property) of the found network.

Parameters:
vtEvent The ID of the required event, see EDISPIDS for the numbers of the events.
vtFunctionPointer A pointer to a function that will be called when the event fires (VBScript, use GetRef!).
pfSucceeded Set to true if the method succeeds.
See also:
EDISPIDS, DetachEvent

IEventBase::DetachEvent [in] VARIANT  vtEvent,
[in] VARIANT  vtFunctionPointer,
[out, retval] VARIANT_BOOL *  pfSucceeded
 

Detach an event from a function/sub.

Detach from an event. This method should be called when you do not want to receive events from a specific object anymore.

Parameters:
vtEvent The ID of the event, see EDISPIDS for the numbers of the events.
vtFunctionPointer The same functionpointer that was passed to the AttachEvent method.
pfSucceeded Set to true if unsubscribing succeeds.
See also:
EDISPIDS, AttachEvent


© Copyright 2001 - 2006 Cross Point. Generated on Mon Mar 12 16:29:51 2007 Cross Point