RAD Studio
ContentsIndex
PreviousUpNext
Generating an ActiveX Control Based On a VCL Form

Unlike other ActiveX controls, Active Forms are not first designed and then wrapped by an ActiveX wrapper class. Instead, the ActiveForm wizard generates a blank form that you design later when the wizard leaves you in the Form Designer. 

When an ActiveForm is deployed on the Web, Delphi creates an HTML page to contain the reference to the ActiveForm and specify its location on the page. The ActiveForm can then displayed and run from a Web browser. Inside the browser, the form behaves just like a stand-alone Delphi form. The form can contain any VCL components or ActiveX controls, including custom-built VCL controls.

To start the ActiveForm wizard,

  1. Choose FileNewOther to open the New Items dialog box.
  2. Select the tab labeled ActiveX.
  3. Double-click the ActiveForm icon.
On the Active Form wizard, you can't specify the name of the VCL class to wrap. This is because Active forms are always based on TActiveForm. 

You can change the default names for the CoClass, implementation unit, and ActiveX library project. Similarly, this wizard lets you indicate whether you want your Active Form to require a license, whether it should include version information, and whether you want an About box form. 

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.
  • A form that descends from TActiveForm. This form appears in the form designer, where you can use it to visually design the Active Form that appears to clients. Its implementation appears in the generated implementation unit. In the initialization section of the implementation unit, a class factory is created, setting up TActiveFormControl as the ActiveX wrapper for this form.
  • An About box form and unit if you requested them.
  • A .LIC file if you enabled licensing.
At this point, you can add controls and design the form as you like. 

After you have designed and compiled the ActiveForm project into an ActiveX library (which has the OCX extension), you can deploy the project to your Web server and Delphi creates a test HTML page with a reference to the ActiveForm.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!