ActiveX Controls

   

Another topic that we could spend a whole chapter discussing is ActiveX controls. Briefly, ActiveX controls are inproc COM servers representing a software component that can be integrated into an existing application to add functionality. In many ways, they are very similar to a VCL control, except it's COM-based and can be used by a number of applications that support ActiveX controls including C++Builder, Delphi, Visual Basic, and Internet Explorer.

Within C++Builder, you can add ActiveX controls to your component palette in the IDE just like a VCL control. The object inspector can be used to modify the properties of an ActiveX control dropped on a form. Property editors can sometimes be provided within an ActiveX control, which enables further property manipulation. To activate a property editor, simply right-click the ActiveX control that has been dropped on your form.

C++Builder provides the ActiveX Control Wizard for creating ActiveX controls based on a VCL. This is illustrated in Figure 17.21.

Figure 17.21. The ActiveX Control Wizard.

graphics/17fig21.gif

This wizard enables you to create an ActiveX control that wraps a VCL class. To activate this wizard, start with a clean project by selecting File, New, Other, and select the ActiveX tab within the New Items dialog as illustrated in Figure 17.3. Then, select the ActiveX Control glyph.

Here are the steps associated to creating an ActiveX control within C++Builder.

  1. Choose or create a new VCL control that forms the basis of your ActiveX control.

  2. Activate the ActiveX control wizard and identify the VCL you've selected or created in Step 1.

  3. To create one or more property pages for the ActiveX control, use Borland's ActiveX property page wizard found on the New Items dialog under the ActiveX view.

  4. If you created a property page, associate it with the ActiveX control.

  5. Build and Register your ActiveX control.

  6. Test your ActiveX control by embedding it within potential target applications.

  7. If your ActiveX control is Web-capable (through Internet Explorer), deploy it on the Web.

You'll notice when creating ActiveX controls that you start with creating the class to an object before you create the COM interface to our control. This is somewhat in reverse from what we did earlier. After the control is written, the type library can be generated.

Another form of ActiveX control that we can create is an Active Form, which is intended for deployment on the Web. To begin to create an Active Form, start with a clean project by selecting File, New, Other, and select the ActiveX tab within the New Items dialog as illustrated in Figure 17.3. Then, select the Active Form glyph. This will enable you to use the IDE's form designer to create a visual control, such as a dialog, that can be deployed and accessed using the Web.

The Borland Help provides additional information on creating ActiveX controls and Active Forms. You're encouraged to look at this material for further details.


   
Top


C++ Builder Developers Guide
C++Builder 5 Developers Guide
ISBN: 0672319721
EAN: 2147483647
Year: 2002
Pages: 253

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net