Bridges > COM Import Bridge and ActiveX > ActiveX Controls > Creating ActiveX Controls

# Creating ActiveX Controls

To include an ActiveX control in an IDL application, use the WIDGET_ACTIVEX function, supplying the COM class or program ID of the ActiveX control as the COM_ID argument.

Note: If the object you want to use in your IDL application is not an ActiveX control, use the IDLcomIDispatch object class as described in Using COM Objects in IDL. Instantiating a non-ActiveX component using the WIDGET_ACTIVEX function is not supported, and may lead to unpredictable results.

Once the ActiveX object has been instantiated within an IDL widget hierarchy, you can call the control’s native methods as described in Method Calls on ActiveX Controls, and access or modify its properties as described in Managing ActiveX Control Properties. IDL widget events generated by the control are discussed in ActiveX Widget Events.

For example, suppose you wished to include an ActiveX control with the class ID:

{0002E510-0000-0000-C000-000000000046}

and the program ID:

OWC.Spreadsheet.9

in an IDL widget hierarchy. Use either of the following calls the WIDGET_ACTIVEX function:

wAx = WIDGET_ACTIVEX(wBase, '0002E510-0000-0000-C000-000000000046')

or

wAx = WIDGET_ACTIVEX(wBase, 'OWC.Spreadsheet.9', ID_TYPE=1)

where wBase is the widget ID of the base widget that will contain the ActiveX control.

Note: When instantiating an ActiveX control using the WIDGET_ACTIVEX function, you do not need to modify the class or program ID as you do when creating an IDLcomIDispatch object using the OBJ_NEW function. Be aware, however, that when IDL creates the underlying IDLcomActiveX object, the dynamic class name will replace the hyphens from a class ID or the dots from a program ID with underscore characters.

IDL’s internal COM subsystem instantiates the ActiveX control within an IDLcomActiveX object with one of the following dynamic class names

IDLcomActiveX$CLSID$0002E510_0000_0000_C000_000000000046

or

IDLcomActiveX$PROGID$OWC_Spreadsheet_9

and sets up communication between the object and IDL. IDL also places the control into the specified widget hierarchy and prepares to accept widget events generated by the control.

See “WIDGET_ACTIVEX” (IDL Reference Guide) for additional details.