[ Pobierz całość w formacie PDF ]
.Note The ActiveX page of the Component palette contains a number of example ActiveXcontrols that were imported this way for you.42-4 Devel oper  s Gui de I mp o r t i n g t y p e l i b r a r y i n f o r ma t i o nCode generated when you import type library informationOnce you import a type library, you can view the generated TypeLibName_TLB unit.At the top, you will find the following:" Constant declarations giving symbolic names to the GUIDS of the type library andits interfaces and CoClasses.The names for these constants are generated asfollows:" The GUID for the type library has the form LBID_TypeLibName, whereTypeLibName is the name of the type library." The GUID for an interface has the form IID_InterfaceName, where InterfaceNameis the name of the interface." The GUID for a dispinterface has the form DIID_InterfaceName, whereInterfaceName is the name of the dispinterface." The GUID for a CoClass has the form CLASS_ClassName, where ClassName isthe name of the CoClass." The compiler directive VARPROPSETTER will be on.This allows the use of thekeyword var in the parameter list of property setter methods.This disables acompiler optimization that would cause parameters to be passed by valueinstead of by reference.The VARPROPSETTER directive must be on, whencreating TLB units for components written in a language other than Delphi." Declarations for the CoClasses in the type library.These map each CoClass to itsdefault interface." Declarations for the interfaces and dispinterfaces in the type library." Declarations for a creator class for each CoClass whose default interface supportsVTable binding.The creator class has two class methods, Create and CreateRemote,that can be used to instantiate the CoClass locally (Create) or remotely(CreateRemote).These methods return the default interface for the CoClass.These declarations provide you with what you need to create instances of theCoClass and access its interface.All you need do is add the generatedTypeLibName_TLB.pas file to the uses clause of the unit where you wish to bind to aCoClass and call its interfaces.Note This portion of the TypeLibName_TLB unit is also generated when you use the TypeLibrary editor or the command-line utility TLIBIMP.If you want to use an ActiveX control, you also need the generated VCL wrapper inaddition to the declarations described above.The VCL wrapper handles windowmanagement issues for the control.You may also have generated a VCL wrapper forother CoClasses in the Import Type Library dialog.These VCL wrappers simplify thetask of creating server objects and calling their methods.They are especiallyrecommended if you want your client application to respond to events.Cr eat i ng COM cl i ent s 42-5 Co n t r o l l i n g a n i mp o r t e d o b j e c tThe declarations for generated VCL wrappers appear at the bottom of the interfacesection.Component wrappers for ActiveX controls are descendants of TOleControl.Component wrappers for Automation objects descend from TOleServer.Thegenerated component wrapper adds the properties, events, and methods exposed bythe CoClass s interface.You can use this component like any other VCL component.Warning You should not edit the generated TypeLibName_TLB unit.It is regenerated each timethe type library is refreshed, so any changes will be overwritten.Note For the most up-to-date information about the generated code, refer to the commentsin the automatically-generated TypeLibName_TLB unit.Controlling an imported objectAfter importing type library information, you are ready to start programming withthe imported objects.How you proceed depends in part on the objects, and in part onwhether you have chosen to create component wrappers.Using component wrappersIf you generated a component wrapper for your server object, writing your COMclient application is not very different from writing any other application thatcontains VCL components.The server object s properties, methods, and events arealready encapsulated in the VCL component.You need only assign event handlers,set property values, and call methods.To use the properties, methods, and events of the server object, see thedocumentation for your server.The component wrapper automatically provides adual interface where possible [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • necian.htw.pl