COM component Design and application (15)--Connection point (vc6.0)

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.