GETCONTROL

Purpose:

Returns a handle to the current ActiveX control or server object in an event handler or custom dialog box.

Syntax:

GETCONTROL(id)

id

-

Optional, an integer, the control ID if the control is referenced in a custom dialog box.

Returns:

A handle to the running object or 1 if an error occurs.

Example:

Consider the following SPL function:

 

/* simple event handler */
MyEvent(argv)
{
    local i, str = "", ctrl;
 
    loop (i = 1..argc)
    {
        str += sprintf("arg%d: %s ", i,
                        caststring(getargv(i)));
    }
 
    /* get calling ActiveX object */
    ctrl = getcontrol();
 
    /* display status text and title */
    message(ctrl.StatusText, str);
}

 

The handler is 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 message box displays the status line text and the current title of the displayed web page.

Remarks:

Within an SPL event handler, GETCONTROL returns a handle to the calling ActiveX object. The handle can be used to further manipulate the object.

 

See REGISTEREVENT to register an SPL function to process and ActiveX event.

See Also:

CREATEOBJECT

GETEXENAME

REGISTERCONTROL

REGISTEREVENT