Method Calls on ActiveX Controls

IDL allows you to call the underlying ActiveX control's methods by calling methods on the IDLcomActiveX object that is automatically created when you call the WIDGET_ACTIVEX function. IDL handles conversion between IDL data types and the data types used by the component, and any results are returned in IDL variables of the appropriate type. As with all IDL objects, the general syntax is:

result = ObjRef->Method([Arguments]) 

or

ObjRef -> Method[, Arguments] 

where ObjRef is an object reference to an instance of a dynamic subclass of the IDLcomActiveX class.

The IDLcomActiveX object class is a direct subclass of the IDLcomIDispatch object class and provides none of its own methods. As a result, method calls on IDLcomActiveX objects follow the same rules as calls on IDLcomIDispatch objects. You should read and understand Method Calls on IDLcomIDispatch Objects before calling an ActiveX control's methods.

Retrieving the Object Reference

Unlike IDLcomIDispatch objects, which you create explicitly with a call to the OBJ_NEW function, IDLcomActiveX objects are created automatically by IDL. To obtain an object reference to the automatically created IDLcomActiveX object, use the GET_VALUE keyword to the WIDGET_CONTROL procedure.

For example, consider the following lines of IDL code:

wBase = WIDGET_BASE() 
wAx = WIDGET_ACTIVEX(wBase, 'myProgram.myComponent.1', ID_TYPE=1) 
WIDGET_CONTROL, wBase, /REALIZE 
WIDGET_CONTROL, wAx, GET_VALUE=oAx 

The first line creates a base widget that will hold the ActiveX control. The second line instantiates the ActiveX control using its program ID and creates an IDLcomActiveX object. The third line realizes the base widget and the ActiveX control it contains; note that the ActiveX widget must be realized before you can retrieve a reference to the IDLcomActiveX object. The fourth line uses the WIDGET_CONTROL procedure to retrieve an object reference to the IDLcomActiveX object in the variable oAx. You can use this object reference to call the ActiveX control's methods and set its properties.