REGISTEREVENT

Purpose:

Establishes an event handler for an ActiveX event.

Syntax:

REGISTEREVENT(object, "eventname", "handlername")

object

-

A handle to an ActiveX object.

"eventname"

-

A string, the name of the ActiveX event.

"handlername"

-

A string, the name of the routine that is called when the event is raised. Typically an SPL function.

 

Alternate Syntax:

 

REGISTEREVENT(object, eventID, "handlername")

object

-

A handle to an ActiveX object.

eventID

-

An integer, the ID of the the ActiveX event.

"handlername"

-

A string, the name of the routine that is called when the event is raised. Typically an SPL function.

 

Returns:

An integer, 1 if successful.

Example:

Consider the following SPL function:

 

/* simple event handler */
MyEvent(argv)
{
    local i, str = "";
 
    loop (i = 1..argc)
    {
        str += sprintf("arg%d: %s ", i,
                       caststring(getargv(i)));
    }
 
    message("MyEvent", str);
}

 

The handler can be used to process events from Internet Explorer.

 

/* connect to Internet Explorer */
ie = createobject("internetexplorer.application");
 
/* navigate to home page */
ie.navigate("www.dadisp.com");
 
/* show it */
ie.visible = 1;
 
/* establish event handler */
registerevent(ie, "TitleChange", "MyEvent");

 

Each time the title displayed by Internet Explorer changes, MyEvent is called and a message box is displayed.

 

The event can also be specified by an integer event ID. For example:

 

registerevent(ie, 0x71, "MyEvent");

Remarks:

The ActiveX event can be specified by name or integer ID.

 

Depending on the particular event, zero or more arguments may be passed to the event handler.

 

See GETCONTROL to return a handle to the calling ActiveX object.

 

See UNREGISTEREVENT to cancel an event handler

 

See RAISEEVENT and FIREEVENT to fire an event from DADiSP to an external client application.

 

REGISTEREVENT can also be called SETEVENTHANDLER.

See Also:

CREATEOBJECT

FIREEVENT

GETCONTROL

GETOBJECT

RAISEEVENT

REGISTERCONTROL

UNREGISTEREVENT