Generating an ActiveX Control from a VCL Control
Go Up to Using ActiveX Controls Index
To generate an ActiveX control from a VCL control, use the ActiveX Control wizard. The properties, methods, and events of the VCL control become the properties, methods, and events of the ActiveX control.
Before using the ActiveX control wizard, you must decide which VCL control will provide the underlying implementation of the generated ActiveX control.
To run the ActiveX control wizard
- Select either:
- File > New > Other > C++Builder > ActiveX > ActiveX Library
- File > New > Other > Delphi > ActiveX > ActiveX Library
- This creates a Dynamic Link Library [DLL] project that you can use to host in-process ActiveX Objects.
- Select either:
- In the ActiveX Control wizard, select the name of the VCL control that will be wrapped by the new ActiveX control. The dialog lists all available controls, which are descendants of TWinControl that are not registered as incompatible with ActiveX using the RegisterNonActiveX procedure.
Tip: If you do not see the control you want in the drop-down list, check whether you have installed it in the IDE or added its unit to your project.
After you have selected a VCL control, the ActiveX Control wizard automatically generates a name for the CoClass, the implementation unit for the ActiveX wrapper, and the ActiveX library project. (If you currently have an ActiveX library project open, and it does not contain a COM+ event object, the current project is automatically used.) You can change any of these in the wizard (unless you have an ActiveX library project already open, in which case the project name is not editable).
The wizard always specifies Apartment as the threading model. This is not a problem if your ActiveX project usually contains only a single control. However, if you add additional objects to your project, you are responsible for providing thread support.
See the Active Form or ActiveX Control wizard for information about the various options you can set for your ActiveX control.
When you exit the wizard, it generates the following:
- An ActiveX Library project file, which contains the code required to start an ActiveX control. You usually don't change this file.
- A type library, which defines and CoClass for your control, the interface it exposes to clients, and any type definitions that these require. For more information about the type library, see Working with Type Libraries - Overview.
- An ActiveX implementation unit, which defines and implements the ActiveX control, a descendant of TActiveXControl. This ActiveX control is a fully-functioning implementation that requires no additional work on your part. However, you can modify this class if you want to customize the properties, methods, and events that the ActiveX control exposes to clients.