Creating an ActiveX Control
Go Up to Using ActiveX Controls Index
An ActiveX control is a software component that integrates into and extends the functionality of any host application that supports ActiveX controls, such as C++Builder, Delphi, Visual Basic, Internet Explorer, and Mozilla Firefox. ActiveX controls implement a particular set of interfaces that allow this integration.
For example, Delphi comes with several ActiveX controls, including charting, spreadsheet, and graphics controls. You can add these controls to the Tool Palette in the IDE, and then use them like any standard VCL component, dropping them on forms and setting their properties using the Object Inspector.
An ActiveX control can also be tested by adding a reference to the ActiveX control in an HTML file, which can then be viewed with ActiveX-enabled Web browsers. See Creating a VCL Forms ActiveX Active Form.
Delphi provides wizards that let you create two types of ActiveX controls:
- ActiveX Controls that wrap VCL classes: By wrapping a VCL class, you can convert existing components into ActiveX controls or create new ones, test them out locally, and then convert them into ActiveX controls. ActiveX controls are typically intended to be embedded in a larger host application.
- Active Forms: Active Forms let you use the form designer to create a more elaborate control that acts like a dialog or like a complete application. You develop the Active Form in much the same way that you develop a typical Delphi application. Active Forms are typically intended for use on the Web.
Overview of ActiveX Control Creation
Creating ActiveX controls using Delphi is very similar to creating ordinary controls or forms. This differs markedly from creating other COM objects (see Creating Simple COM Servers - Overview, where you first define the object's interface and then complete the implementation. To create ActiveX controls (other than Active Forms), you reverse this process, starting with the implementation of a VCL control, and then generating the interface and type library once the control is written. When creating Active Forms, the interface and type library are created at the same time as your form, and then you use the form designer to implement the form. Type libraries are now stored in a proprietary format, the RIDL File.
The completed ActiveX control consists of a VCL control that provides the underlying implementation, a COM object that wraps the VCL control, and a type library that lists the COM object's properties, methods, and events. For details, see Elements of an ActiveX Control.
To create a new ActiveX control (other than an Active Form)
- Design and create (or otherwise obtain) the custom VCL control that is to form the basis of your ActiveX control.
- Use the ActiveX Control wizard to create an ActiveX control from the VCL control you created in step 1.
- (Optional) Use the ActiveX property page wizard to create one or more property pages for the control.
- (Optional) Associate a property page with an ActiveX control.
- Register your ActiveX control.
- Test your ActiveX control with all potential target applications.
To create an Active Form
- Follow the steps in Creating a VCL Forms ActiveX Active Form.
- To give your Active Form a property page and register it, follow steps 3, 4, and 5 in "To create a new ActiveX control," above.
- To test an Active Form, see Creating a VCL Forms ActiveX Active Form.