Bridges > COM Import Bridge and ActiveX > Overview > Using COM Objects With IDL

# Using COM Objects With IDL

The methods for using COM objects with IDL are:

- Exposing a COM Object as an IDL Object
- Including an ActiveX Control in an IDL Widget Hierarchy

## Exposing a COM Object as an IDL Object

IDL’s IDLcomIDispatch object class creates an IDL object that communicates with an underlying COM object using the COM object’s IDispatch interface. When you create an IDLcomIDispatch object, you provide the identifier for the COM object you wish to use, and IDL handles instantiation of and communication with the object. You can call the COM object’s methods and get and set its properties using standard IDL object conventions and syntax.

Note: The IDLcomIDispatch object is useful when you want to incorporate a generic COM object into your IDL application. If the COM object you want to use is an ActiveX control, use the WIDGET_ACTIVEX routine, discussed below.

For details on using the IDLcomIDispatch object class to incorporate COM objects into your IDL applications, see Using COM Objects in IDL.

## Including an ActiveX Control in an IDL Widget Hierarchy

IDL’s WIDGET_ACTIVEX routine incorporates an ActiveX control directly into an IDL widget hierarchy. This allows you to place the ActiveX control in an IDL widget interface, and to receive widget events directly from the control for handling by a standard IDL widget event handler.

Internally, IDL uses the same mechanisms it uses when creating IDLcomIDispatch objects when it instantiates an ActiveX control as part of an IDL widget hierarchy. After the widget hierarchy has been realized, an object reference to the IDL object that encapsulates the ActiveX control can be retrieved and used as an interface with the ActiveX control. This allows you to call the ActiveX control’s methods and get and set its properties using standard IDL object conventions and syntax.

For details on using the WIDGET_ACTIVEX routine to incorporate ActiveX controls into your IDL applications, see Using ActiveX Controls in IDL.