[ Pobierz całość w formacie PDF ]
.ActiveX controls implement a particular set of interfaces that allow thisintegration.For example, Delphi comes with several ActiveX controls, including charting,spreadsheet, and graphics controls.You can add these controls to the componentpalette in the IDE, and then use them like any standard VCL component, droppingthem on forms and setting their properties using the Object Inspector.An ActiveX control can also be deployed on the Web, allowing it to be referenced inHTML documents and viewed with ActiveX-enabled Web browsers.Delphi provides wizards that let you create two types of ActiveX controls:" ActiveX controls that wrap VCL classes.By wrapping a VCL class, you canconvert existing components into ActiveX controls or create new ones, test themout locally, and then convert them into ActiveX controls.ActiveX controls aretypically intended to be embedded in a larger host application." Active forms.Active forms let you use the form designer to create a moreelaborate control that acts like a dialog or like a complete application.You developthe Active form in much the same way that you develop a typical Delphiapplication.Active Forms are typically intended for deployment on the Web.This chapter provides an overview of how to create an ActiveX control in the Delphienvironment.It is not intended to provide complete implementation details ofwriting ActiveX control without using a wizard.For that information, refer to yourMicrosoft Developer s Network (MSDN) documentation or search the Microsoft Website for ActiveX information.Cr eat i ng an Ac t i v eX c ont r ol 38-1 Ov e r v i e w o f Ac t i v e X c o n t r o l c r e a t i o nOverview of ActiveX control creationCreating ActiveX controls using Delphi is very similar to creating ordinary controlsor forms.This differs markedly from creating other COM objects, where you firstdefine the object s interface and then complete the implementation.To create ActiveXcontrols (other than Active Forms), you reverse this process, starting with theimplementation of a VCL control, and then generating the interface and type libraryonce the control is written.When creating Active Forms, the interface and typelibrary are created at the same time as your form, and then you use the form designerto implement the form.The completed ActiveX control consists of a VCL control that provides theunderlying implementation, a COM object that wraps the VCL control, and a typelibrary that lists the COM object s properties, methods, and events.To create a new ActiveX control (other than an Active Form), perform the followingsteps:1 Design and create the custom VCL control that forms the basis of your ActiveXcontrol.2 Use the ActiveX control wizard to create an ActiveX control from the VCL controlyou created in step 1.3 Use the ActiveX property page wizard to create one or more property pages forthe control (optional).4 Associate the property page with the ActiveX control (optional).5 Register the control.6 Test the control with all potential target applications.7 Deploy the ActiveX control on the Web.(optional)To create a new Active Form, perform the following steps:1 Use the ActiveForm wizard to create an Active Form, which appears as a blankform in the IDE, and an associated ActiveX wrapper for that form.2 Use the form designer to add components to your Active Form and implement itsbehavior in the same way you create and implement an ordinary form using theform designer.3 Follow steps 3-7 above to give your Active Form a property page, register it, anddeploy it on the Web.Elements of an ActiveX controlAn ActiveX control involves many elements which each perform a specific function.The elements include a VCL control, a corresponding COM object wrapper thatexposes properties, methods, and events, and one or more associated type libraries.38-2 Devel oper  s Gui de Ov e r v i e w o f Ac t i v e X c o n t r o l c r e a t i o nVCL controlThe 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 controlfrom which you will make your ActiveX control.The underlying VCL control must be a descendant of TWinControl, because it musthave a window that can be parented by the host application.When you create anActive form, this object is a descendant of TActiveForm.Note The ActiveX control wizard lists the available TWinControl descendants from whichyou can choose to make an ActiveX control.This list does not include all TWinControldescendants, however.Some controls, such as THeaderControl, are registered asincompatible with ActiveX (using the RegisterNonActiveX procedure) and do notappear in the list.ActiveX wrapperThe actual COM object is an ActiveX wrapper object for the VCL control.For Activeforms, this class is always TActiveFormControl.For other ActiveX controls, it has aname 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 theActiveX interfaces.The ActiveX wrapper inherits this support, which allows it toforward Windows messages to the VCL control and parent its window in the hostapplication.The ActiveX wrapper exposes the VCL control s properties and methods to clientsvia its default interface.The wizard automatically implements most of the wrapperclass s properties and methods, delegating method calls to the underlying VCLcontrol.The wizard also provides the wrapper class with methods that fire the VCLcontrol s events on clients and assigns these methods as event handlers on the VCLcontrol [ Pobierz całość w formacie PDF ]
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • agnieszka90.opx.pl