Connection point in COM ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------ 1. The connection point is used in COM to make the components to communicate with the client program. 2. Implementation of the connection point is also called the implementation of the interface in COM. The interface is defined in the component, but implemented in the client program, specifically defining a class in the client program (this class is also called the receiver), which is derived from the assembly outlet.
Connection point implementation:
Component: 1. Create an ATL component according to the regular, insert a simple ATL object, pay attention to "Support Connection Points" 2. Press the above steps to generate the "_ixxevents" interface, actually the interface we want to define 3. In the outlet Add method 4. Add method 5 in the interface 5. Modify .idl file <1> Dispinterface _ixxxevents to change to Interface _ixxxevents: iUnknown <2> Remove Properties: and Methods: Model <3> [Default, Source] Dispinterface_ixxxevents [Default, Source] interface_ixxxevents
6.BUILD, generate the type definition 7. Right-click the component class (cxxx), select "Implement Connection Point ..", select "_ixxxevents", ok8. At this time, a proxy class cproxy_ixxxevets is generated, and there is one Fire_YourMethod ... so, you can call the Fire method in the inlet method in the component (as if the method of calling the customer program) is actually encapsulated by the method defined in the interface.
Client: 1. Copy ServerProjectName.h and serverProjectname.tlb files Under your customer EXE project folder, add a #include "component name .h" #import "component name .t" #import "component name .tlb" # iport_guids raw_interface_only "
2. Create a class derived from the embodiment implemented method _IXXXEvents 3. <1> HRESULT STDMETHODCALLTYPE QueryInterface (REFIID iid, void ** ppvObject) <2> ULONG STDMETHODCALLTYPE AddRef () <3> ULONG STDMETHODCALLTYPE Release () <4> Finally, implement the method defined in the interface 4. Create a COM object according to the regular, call the interface (into the interface) method.
In fact, when the interface method is called to be designed in the component.
Ok, the above is the implementation of the connection point, so you can implement two-way communication between the component and the customer program, if there is a deficiency, please correct ------------------- ------------------------------------------ Vigor 2004.11.4