|
1 | 1 | ---
|
2 |
| -description: "Learn more about: Adding Connection Points to an Object" |
3 | 2 | title: "Adding Connection Points to an Object"
|
4 |
| -ms.date: "11/04/2016" |
| 3 | +description: "Learn more about: Adding Connection Points to an Object" |
| 4 | +ms.date: 11/04/2016 |
5 | 5 | helpviewer_keywords: ["connection points [C++], adding to ATL objects", "Implement Connection Point ATL wizard"]
|
6 |
| -ms.assetid: 843531be-4a36-4db0-9d54-e029b1a72a8b |
7 | 6 | ms.topic: how-to
|
8 | 7 | ---
|
9 | 8 | # Adding Connection Points to an Object
|
10 | 9 |
|
11 |
| -The [ATL Tutorial](../atl/active-template-library-atl-tutorial.md) demonstrates how to create a control with support for connection points, how to add events, and then how to implement the connection point. ATL implements connection points with the [IConnectionPointImpl](../atl/reference/iconnectionpointimpl-class.md) class. |
| 10 | +The [ATL Tutorial](active-template-library-atl-tutorial.md) demonstrates how to create a control with support for connection points, how to add events, and then how to implement the connection point. ATL implements connection points with the [`IConnectionPointImpl`](reference/iconnectionpointimpl-class.md) class. |
12 | 11 |
|
13 | 12 | To implement a connection point, you have two choices:
|
14 | 13 |
|
15 | 14 | - Implement your own outgoing event source, by adding a connection point to the control or object.
|
16 |
| - |
17 | 15 | - Reuse a connection point interface defined in another type library.
|
18 | 16 |
|
19 |
| -In either case, the Implement Connection Point Wizard uses a type library to do its work. |
| 17 | +In either case, the **Implement Connection Point Wizard** uses a type library to do its work. |
20 | 18 |
|
21 |
| -### To add a connection point to a control or object |
| 19 | +### Add a connection point to a control or object |
22 | 20 |
|
23 |
| -1. Define a dispinterface in the library block of the .idl file. If you enabled support for connection points when you created the control with the ATL Control Wizard, the dispinterface will already be created. If you did not enable support for connection points when you created the control, you must manually add a dispinterface to the .idl file. The following is an example of a dispinterface. Outgoing interfaces are not required to be dispatch interfaces but many scripting languages such as VBScript and JScript require this, so this example uses two dispinterfaces: |
| 21 | +1. Define a dispinterface in the library block of the `.idl` file. If you enabled support for connection points when you created the control with the **ATL Control Wizard**, the dispinterface will already be created. If you did not enable support for connection points when you created the control, you must manually add a dispinterface to the `.idl` file. The following is an example of a dispinterface. Outgoing interfaces are not required to be dispatch interfaces but many scripting languages such as VBScript and JScript require this, so this example uses two dispinterfaces: |
24 | 22 |
|
25 |
| - [!code-cpp[NVC_ATL_Windowing#81](../atl/codesnippet/cpp/adding-connection-points-to-an-object_1.idl)] |
| 23 | + [!code-cpp[NVC_ATL_Windowing#81](codesnippet/cpp/adding-connection-points-to-an-object_1.idl)] |
26 | 24 |
|
27 |
| - Use either the uuidgen.exe or guidgen.exe utility to generate a GUID. |
| 25 | + Use either the `uuidgen.exe` or `guidgen.exe` utility to generate a GUID. |
28 | 26 |
|
29 |
| -2. Add the dispinterface as the `[default,source]` interface in the coclass for the object in the project's .idl file. Again, if you enabled support for connection points when you created the control, the ATL Control Wizard will create the `[default,source`] entry. To manually add this entry, add the line in bold: |
| 27 | +2. Add the dispinterface as the `[default,source]` interface in the coclass for the object in the project's `.idl` file. Again, if you enabled support for connection points when you created the control, the ATL Control Wizard will create the `[default,source]` entry. To manually add this entry, add the line in bold: |
30 | 28 |
|
31 |
| - [!code-cpp[NVC_ATL_Windowing#82](../atl/codesnippet/cpp/adding-connection-points-to-an-object_2.idl)] |
| 29 | + [!code-cpp[NVC_ATL_Windowing#82](codesnippet/cpp/adding-connection-points-to-an-object_2.idl)] |
32 | 30 |
|
33 |
| - See the .idl file in the [Circ](../overview/visual-cpp-samples.md) ATL sample for an example. |
| 31 | + See the `.idl` file in the [Circ](../overview/visual-cpp-samples.md) ATL sample for an example. |
34 | 32 |
|
35 |
| -3. Use Class View to add methods and properties to the event interface. Right-click the class in Class View, point to **Add** on the shortcut menu, and click **Add Connection Point**. |
| 33 | +3. Use **Class View** to add methods and properties to the event interface. Right-click the class in **Class View**, point to **Add** on the shortcut menu, and select **Add Connection Point**. |
36 | 34 |
|
37 |
| -4. In the **Source Interfaces** list box of the Implement Connection Point Wizard, select **Project's interfaces**. If you choose an interface for your control and press **OK**, you will: |
| 35 | +4. In the **Source Interfaces** list box of the **Implement Connection Point Wizard**, select **Project's interfaces**. If you choose an interface for your control and select **OK**, you: |
38 | 36 |
|
39 | 37 | - Generate a header file with an event proxy class that implements the code that will make the outgoing calls for the event.
|
40 |
| - |
41 | 38 | - Add an entry to the connection point map.
|
42 | 39 |
|
43 |
| - You will also see a list of all of the type libraries on your computer. You should only use one of these other type libraries to define your connection point if you want to implement the exact same outgoing interface found in another type library. |
44 |
| - |
45 |
| -### To reuse a connection point interface defined in another type library |
| 40 | + You also see a list of all of the type libraries on your computer. Only use one of these other type libraries to define your connection point if you want to implement the exact same outgoing interface found in another type library. |
46 | 41 |
|
47 |
| -1. In Class View, right-click a class that implements a **BEGIN_COM_MAP** macro, point to **Add** on the shortcut menu, and click **Add Connection Point**. |
| 42 | +### Reuse a connection point interface defined in another type library |
48 | 43 |
|
49 |
| -2. In the Implement Connection Point Wizard, select a type library and an interface in the type library and click **Add**. |
| 44 | +1. In **Class View**, right-click a class that implements a `BEGIN_COM_MAP` macro, point at **Add** on the shortcut menu, and select **Add Connection Point**. |
50 | 45 |
|
51 |
| -3. Edit the .idl file to either: |
| 46 | +2. In the **Implement Connection Point Wizard**, select a type library and an interface in the type library and select **Add**. |
52 | 47 |
|
53 |
| - - Copy the dispinterface from the .idl file for the object whose event-source is being used. |
| 48 | +3. Edit the `.idl` file to either: |
54 | 49 |
|
| 50 | + - Copy the dispinterface from the `.idl` file for the object whose event-source is being used. |
55 | 51 | - Use the **importlib** instruction on that type library.
|
56 | 52 |
|
57 | 53 | ## See also
|
58 | 54 |
|
59 |
| -[Connection Point](../atl/atl-connection-points.md) |
| 55 | +[Connection Point](atl-connection-points.md) |
0 commit comments