RAD Studio
|
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.
The underlying implementation of an ActiveX control in Delphi is a VCL control. When you create an ActiveX control, you must first design or choose the VCL control from which you will make your ActiveX control.
The underlying VCL control must be a descendant of TWinControl, because it must have a window that can be parented by the host application. When you create an Active form, this object is a descendant of TActiveForm.
The actual COM object is an ActiveX wrapper object for the VCL control. For Active forms, this class is always TActiveFormControl. For other ActiveX controls, it has a name of the form TVCLClassX, where TVCLClass is the name of the VCL control class. Thus, for example, the ActiveX wrapper for TButton would be named TButtonX.
The wrapper class is a descendant of TActiveXControl, which provides support for the ActiveX interfaces. The ActiveX wrapper inherits this support, which allows it to forward Windows messages to the VCL control and parent its window in the host application.
The ActiveX wrapper exposes the VCL control's properties and methods to clients via its default interface. You must implement the wrapper class' properties and methods, delegating method calls to the underlying VCL control. You must also provide the wrapper class with methods that fire the VCL control's events on clients and assign these methods as event handlers on the VCL control.
You must generate a type library for your ActiveX control that contains the type definitions for the wrapper class, its default interface, and any type definitions that these require. This type information provides a way for your control to advertise its services to host applications. You can view and edit this information using the Type Library editor. Although this information is stored in a separate, binary type library file (.TLB extension), you may also compile it into the ActiveX control DLL as a resource.
You can optionally give your ActiveX control a property page. The property page allows the user of a host (client) application to view and edit your control's properties. You can group several properties on a page, or use a page to provide a dialog-like interface for a property. For information on how to create property pages, see Creating a property page for an ActiveX control.
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|