You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
C2039 can also occur if you attempt to access a default indexer incorrectly. The following sample defines a component authored in C#.
59
+
C2039 can also occur if you attempt to access a default indexer incorrectly. To demonstrate, the following code defines a component authored in C# that will be accessed by the C++/CLI code that follows:
61
60
62
-
```
61
+
```c#
63
62
// C2039_d.cs
64
63
// compile with: /target:library
65
64
// a C# program
@@ -72,7 +71,7 @@ public class B {
72
71
};
73
72
```
74
73
75
-
The following sample generates C2039.
74
+
The following sample generates C2039 when it uses the previously defined C# component's default indexer incorrectly from C++/CLI:
OLE controls are able to expose interfaces to other applications. These interfaces only allow access from a container into that control. If an OLE control wants to access external interfaces of other OLE objects, a connection point must be established. This connection point allows a control outgoing access to external dispatch maps, such as event maps or notification functions.
12
11
13
-
The Microsoft Foundation Class Library offers a programming model that supports connection points. In this model, "connection maps" are used to designate interfaces or connection points for the OLE control. Connection maps contain one macro for each connection point. For more information on connection maps, see the [CConnectionPoint](../../mfc/reference/cconnectionpoint-class.md) class.
12
+
The Microsoft Foundation Class Library offers a programming model that supports connection points. In this model, "connection maps" are used to designate interfaces or connection points for the OLE control. Connection maps contain one macro for each connection point. For more information on connection maps, see the [`CConnectionPoint`](../../mfc/reference/cconnectionpoint-class.md) class.
14
13
15
14
Typically, a control supports just two connection points: one for events and one for property notifications. These are implemented by the `COleControl` base class and require no extra work by the control writer. Any other connection points you want to implement in your class must be added manually. To support connection maps and points, MFC provides the following macros:
16
15
17
-
### Connection Map Declaration and Demarcation
16
+
### Connection Map declaration and demarcation
18
17
19
18
|Name|Description|
20
19
|-|-|
21
-
|[BEGIN_CONNECTION_PART](#begin_connection_part)|Declares an embedded class that implements an additional connection point (must be used in the class declaration).|
22
-
|[END_CONNECTION_PART](#end_connection_part)|Ends the declaration of a connection point (must be used in the class declaration).|
23
-
|[CONNECTION_IID](#connection_iid)|Specifies the interface ID of the control's connection point.|
24
-
|[DECLARE_CONNECTION_MAP](#declare_connection_map)|Declares that a connection map will be used in a class (must be used in the class declaration).|
25
-
|[BEGIN_CONNECTION_MAP](#begin_connection_map)|Begins the definition of a connection map (must be used in the class implementation).|
26
-
|[END_CONNECTION_MAP](#end_connection_map)|Ends the definition of a connection map (must be used in the class implementation).|
27
-
|[CONNECTION_PART](#connection_part)|Specifies a connection point in the control's connection map.|
20
+
|[`BEGIN_CONNECTION_PART`](#BEGIN_CONNECTION_PART)|Declares an embedded class that implements an additional connection point (must be used in the class declaration).|
21
+
|[`END_CONNECTION_PART`](#END_CONNECTION_PART)|Ends the declaration of a connection point (must be used in the class declaration).|
22
+
|[`CONNECTION_IID`](#CONNECTION_IID)|Specifies the interface ID of the control's connection point.|
23
+
|[`DECLARE_CONNECTION_MAP`](#DECLARE_CONNECTION_MAP)|Declares that a connection map will be used in a class (must be used in the class declaration).|
24
+
|[`BEGIN_CONNECTION_MAP`](#BEGIN_CONNECTION_MAP)|Begins the definition of a connection map (must be used in the class implementation).|
25
+
|[`END_CONNECTION_MAP`](#END_CONNECTION_MAP)|Ends the definition of a connection map (must be used in the class implementation).|
26
+
|[`CONNECTION_PART`](#CONNECTION_PART)|Specifies a connection point in the control's connection map.|
28
27
29
28
The following functions assist a sink in establishing and disconnecting a connection using connection points:
30
29
31
-
### Initialization/Termination of Connection Points
30
+
### Initialization/termination of connection points
32
31
33
32
|Name|Description|
34
33
|-|-|
35
-
|[AfxConnectionAdvise](#afxconnectionadvise)|Establishes a connection between a source and a sink.|
36
-
|[AfxConnectionUnadvise](#afxconnectionunadvise)|Breaks a connection between a source and a sink.|
34
+
|[`AfxConnectionAdvise`](#AfxConnectionAdvise)|Establishes a connection between a source and a sink.|
35
+
|[`AfxConnectionUnadvise`](#AfxConnectionUnadvise)|Breaks a connection between a source and a sink.|
Use the BEGIN_CONNECTION_PART macro to begin the definition of additional connection points beyond the event and property notification connection points.
39
+
Use the `BEGIN_CONNECTION_PART` macro to begin the definition of additional connection points beyond the event and property notification connection points.
41
40
42
-
```
41
+
```cpp
43
42
BEGIN_CONNECTION_PART(theClass, localClass)
44
43
```
45
44
46
45
### Parameters
47
46
48
-
*theClass*<br/>
47
+
*`theClass`*
49
48
Specifies the name of the control class whose connection point this is.
50
49
51
-
*localClass*<br/>
50
+
*`localClass`*
52
51
Specifies the name of the local class that implements the connection point.
53
52
54
53
### Remarks
55
54
56
-
In the declaration (.h) file that defines the member functions for your class, start the connection point with the BEGIN_CONNECTION_PART macro. Then add the CONNECTION_IID macro and any other member functions you wish to implement. Finally, complete the connection point map with the END_CONNECTION_PART macro.
55
+
In the declaration (`.h`) file that defines the member functions for your class, start the connection point with the `BEGIN_CONNECTION_PART` macro. Then add the `CONNECTION_IID` macro and any other member functions you wish to implement. Finally, complete the connection point map with the `END_CONNECTION_PART` macro.
Specifies the name of the local class that implements the connection point.
74
73
75
74
### Requirements
76
75
77
-
**Header** afxdisp.h
76
+
**Header**`afxdisp.h`
78
77
79
-
## <aname="connection_iid"></a> CONNECTION_IID
78
+
## <aname="CONNECTION_IID"></a> `CONNECTION_IID`
80
79
81
-
Use between the BEGIN_CONNECTION_PART and END_CONNECTION_PART macros to define an interface ID for a connection point supported by your OLE control.
80
+
Use between the `BEGIN_CONNECTION_PART` and `END_CONNECTION_PART` macros to define an interface ID for a connection point supported by your OLE control.
82
81
83
-
```
82
+
```cpp
84
83
CONNECTION_IID(iid)
85
84
```
86
85
87
86
### Parameters
88
87
89
-
*iid*<br/>
88
+
*`iid`*\
90
89
The interface ID of the interface called by the connection point.
91
90
92
91
### Remarks
93
92
94
-
The *iid* argument is an interface ID used to identify the interface that the connection point calls on its connected sinks. For example:
93
+
The *`iid`* argument is an interface ID used to identify the interface that the connection point calls on its connected sinks. For example:
Each `COleControl`-derived class in your program can provide a connection map to specify additional connection points that your control supports.
107
106
108
-
```
107
+
```cpp
109
108
DECLARE_CONNECTION_MAP()
110
109
```
111
110
112
111
### Remarks
113
112
114
-
If your control supports additional points, use the DECLARE_CONNECTION_MAP macro at the end of your class declaration. Then, in the .cpp file that defines the member functions for the class, use the BEGIN_CONNECTION_MAP macro, CONNECTION_PART macros for each of the control's connection points, and the END_CONNECTION_MAP macro to declare the end of the connection map.
113
+
If your control supports additional points, use the `DECLARE_CONNECTION_MAP` macro at the end of your class declaration. Then, in the .cpp file that defines the member functions for the class, use the `BEGIN_CONNECTION_MAP` macro, `CONNECTION_PART` macros for each of the control's connection points, and the `END_CONNECTION_MAP` macro to declare the end of the connection map.
Each `COleControl`-derived class in your program can provide a connection map to specify connection points that your control will support.
123
122
124
-
```
123
+
```cpp
125
124
BEGIN_CONNECTION_MAP(theClass, theBase)
126
125
```
127
126
128
127
### Parameters
129
128
130
-
*theClass*<br/>
129
+
*`theClass`*\
131
130
Specifies the name of the control class whose connection map this is.
132
131
133
-
*theBase*<br/>
134
-
Specifies the name of the base class of *theClass*.
132
+
*`theBase`*\
133
+
Specifies the name of the base class of *`theClass`*.
135
134
136
135
### Remarks
137
136
138
-
In the implementation (.CPP) file that defines the member functions for your class, start the connection map with the BEGIN_CONNECTION_MAP macro, then add macro entries for each of your connection points using the [CONNECTION_PART](#connection_part) macro. Finally, complete the connection map with the [END_CONNECTION_MAP](#end_connection_map) macro.
137
+
In the implementation (`.CPP`) file that defines the member functions for your class, start the connection map with the `BEGIN_CONNECTION_MAP` macro, then add macro entries for each of your connection points using the [`CONNECTION_PART`](#CONNECTION_PART) macro. Finally, complete the connection map with the [`END_CONNECTION_MAP`](#END_CONNECTION_MAP) macro.
A pointer to the object that implements the interface.
207
206
208
-
*iid*<br/>
207
+
*`iid`*\
209
208
The interface ID of the connection.
210
209
211
-
*bRefCount*<br/>
212
-
For out-of-process connections, this parameter must be TRUE, and indicates that creating the connection should cause the reference count of *pUnkSink* to be incremented.
210
+
*`bRefCount`*\
211
+
For out-of-process connections, this parameter must be `TRUE`, and indicates that creating the connection should cause the reference count of *`pUnkSink`* to be incremented.
213
212
214
-
For in-process connections, TRUE indicates that creating the connection should cause the reference count of *pUnkSink* to be incremented. FALSE indicates that the reference count should not be incremented.
213
+
For in-process connections, `TRUE` indicates that creating the connection should cause the reference count of *`pUnkSink`* to be incremented. `FALSE` indicates that the reference count should not be incremented.
215
214
216
-
**Warning**: In general, it can't be predicted which connections are in-process and which connections are out-of-process, so it is recommended to always set this parameter to TRUE.
215
+
**Warning**: In general, it can't be predicted which connections are in-process and which connections are out-of-process, so it is recommended to always set this parameter to `TRUE`.
217
216
218
-
*pdwCookie.*<br/>
219
-
A pointer to a DWORD where a connection identifier is returned. This value should be passed as the *dwCookie* parameter to `AfxConnectionUnadvise` when disconnecting the connection.
217
+
*`pdwCookie`*\
218
+
A pointer to a `DWORD` where a connection identifier is returned. This value should be passed as the *`dwCookie`* parameter to `AfxConnectionUnadvise` when disconnecting the connection.
220
219
221
220
### Return Value
222
221
@@ -228,13 +227,13 @@ Nonzero if a connection was established; otherwise 0.
A pointer to the object that implements the interface.
253
252
254
-
*iid*<br/>
253
+
*`iid`*\
255
254
The interface ID of the connection point interface.
256
255
257
-
*bRefCount*<br/>
258
-
For out-of-process connections, this parameter must be TRUE, and indicates that creating the connection should cause the reference count of *pUnkSink* to be decremented.
256
+
*`bRefCount`*\
257
+
For out-of-process connections, this parameter must be `TRUE`, and indicates that creating the connection should cause the reference count of *`pUnkSink`* to be decremented.
259
258
260
-
For in-process connections, TRUE indicates that creating the connection should cause the reference count of *pUnkSink* to be decremented. FALSE indicates that the reference count should not be decremented.
259
+
For in-process connections, `TRUE` indicates that creating the connection should cause the reference count of *`pUnkSink`* to be decremented. `FALSE` indicates that the reference count should not be decremented.
261
260
262
-
**Warning**: In general, it cannot be predicted which connections are in-process and which connections are out-of-process, so it is recommended to always set this parameter to TRUE.
261
+
**Warning**: In general, it cannot be predicted which connections are in-process and which connections are out-of-process, so it is recommended to always set this parameter to `TRUE`.
263
262
264
-
*dwCookie*<br/>
265
-
The connection identifier returned by `AfxConnectionAdvise`.
263
+
*`dwCookie`*\
264
+
The connection identifier returned by ``AfxConnectionAdvise``.
266
265
267
-
### Return Value
266
+
### Return value
268
267
269
268
Nonzero if a connection was disconnected; otherwise 0.
270
269
@@ -278,5 +277,4 @@ Nonzero if a connection was disconnected; otherwise 0.
278
277
279
278
## See also
280
279
281
-
[Macros and Globals](../../mfc/reference/mfc-macros-and-globals.md)
282
-
280
+
[Macros and Globals](../../mfc/reference/mfc-macros-and-globals.md)
0 commit comments