RAD Studio |  |

Using ActiveX controls
Collapse All
Topics

Name | Description
Elements of an ActiveX Control | An ActiveX control involves many elements which each perform a specific function. The elements include a VCL control, a corresponding COM object wrapper that exposes properties, methods, and events, and one or more associated type libraries.
Designing an ActiveX Control | When designing an ActiveX control, you start by creating a custom VCL control. This forms the basis of your ActiveX control. For information on creating custom controls, see Creating custom components. When designing the VCL control, keep in mind that it will be embedded in another application; this control is not an application in itself. For this reason, you probably do not want to use elaborate dialog boxes or other major user-interface components. Your goal is typically to make a simple control that works inside of, and follows the rules of the main application. In addition, you should make... more
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,... more
Licensing ActiveX Controls | Licensing an ActiveX control consists of providing a license key at design-time and supporting the creation of licenses dynamically for controls created at runtime. To provide design-time licenses, a key is created for the control , which is stored in a file with the same name as the project with the LIC extension. This .LIC file is added to the project. The user of the control must have a copy of the .LIC file to open the control in a development environment. Each control in the project that has Make Control Licensed checked has a separate key entry in... more
Customizing the ActiveX Control's Interface | You can add, edit, and remove the properties, methods, and events in an ActiveX control by editing the type library. You can use the Type Library editor as described in Using the Type Library Editor. Remember that when you add events, they should be added to the Events interface, not the ActiveX control's default interface. Note: You can add unpublished properties to your ActiveX control's interface. Such properties can be set at runtime and will appear in a development environment, but changes made to them will not persist. That is, when the user of the control changes the value... more
Adding Additional Properties, Methods, and Events | You can add additional properties, methods, and events to the control using the type library editor. The declaration is automatically added to the control's implementation unit, type library (TLB) file, and type library unit. The specifics of what Delphi supplies depends on whether you have added a property or method or whether you have added an event.
How Delphi Adds Properties | The ActiveX wrapper class implements properties in its interface using read and write access methods. That is, the wrapper class has COM properties, which appear on an interface as getter and/or setter methods. Unlike VCL properties, you do not see a "property" declaration on the interface for COM properties. Rather, you see methods that are flagged as property access methods. When you add a property to the ActiveX control's default interface, the wrapper class definition (which appears in the _TLB unit that is updated by the Type Library editor) gains one or two new methods (a getter and/or setter) that... more
How Delphi Adds Events | The ActiveX control can fire events to its container in the same way that an automation object fires events to clients. This mechanism is described in Managing events in your Automation object. If the VCL control you are using as the basis of your ActiveX control has any published events, the wizards automatically add the necessary support for managing a list of client event sinks to your ActiveX wrapper class and define the outgoing dispinterface that clients must implement to respond to events. You add events to this outgoing dispinterface. To add an event in the type library editor,... more
Enabling Simple Data Binding with the Type Library | With simple data binding, you can bind a property of your ActiveX control to a field in a database. To do this, the ActiveX control must communicate with its host application about what value represents field data and when it changes. You enable this communication by setting the property's binding flags using the Type Library editor. By marking a property bindable, when a user modifies the property (such as a field in a database), the control notifies its container (the client host application) that the value has changed and requests that the database record be updated. The container interacts with... more
Creating a Property Page for an ActiveX Control | A property page is a dialog box similar to the Delphi Object Inspector in which users can change the properties of an ActiveX control. A property page dialog allows you to group many properties for a control together to be edited at once. Or, you can provide a dialog box for more complex properties. Typically, users access the property page by right-clicking the ActiveX control and choosing Properties.
Creating a New Property Page | You use the Property Page wizard to create a new property page.
Adding Controls to a Property Page | You must add a control to the property page for each property of the ActiveX control that you want the user to access. For example, the following illustration shows a property page for setting the MaskEdit property of an ActiveX control. The list box allows the user to select from a list of sample masks. The edit controls allow the user to test the mask before applying it to the ActiveX control. You add controls to the property page the same as you would to a form.
Associating Property Page Controls with ActiveX Control Properties | After adding the controls you need to the property page, you must associate each control with its corresponding property. You make this association by adding code to the property page's UpdatePropertyPage and UpdateObject methods.
Updating the Property Page | Add code to the UpdatePropertyPage method to update the control on the property page when the properties of the ActiveX control change. You must add code to the UpdatePropertyPage method to update the property page with the current values of the ActiveX control's properties. You can access the ActiveX control using the property page's OleObject property, which is an OleVariant that contains the ActiveX control's interface. For example, the following code updates the property page's edit control (InputMask) with the current value of the ActiveX control's EditMask property:
Updating the Object | Add code to the UpdateObject method to update the property when the user changes the controls on the property page. You must add code to the UpdateObject method in order to set the properties of the ActiveX control to their new values. You use the OleObject property to access the ActiveX control. For example, the following code sets the EditMask property of the ActiveX control using the value in the property page's edit box control (InputMask):
Connecting a Property Page to an ActiveX Control | Describes the steps in connecting an ActiveX control to a property page. To connect a property page to an ActiveX control: Add DefinePropertyPage with the GUID constant of the property page as the parameter to the DefinePropertyPages method implementation in the control's implementation for the unit. For example, procedure TButtonX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); begin DefinePropertyPage(Class_PropertyPage1); >end; BEGIN_PROPERTY_MAP(TActiveFormXImpl) // Define property pages here. Property pages are defined using // the PROP_PAGE macro with the class id of the page. For example, // PROP_PAGE(CLSID_ActiveFormXPage) PROP_PAGE(CLSID_PropertyPage1) END_PROPERTY_MAP() The GUID constant, Class_PropertyPage1, of the property page can be found in the property pages unit. The GUID... more

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