Skip to content

COM Object Wrapper Classes

In DataFlex, you use a COM object by instantiating the appropriate wrapper class that was generated by the COM Import wizards. After you have imported a COM component, the Studio automatically opens the package containing all of the class code and other definitions it has generated.

You should be aware of the definitions inside this package as you will need to reference them as you begin programming. Use the following guideline to determine the naming used to expose the COM object's interface:

Class Name

As discussed in the section on Importing COM Components, the wrapper classes have the same name as the COM objects that they represent but prefixed with "Com" (or "ComDb" for data-aware ActiveX controls).

The wrapper class declaration can be found at the end of the generated package.

Wrapper Class Structure

Each wrapper class that is generated is constructed from three superclasses using multiple inheritance. The diagram below shows this structure:

Wrapper Class Structure

cCom{wrapper}

This is the wrapper class that you will directly use in your application to access the COM component that you imported. It is generated when you import a COM component. For example, the Calendar ActiveX control's wrapper class is generated as cComCalendar.

cComI{wrapper}

This superclass is also generated when you import a COM component. It provides wrappers for all of the component's interface elements (properties, procedures, and functions). You can review this class definition to inspect the names, data types, etc. that appear in this interface. For example, the Calendar ActiveX control's interface is generated in a class named cComICalendar.

cCom{wrapper}Events

This superclass is also generated when you import a COM component. It implements the COM component's event interface. For example, the Calendar ActiveX control's event interface is generated in a class named cComCalendarEvents.

cCom{type}

The third superclass is one of the built-in DataFlex COM classes. The type of COM component that you import determines which class is used. For example, the Calendar ActiveX control's DataFlex superclass would be either cComActiveXControl or cComDbActiveXControl, depending on whether you imported the control as data-aware or not.

ActiveX Controls

ActiveX control wrapper classes are derived from either cComActiveXControl or cComDbActiveXControl. Which class is used depends on whether you imported the control using the "data-aware" option or not (see Importing ActiveX Controls for more information).

Automation Libraries

Automation object wrapper classes are derived from cComAutomationObject.

Embedded Objects

Embedded object wrapper classes are derived from cComDocumentObject.

Method Name

Each exposed interface member (property, procedure, or function) will have the same name in the DataFlex wrapper class as the documented name in the COM object, except that the prefix "Com" is added. For example, in the Calendar ActiveX control, the Month property is exposed as ComMonth, and ShowDays is exposed as ComShowDays.

Events

Event methods are similarly exposed except that the prefix becomes "OnCom". For example, in the Calendar ActiveX control, the OnClick event is exposed as OnComClick.

Enumerated Constants

Many COM Objects define integer types based on a discrete set of integer values. These are exposed in the generated package with the same names as used in the COM object's interface, except that they are prefixed with "OLE". For example, in the Automation controller sample, the COM Automation Server object exposes an integer type called txShapeType; this is exposed in the wrapper class as OLETxShapeType.

These definitions are generated at the beginning of the package containing the wrapper class definitions.

See Also