This article supporting source code
First, the preface
The last book introduced the callback interface, on the basis of which we understand the connection point is much easier.
Second, the principle
Diagram I, connection point component schematic diagram. The left side is the client and the right side is the server side (Component object)
Look very complicated ah ... Oh, in fact, simple tight: (Note 1)
1, a COM component that allows multiple connection point objects (IConnectionPoint).
That is, there can be multiple sources of "events". There are 3 connection points on the diagram above;
2, the interface that manages these connection points is called "Connection point Container" (IConnectionPointContainer).
The connection point container interface is particularly simple because there are only 2 functions, one is FindConnectionPoint (), which means finding the connection point you want, and the other is EnumConnectionPoints (), which indicates that all the connection points are listed and then you choose which to use. In the actual application, the lookup method uses the most, occupies 90%, but the enumeration method uses only 10%, generally uses in the support third party's plug-in (Plug in). (Do you want to write a plugin for IE?) We'll talk about it later.)
3, each connection point, can be multiple client's receiver (Sink) connection;
We are familiar with this, remember we in the last book in order to manage multiple callback interface, using a cookie way to distinguish it?!
III. Implementation components (i)
1. Establish a working area (WorkSpace)
2. Create an ATL project (project) in the workspace. The project name in the sample program is called SIMPLE15, accepting all default options.
3. In ClassView, execute the right mouse button menu command New Atl Object ..., add the ALT class.
4, the left category Category select Objects, right Objects select Simpleobject (In fact, is the default project).
5, Name card, enter the name of the component. The sample program is Dispconnect.
6, the attribute Attributes card, the interface type chooses Dual dual interface. Note that you must select Support Connection Points to support connection points.