RAD Studio
ContentsIndex
PreviousUpNext
Creating a VCL Forms ActiveX Active Form

Like a Delphi control, an ActiveX control generates program code when you place the component on a form or other logical container in the IDE. The main difference between an ActiveX control and a Delphi control is that an ActiveX control is language independent. You can create ActiveX controls for deployment to a variety of programming environments on Windows, not just Delphi or C++Builder, for example.  

This procedure uses the VCL forms ActiveX Active Form wizard to create an Active Form containing two components. To test the control, you can deploy it to the Web. This procedure consists of the following major steps:

  1. Create an ActiveX library project for an ActiveX Active Form.
  2. Add controls to the Active Form.
  3. Add event handling code for the controls.
  4. Deploy the project to the Web.
  5. Display the form and test the controls in your Web browser.

To create an Active X library project for an ActiveX Active Form

  1. Create a directory on your local drive for the ActiveX project. Give it an easy to find name, for example, ActiveX.
  2. Create a second directory to contain the ActiveX component and an HTML file for deploying the Active Form to your Microsoft Internet Explorer Web browser. Name this directory ActiveX_Deploy.
  3. Choose FileNewOther and select the ActiveX page in the New Items dialog.
  4. On the ActiveX page, double-click Active Form. The Active Form Wizard displays.
  5. Accept the default settings and click OK. The wizard generates the code needed to implement the ActiveX control and adds the code to the project. If the project is already an ActiveX library, the wizard adds the control to the current project.
    Note: If the project is not already an ActiveX library, a Warning
    dialog displays and asks you if you want to start a new ActiveX library project.
  6. Click OK to start a new ActiveX library project. An ActiveX Active Form displays.

To add some functionality to the Active Form

  1. From the Standard page of the Tool Palette, add TEdit and TButton components to the form.
  2. Select the button.
  3. On the Events tab in the Object Inspector, double-click the OnClick event. The Code Editor opens with the cursor in place in the TActiveFormX.Button1Click (Delphi) or TActiveFormX::Button1Click() (C++) event handler block. Enter the following code at the cursor:

ShowMessage(Edit1.text);

 

ShowMessage( Edit1–>Text )

  1. Save the project files to your ActiveX directory.
Note: To deploy the Active form to your Web, use the Deployment Manager
. Click FileNewOtherDeployment.

To test the Active Form

  1. Launch your browser.
  2. Choose FileOpen, and browse to the ActiveX_Deploy directory.
  3. Double-click the HTML file to launch it in the browser window. The Active Form displays in the browser window.
  4. Click the button. A pop-up dialog displays the text in the Edit box.
  5. Change the text, and click the button again. The new text you entered displays in the pop-up.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!