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
The **Add IDL Property** wizard adds a method to an interface defined in an Interface Definition Library (IDL). To use the **Add IDL Property** wizard, your project can't support MFC.
11
+
The **Add IDL Property** wizard adds a property to an interface defined in an Interface Definition Library (IDL), such as in an ATL project that contains an `.idl` file. This wizard isn't available in projects that support MFC.
12
12
13
-
For example, if you have an ATL project, and it has an `.idl` file in it, use the following procedure to add a property to an interface.
14
-
15
-
This wizard differs from the **Add Property** wizard and **Add IDL MFC Property** wizard. The [Add Property](adding-a-property-visual-cpp.md) wizard adds a property to your project. The **Add IDL MFC Property** wizard is specific to MFC, ActiveX, or ATL projects that support MFC.
13
+
This wizard differs from the [Add Property](adding-a-property-visual-cpp.md) wizard and [Add IDL MFC Property](../mfc/reference/add-interface-definition-library-mfc-property-wizard.md) wizard in the following ways:
14
+
- The **Add Property** wizard adds a property to an interface in your project.
15
+
- The **Add IDL MFC Property** wizard is specific to MFC, ActiveX, or ATL projects that support MFC.
16
16
17
17
**To add an IDL property**
18
18
@@ -23,29 +23,31 @@ This wizard differs from the **Add Property** wizard and **Add IDL MFC Property*
23
23
> [!NOTE]
24
24
> You can also add properties to dispinterfaces, which, unless the project is attributed, are nested within the library node.
25
25
26
+
1. Right-click the name of the interface.
27
+
26
28
1. From the shortcut menu, select **Add** > **Add Property**.
27
29
28
30
1. In the **Add IDL Property** wizard, provide the information to create the property.
29
31
30
32
1. Select **OK** to add the property.
31
33
32
-
The `Get` and `Put` methods of the property are displayed as two icons in **Class View**, under the interface where it's defined. You can double-click either icon to view the property declaration in the `.idl` file.
34
+
The `Get` and `Put` methods of the property are displayed as two icons in **Class View** under the interface where it's defined. Double-click either icon to view the property declaration in the `.idl` file.
33
35
34
36
For ATL interfaces, the `Get` and `Put` functions are added to the `.cpp` and `.h` files.
35
37
36
38
## Add an IDL property wizard
37
39
38
40
The following section describes the UI that you'll use to add an IDL property:
39
41
40
-
:::image type="content" source="media/add-interface-definition-library-property-wizard.png" alt-text="Screenshot of adding IDL property to the interface.":::
42
+
:::image type="content" source="media/add-interface-definition-library-property-wizard.png" alt-text="Screenshot of Add IDL Property with two parameters: [ in ] int i and [ in ] char c. Return type is HRESULT. Property type is float.":::
41
43
42
44
-**Property name**
43
45
44
46
Sets the name of the property.
45
47
46
48
-**Property type**
47
49
48
-
Sets whether your property will have a getter, setter, or both.
50
+
The data type of the property.
49
51
50
52
-**Return type**
51
53
@@ -63,8 +65,8 @@ The following section describes the UI that you'll use to add an IDL property:
63
65
64
66
|Option|Description|
65
67
|------------|-----------------|
66
-
|**propput**|The [PropPut](../windows/attributes/propput.md) function returns a copy of the object. **propput** is the default and the most common way to make the property writable.|
67
-
|**propputref**|The [PropPutRef](../windows/attributes/propputref.md) function returns a reference to the object, rather than returning the copy of the object itself. Consider using **propputref** option for objects, such as large structs or arrays, that may have initialization overhead.|
68
+
|**`propput`**|The [`PropPut`](../windows/attributes/propput.md) function returns a copy of the object. **propput** is the default and the most common way to make the property writable.|
69
+
|**`propputref`**|The [`PropPutRef`](../windows/attributes/propputref.md) function returns a reference to the object, rather than returning the copy of the object itself. Consider using **`propputref`** option for objects, such as large structs or arrays, that may have initialization overhead.|
68
70
69
71
-**Parameters**
70
72
@@ -89,34 +91,35 @@ The following section describes the UI that you'll use to add an IDL property:
89
91
90
92
1.`helpcontext`
91
93
92
-
Specifies a context ID that lets the user view information about this property in the Help file. For more information, see [helpcontext](/windows/win32/Midl/helpcontext).
94
+
Specifies a context ID that lets the user view information about this property in the Help file. For more information, see [`helpcontext`](/windows/win32/Midl/helpcontext).
93
95
94
96
1.`helpstring`
95
97
96
-
Specifies a character string that's used to describe the element to which it applies. By default, it's set to **`property`** *Property name*. For more information, see [helpstring](/windows/win32/Midl/helpstring).
98
+
Specifies a character string that's used to describe the element to which it applies. By default, it's set to **`property`** *Property name*. For more information, see [`helpstring`](/windows/win32/Midl/helpstring).
97
99
98
100
1.`id`
99
101
100
-
Sets the numerical identifier that identifies the property. This option isn't available for properties of custom interfaces. For more information, see [id](/windows/win32/Midl/id).
102
+
Sets the numerical identifier that identifies the property. This option isn't available for properties of custom interfaces. For more information, see [`id`](/windows/win32/Midl/id).
101
103
102
104
-**Additional attributes**
103
105
104
106
Keywords in the Microsoft Interface Definition Language (MIDL) are described in detail in the [MIDL language reference](/windows/win32/midl/midl-language-reference.md).
105
107
106
108
|Option|Description|
107
109
|------------|-----------------|
108
-
|`bindable`|Indicates that the property supports data binding. For more information, see [bindable](/windows/win32/Midl/bindable).|
110
+
|`bindable`|Indicates that the property supports data binding. For more information, see [`bindable`](/windows/win32/Midl/bindable).|
109
111
|`defaultbind`|Indicates that this single, bindable property best represents the object. For more information, see [defaultbind](/windows/win32/Midl/defaultbind).|
110
-
|`defaultcollelem`|Indicates that the property is an accessor function for an element of the default collection. For more information, see [defaultcollelem](/windows/win32/Midl/defaultcollelem).|
111
-
|`displaybind`|Indicates that this property should be displayed to the user as bindable. For more information, see [displaybind](/windows/win32/Midl/displaybind).|
112
-
|`hidden`|Indicates that the property exists but shouldn't be displayed in a user-oriented browser. For more information, see [hidden](/windows/win32/Midl/hidden).|
113
-
|`immediatebind`|Indicates that the database will be notified immediately of all changes to this property of a data-bound object. For more information, see [immediatebind](/windows/win32/Midl/immediatebind).|
114
-
|`local`|Specifies to the MIDL compiler that the property isn't remote. For more information, see [local](/windows/win32/Midl/local).|
115
-
|`nonbrowsable`|Tags an interface or dispinterface member that shouldn't be displayed in a properties browser. For more information, see [nonbrowsable](/windows/win32/Midl/nonbrowsable).|
116
-
|`requestedit`|Indicates that the property supports the `OnRequestEdit` notification. For more information, see [requestedit](/windows/win32/Midl/requestedit).|
117
-
|`restricted`|Specifies that the property can't be called arbitrarily. For more information, see [restricted](/windows/win32/Midl/restricted).|
118
-
|`source`|Indicates that a member of the property is a source of events. For more information, see [source](/windows/win32/Midl/source).|
112
+
|`defaultcollelem`|Indicates that the property is an accessor function for an element of the default collection. For more information, see [`defaultcollelem`](/windows/win32/Midl/defaultcollelem).|
113
+
|`displaybind`|Indicates that this property should be displayed to the user as bindable. For more information, see [`displaybind`](/windows/win32/Midl/displaybind).|
114
+
|`hidden`|Indicates that the property exists but shouldn't be displayed in a user-oriented browser. For more information, see [`hidden`](/windows/win32/Midl/hidden).|
115
+
|`immediatebind`|Indicates that the database will be notified immediately of all changes to this property of a data-bound object. For more information, see [`immediatebind`](/windows/win32/Midl/immediatebind).|
116
+
|`local`|Specifies to the MIDL compiler that the property isn't remote. For more information, see [`local`](/windows/win32/Midl/local).|
117
+
|`nonbrowsable`|Tags an interface or dispinterface member that shouldn't be displayed in a properties browser. For more information, see [`nonbrowsable`](/windows/win32/Midl/nonbrowsable).|
118
+
|`requestedit`|Indicates that the property supports the `OnRequestEdit` notification. For more information, see [`requestedit`](/windows/win32/Midl/requestedit).|
119
+
|`restricted`|Specifies that the property can't be called arbitrarily. For more information, see [`restricted`](/windows/win32/Midl/restricted).|
120
+
|`source`|Indicates that a member of the property is a source of events. For more information, see [`source`](/windows/win32/Midl/source).|
Use the [Add Property wizard](#add-property-wizard) to add a method to an interface in your project.
12
+
Use the [Add Property wizard](#add-property-wizard) to add a property to an interface in your project.
13
13
14
14
**To add a property to your interface:**
15
15
16
-
1. From the Visual Studio main menu, select **View** > **Class view**. In the [Class View](/visualstudio/ide/viewing-the-structure-of-code) pane, expand the project node to display the interface you want to add the method to.
16
+
1. From the Visual Studio main menu, select **View** > **Class view**. In the [Class View](/visualstudio/ide/viewing-the-structure-of-code) pane, expand the project node to display the interface you want to add the property to.
17
17
18
18
> [!NOTE]
19
19
> You can also add properties to dispinterfaces, which, unless the project is attributed, are nested within the library node.
@@ -50,4 +50,10 @@ The following section describes the UI that you'll use to add a property:
50
50
51
51
Select to add a property setter. By default, the name of the `Set` function is `Set`*PropertyName*. You can edit this name. If you delete the name, the function [`SetNotSupported`](../mfc/reference/colecontrol-class.md#setnotsupported) is inserted into the interface dispatch map. The `Set`*PropertyName* function specifies that the property is writable.
52
52
53
-
For ATL interfaces **Put function** makes the property writable; that is, it creates the `Put` method for setting, or "putting," this property of the object. Select **Get**, **Put**, or both.
53
+
For ATL interfaces **Put function** makes the property writable; that is, it creates the `Put` method for setting, or "putting," this property of the object. Select **Get**, **Put**, or both.
0 commit comments