[ Pobierz całość w formacie PDF ]
.This type information provides a way for your control to advertiseits services to host applications.You can view and edit this information using theType Library editor.Although this information is stored in a separate, binary typelibrary file (.TLB extension), it is also automatically compiled into the ActiveX controlDLL as a resource.Property pageYou can optionally give your ActiveX control a property page.The property pageallows the user of a host (client) application to view and edit your control sproperties.You can group several properties on a page, or use a page to provide adialog-like interface for a property.For information on how to create property pages,see  Creating a property page for an ActiveX control on page 38-11.Cr eat i ng an Ac t i v eX c ont r ol 38-3 De s i g n i n g a n Ac t i v e X c o n t r o lDesigning an ActiveX controlWhen designing an ActiveX control, you start by creating a custom VCL control.Thisforms the basis of your ActiveX control.For information on creating custom controls,see Part V,  Creating custom components.When designing the VCL control, keep in mind that it will be embedded in anotherapplication; this control is not an application in itself.For this reason, you probablydo 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 therules of the main application.In addition, you should make sure that the types for all properties and methods youwant your object to expose to clients are Automation-compatible, because theActiveX control s interface must support IDispatch.The wizard does not add anymethods to the wrapper class s interface that have parameters that are notAutomation-compatible.For a list of Automation-compatible types, see  Validtypes on page 34-11.The wizards implement all the necessary ActiveX interfaces required using the COMwrapper class.They also surface all Automation-compatible properties, methods,and events through the wrapper class s default interface.Once the wizard hasgenerated the COM wrapper class and its interface, you can use the Type Libraryeditor to modify the default interface or augment the wrapper class by implementingadditional interfaces.Generating an ActiveX control from a VCL controlTo generate an ActiveX control from a VCL control, use the ActiveX Control wizard.The properties, methods, and events of the VCL control become the properties,methods, and events of the ActiveX control.Before using the ActiveX control wizard, you must decide what VCL control willprovide the underlying implementation of the generated ActiveX control.To bring up the ActiveX control wizard,1 Choose File|New|Other to open the New Items dialog box.2 Select the tab labeled ActiveX.3 Double-click the ActiveX Control icon.In the wizard, select the name of the VCL control that will be wrapped by the newActiveX control.The dialog lists all available controls, which are descendants ofTWinControl that are not registered as incompatible with ActiveX using theRegisterNonActiveX procedure.Tip If you do not see the control you want in the drop-down list, check whether you haveinstalled it in the IDE or added its unit to your project.Once you have selected a VCL control, the wizard automatically generates a name forthe CoClass, the implementation unit for the ActiveX wrapper, and the ActiveX38-4 Devel oper  s Gui de Ge n e r a t i n g a n Ac t i v e X c o n t r o l b a s e d o n a VCL f o r mlibrary project.(If you currently have an ActiveX library project open, and it does notcontain a COM+ event object, the current project is automatically used.) You canchange any of these in the wizard (unless you have an ActiveX library project alreadyopen, in which case the project name is not editable).The wizard always specifies Apartment as the threading model.This is not a problemif your ActiveX project usually contains only a single control.However, if you addadditional objects to your project, you are responsible for providing thread support.The wizard also lets you configure various options on your ActiveX control:" Enabling licensing: You can make your control licensed to ensure that users of thecontrol can't open it either for design purposes or at runtime unless they have alicense key for the control." Including Version information: You can include version information, such as acopyright or a file description, in the ActiveX control.This information can beviewed in a browser.Some host clients, such as Visual Basic 4.0, require Versioninformation or they will not host the ActiveX control.Specify version informationby choosing Project|Options and selecting the Version Info page." Including an About box: You can tell the wizard to generate a separate form thatimplements an About box for your control.Users of the host application candisplay this About box in a development environment.By default, the About boxincludes the name of the ActiveX control, an image, copyright information, and anOK button.You can modify this default form, which the wizard adds to yourproject.When you exit the wizard, it generates the following:" An ActiveX Library project file, which contains the code required to start anActiveX control.You usually don t change this file." A type library, which defines and CoClass for your control, the interface it exposesto clients, and any type definitions that these require.For more information aboutthe type library, refer to Chapter 34,  Working with type libraries." An ActiveX implementation unit, which defines and implements the ActiveXcontrol, a descendant of TActiveXControl [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • czarkowski.pev.pl
  •