Code Generated by Wizards

From RAD Studio
Jump to: navigation, search

Go Up to Implementing COM Objects with Wizards


Delphi and C++Builder wizards generate classes that are derived from the Delphi ActiveX framework (DAX). Despite its name, the Delphi ActiveX framework supports both Delphi and C++, as well as all types of COM objects, not just ActiveX controls. The classes in this framework provide the underlying implementation of the standard COM interfaces for the objects you create using a wizard.

The following figure illustrates the objects in the Delphi ActiveX framework:

Note: For C++Builder, DAX object names typically contain "Cpp" (for example, TCppComObject and TCppActiveXPropertyPage, and so forth).

Delphi ActiveX framework

Each wizard generates an implementation unit that implements your COM server object. The COM server object (the implementation object) descends from one of the classes in DAX:

DAX Base classes for generated implementation classes :

Wizard Base class from DAX Inherited support

COM Servers

System.Win.ComObj.TTypedComObject

Support for IUnknown and ISupportErrorInfo interfaces.

Support for aggregation, OLE exception handling, and safecall calling convention on dual interfaces.

Support for reading type library information.

Automation Servers or Creating an Active Server Page Index

System.Win.ComObj.TAutoObject

Everything provided by TTypedComObject, plus:

Support for the IDispatch interface.

Auto-marshaling support.


Corresponding to the classes in DAX, there is a hierarchy of class factory objects that handle the creation of these COM objects. The wizard adds code to the initialization section of your implementation unit that instantiates the appropriate class factory for your implementation class.

The wizards also generate a type library and its associated unit, which has a name of the form Project1_TLB. The Project1_TLB unit includes the definitions your application needs to use the type definitions and interfaces defined in the type library. For more information on the contents of this file, see Code Generated When You Import Type Library Information.

You can modify the interface generated by the wizard using the Type Library Editor. When you do this, the implementation class is automatically updated to reflect those changes. You need only fill in the bodies of the generated methods to complete the implementation.