Creating IDLcomIDispatch Objects

To expose a COM object as an IDL object, use the OBJ_NEW function to create a dynamic subclass of the IDLcomIDispatch object class. The name of the subclass must be constructed as described in IDLcomIDispatch Object Naming Scheme, and identifies the COM object to be instantiated.

Note
If the COM object you want to use within IDL is an ActiveX control, use the WIDGET_ACTIVEX routine as described in Using ActiveX Controls in IDL. Instantiating the ActiveX control as part of an IDL widget hierarchy allows you to respond to events generated by the control, whereas COM objects that are instantiated using the OBJ_NEW do not generate events that IDL is aware of.

For example, suppose you wish to include a COM component with the class ID

{A77BC2B2-88EC-4D2A-B2B3-F556ACB52E52} 

and the program ID

RSIDemoComponent.RSIDemoObj1.1 

in an IDL program. Use either of the following calls to the OBJ_NEW function:

ObjRef = OBJ_NEW( $ 
   'IDLcomIDispatch$CLSID$A77BC2B2_88EC_4D2A_B2B3_F556ACB52E52') 

or

ObjRef = OBJ_NEW( $ 
   'IDLcomIDispatch$PROGID$RSIDemoComponent_RSIDemoObj1_1') 

IDL's internal COM subsystem instantiates the COM object within an IDLcomIDispatch object with one of the following the dynamic class names

IDLcomIDispatch$CLSID$A77BC2B2_88EC_4D2A_B2B3_F556ACB52E52 

or

IDLcomIDispatch$PROGID$RSIDemoComponent_RSIDemoObj1_1 

and sets up communication between the object and IDL. You can work with the IDLcomIDispatch object just as you would with any other IDL object; calling the object's methods, and getting and setting its properties.

See "IDLcomIDispatch" (IDL Reference Guide) for additional details.