Skip to content

Commit cbf41cc

Browse files
TylerMSFTTylerMSFT
authored andcommitted
fix github issue 4666 and fix error from checkin yesterday
1 parent cbdb87e commit cbf41cc

2 files changed

Lines changed: 83 additions & 86 deletions

File tree

docs/error-messages/compiler-errors-1/compiler-error-c2039.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
22
description: "Learn more about: Compiler Error C2039"
33
title: "Compiler Error C2039"
4-
ms.date: "11/04/2016"
4+
ms.date: "8/1/2023"
55
f1_keywords: ["C2039"]
66
helpviewer_keywords: ["C2039"]
7-
ms.assetid: f9dfd521-9b36-4454-a69c-d63f45b606bb
87
---
98
# Compiler Error C2039
109

@@ -57,9 +56,9 @@ int S::get_Count() { return 0; } // C2039
5756
int S::Count::get() { return 0; } // OK
5857
```
5958
60-
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:
6160
62-
```
61+
```c#
6362
// C2039_d.cs
6463
// compile with: /target:library
6564
// a C# program
@@ -72,7 +71,7 @@ public class B {
7271
};
7372
```
7473

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:
7675

7776
```cpp
7877
// C2039_e.cpp
Lines changed: 79 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,175 +1,174 @@
11
---
22
description: "Learn more about: Connection Maps"
33
title: "Connection Maps"
4-
ms.date: "11/04/2016"
4+
ms.date: "8/1/2023"
55
helpviewer_keywords: ["connection maps"]
6-
ms.assetid: 1f25a9bc-6d09-4614-99cf-dc38e8ddfa73
76
---
87

9-
# Connection Maps
8+
# Connection maps
109

1110
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.
1211

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.
1413

1514
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:
1615

17-
### Connection Map Declaration and Demarcation
16+
### Connection Map declaration and demarcation
1817

1918
|Name|Description|
2019
|-|-|
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.|
2827

2928
The following functions assist a sink in establishing and disconnecting a connection using connection points:
3029

31-
### Initialization/Termination of Connection Points
30+
### Initialization/termination of connection points
3231

3332
|Name|Description|
3433
|-|-|
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.|
3736

38-
## <a name="begin_connection_part"></a> BEGIN_CONNECTION_PART
37+
## <a name="BEGIN_CONNECTION_PART"></a> `BEGIN_CONNECTION_PART`
3938

40-
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.
4140

42-
```
41+
```cpp
4342
BEGIN_CONNECTION_PART(theClass, localClass)
4443
```
4544

4645
### Parameters
4746

48-
*theClass*<br/>
47+
*`theClass`*
4948
Specifies the name of the control class whose connection point this is.
5049

51-
*localClass*<br/>
50+
*`localClass`*
5251
Specifies the name of the local class that implements the connection point.
5352

5453
### Remarks
5554

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.
5756

5857
### Requirements
5958

60-
**Header** afxdisp.h
59+
**Header** `afxdisp.h`
6160

62-
## <a name="end_connection_part"></a> END_CONNECTION_PART
61+
## <a name="END_CONNECTION_PART"></a> `END_CONNECTION_PART`
6362

6463
Ends the declaration of your connection point.
6564

66-
```
65+
```cpp
6766
END_CONNECTION_PART(localClass)
6867
```
6968

7069
### Parameters
7170

72-
*localClass*<br/>
71+
*`localClass`*\
7372
Specifies the name of the local class that implements the connection point.
7473

7574
### Requirements
7675

77-
**Header** afxdisp.h
76+
**Header** `afxdisp.h`
7877

79-
## <a name="connection_iid"></a> CONNECTION_IID
78+
## <a name="CONNECTION_IID"></a> `CONNECTION_IID`
8079

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.
8281

83-
```
82+
```cpp
8483
CONNECTION_IID(iid)
8584
```
8685

8786
### Parameters
8887

89-
*iid*<br/>
88+
*`iid`*\
9089
The interface ID of the interface called by the connection point.
9190

9291
### Remarks
9392

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:
9594

9695
[!code-cpp[NVC_MFCConnectionPoints#10](../../mfc/codesnippet/cpp/connection-maps_1.h)]
9796

98-
specifies a connection point that calls the `ISinkInterface` interface.
97+
Specifies a connection point that calls the `ISinkInterface` interface.
9998

10099
### Requirements
101100

102-
**Header** afxdisp.h
101+
**Header** `afxdisp.h`
103102

104-
## <a name="declare_connection_map"></a> DECLARE_CONNECTION_MAP
103+
## <a name="DECLARE_CONNECTION_MAP"></a> `DECLARE_CONNECTION_MAP`
105104

106105
Each `COleControl`-derived class in your program can provide a connection map to specify additional connection points that your control supports.
107106

108-
```
107+
```cpp
109108
DECLARE_CONNECTION_MAP()
110109
```
111110

112111
### Remarks
113112

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.
115114

116115
### Requirements
117116

118-
**Header** afxdisp.h
117+
**Header** `afxdisp.h`
119118

120-
## <a name="begin_connection_map"></a> BEGIN_CONNECTION_MAP
119+
## <a name="BEGIN_CONNECTION_MAP"></a> `BEGIN_CONNECTION_MAP`
121120

122121
Each `COleControl`-derived class in your program can provide a connection map to specify connection points that your control will support.
123122

124-
```
123+
```cpp
125124
BEGIN_CONNECTION_MAP(theClass, theBase)
126125
```
127126

128127
### Parameters
129128

130-
*theClass*<br/>
129+
*`theClass`*\
131130
Specifies the name of the control class whose connection map this is.
132131

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`*.
135134

136135
### Remarks
137136

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.
139138

140139
### Requirements
141140

142-
**Header** afxdisp.h
141+
**Header** `afxdisp.h`
143142

144-
## <a name="end_connection_map"></a> END_CONNECTION_MAP
143+
## <a name="END_CONNECTION_MAP"></a> `END_CONNECTION_MAP`
145144

146145
Ends the definition of your connection map.
147146

148-
```
147+
```cpp
149148
END_CONNECTION_MAP()
150149
```
151150

152151
### Requirements
153152

154-
**Header** afxdisp.h
153+
**Header** `afxdisp.h`
155154

156-
## <a name="connection_part"></a> CONNECTION_PART
155+
## <a name="CONNECTION_PART"></a> `CONNECTION_PART`
157156

158157
Maps a connection point for your OLE control to a specific interface ID.
159158

160-
```
159+
```cpp
161160
CONNECTION_PART(theClass, iid, localClass)
162161
```
163162

164163
### Parameters
165164

166-
*theClass*<br/>
165+
*`theClass`*\
167166
Specifies the name of the control class whose connection point this is.
168167

169-
*iid*<br/>
168+
*`iid`*\
170169
The interface ID of the interface called by the connection point.
171170

172-
*localClass*<br/>
171+
*`localClass`*\
173172
Specifies the name of the local class that implements the connection point.
174173

175174
### Remarks
@@ -182,13 +181,13 @@ implements a connection map, with a connection point, that calls the `IID_ISinkI
182181

183182
### Requirements
184183

185-
**Header** afxdisp.h
184+
**Header** `afxdisp.h`
186185

187-
## <a name="afxconnectionadvise"></a> AfxConnectionAdvise
186+
## <a name="AfxConnectionAdvise"></a> `AfxConnectionAdvise`
188187

189-
Call this function to establish a connection between a source, specified by *pUnkSrc*, and a sink, specified by *pUnkSink*.
188+
Call this function to establish a connection between a source, specified by *`pUnkSrc`*, and a sink, specified by *`pUnkSink`*.
190189

191-
```
190+
```cpp
192191
BOOL AFXAPI AfxConnectionAdvise(
193192
LPUNKNOWN pUnkSrc,
194193
REFIID iid,
@@ -199,24 +198,24 @@ BOOL AFXAPI AfxConnectionAdvise(
199198
200199
### Parameters
201200
202-
*pUnkSrc*<br/>
201+
*`pUnkSrc`*\
203202
A pointer to the object that calls the interface.
204203
205-
*pUnkSink*<br/>
204+
*`pUnkSink`*\
206205
A pointer to the object that implements the interface.
207206
208-
*iid*<br/>
207+
*`iid`*\
209208
The interface ID of the connection.
210209
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.
213212
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.
215214
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`.
217216
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.
220219
221220
### Return Value
222221
@@ -228,13 +227,13 @@ Nonzero if a connection was established; otherwise 0.
228227
229228
### Requirements
230229
231-
**Header:** afxctl.h
230+
**Header:** `afxctl.h`
232231
233-
## <a name="afxconnectionunadvise"></a> AfxConnectionUnadvise
232+
## <a name="AfxConnectionUnadvise"></a> `AfxConnectionUnadvise`
234233
235-
Call this function to disconnect a connection between a source, specified by *pUnkSrc*, and a sink, specified by *pUnkSink*.
234+
Call this function to disconnect a connection between a source, specified by *pUnkSrc*, and a sink, specified by *`pUnkSink`*.
236235
237-
```
236+
```cpp
238237
BOOL AFXAPI AfxConnectionUnadvise(
239238
LPUNKNOWN pUnkSrc,
240239
REFIID iid,
@@ -245,26 +244,26 @@ BOOL AFXAPI AfxConnectionUnadvise(
245244

246245
### Parameters
247246

248-
*pUnkSrc*<br/>
247+
*`pUnkSrc`*\
249248
A pointer to the object that calls the interface.
250249

251-
*pUnkSink*<br/>
250+
*`pUnkSink`*\
252251
A pointer to the object that implements the interface.
253252

254-
*iid*<br/>
253+
*`iid`*\
255254
The interface ID of the connection point interface.
256255

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.
259258

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.
261260

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`.
263262

264-
*dwCookie*<br/>
265-
The connection identifier returned by `AfxConnectionAdvise`.
263+
*`dwCookie`*\
264+
The connection identifier returned by ``AfxConnectionAdvise``.
266265

267-
### Return Value
266+
### Return value
268267

269268
Nonzero if a connection was disconnected; otherwise 0.
270269

@@ -278,5 +277,4 @@ Nonzero if a connection was disconnected; otherwise 0.
278277

279278
## See also
280279

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

Comments
 (0)