Skip to content

Commit d8c61e7

Browse files
committed
Update after review
1 parent 8bb34e0 commit d8c61e7

File tree

2 files changed

+10
-104
lines changed

2 files changed

+10
-104
lines changed
Lines changed: 10 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
description: "Learn more about: Add a method to an interface in a Visual C++ project"
33
title: "Add a method"
4-
ms.date: "03/16/2022"
4+
ms.date: "03/21/2022"
55
f1_keywords: ["vc.codewiz.method.overview", "vc.codewiz.method.idlattrib"]
66
helpviewer_keywords: ["add method wizard [C++]", "methods [C++], adding", "methods [C++], adding using wizards", "IDL attributes, add method wizard"]
77
ms.custom: devdivchpfy22
88
---
99
# Add a method
1010

11-
You can use the [add method wizard](#add-method-wizard) to add a method to an interface in your project. If the project contains a class associated with the interface, the wizard modifies the class, too.
11+
You can use the [add method wizard](#add-method-wizard) to add a method to an interface in your project. In any type of project, add interface and follow the given steps to get the **Add method** wizard. If the project contains a class associated with the interface, the wizard modifies the class, too.
1212

1313
**To add a method to your object:**
1414

@@ -21,80 +21,37 @@ You can use the [add method wizard](#add-method-wizard) to add a method to an in
2121

2222
1. On the shortcut menu, choose **Add**, and then choose **Add Method**.
2323

24-
1. In the Add Method Wizard, provide the information to create the method.
25-
26-
1. Specify interface definition language settings for the method in the [IDL attributes](#idl-attributes-add-method-wizard) page of the wizard.
24+
1. In the **Add Method** wizard, provide the information to create the method.
2725

2826
1. Select **OK** to add the method.
2927

30-
## In this section
31-
32-
- [Add method wizard](#add-method-wizard)
33-
- [IDL attributes, add method wizard](#idl-attributes-add-method-wizard)
34-
3528
## Add method wizard
3629

3730
Use this wizard to add a method to an interface.
3831

32+
:::image type="content" source="../ide/media/add-method-wizard.png" alt-text="Screenshot of Add method wizard":::
33+
3934
### Names
4035

4136
- **Method name**
4237

43-
Sets the method name.
44-
45-
|Interface type|Description|
46-
|--------------------|-----------------|
47-
|ATL dual interface, custom interface, and local custom interface|Provide your own method name.|
48-
|MFC dispinterface|Provide your own method name or select a suggested method name from the list. If you select a name from the list, the appropriate value appears in the **Return type** box, and it's unchangeable.|
49-
|MFC ActiveX control dispinterface|Provide your own or select either of the stock methods [DoClick](../mfc/reference/colecontrol-class.md#doclick) and [Refresh](../mfc/reference/colecontrol-class.md#refresh). For more information, see [MFC ActiveX controls: Adding stock methods](../mfc/mfc-activex-controls-adding-stock-methods.md).|
50-
51-
- **Internal name**
52-
53-
Available only for custom methods added to an MFC dispinterface. Sets the name used in the dispatch map, the header (`.h`) file, and the implementation (`.cpp`) file. By default, this name is the same as **Method name**. You can change the method name, if you're working with an MFC dispinterface or if you're adding a custom method to an MFC ActiveX control dispinterface.
54-
55-
|Interface type|Description|
56-
|--------------------|-----------------|
57-
|ATL dual interface, custom interface, and local custom interface|Not available.|
58-
|MFC dispinterface|Set to the method name by default. You can edit the internal name.|
59-
|MFC ActiveX control dispinterface|You can set the internal name only for custom methods. Stock methods don't use an internal name.|
38+
Sets the method name. Provide your own method name.
6039

6140
- **Return type**
6241

63-
The data type returned by the method. `HRESULT` is recommended for all interface types, as it provides a standard way to return errors.
64-
65-
|Interface type|Description|
66-
|--------------------|-----------------|
67-
|Dual interface|`HRESULT`. Unchangeable.|
68-
|Custom interface|`HRESULT`. Unchangeable.|
69-
|Local custom interface|Provide your own return type or select from the list.|
70-
|Dispinterface|Provide your own return type or select from the list.|
71-
|MFC ActiveX control dispinterface|If you implement a stock method, the return type is set to the appropriate value and is unchangeable. If you select a method from the **Method name** list and select **Custom** under **Select method type**, select a return type from the list.|
72-
73-
- **Method type**
74-
75-
Available only for MFC projects, ActiveX control projects, and ATL projects that support MFC. This field is unavailable, if you provide a method name in the **Method name**, rather than selecting a method from the list.
76-
77-
If you select one of the methods in the **Method name** list, select either the stock implementation or a custom implementation.
78-
79-
|Method type|Description|
80-
|-----------------|-----------------|
81-
|**Stock**|The default. Inserts the stock implementation of the method you select in the **Method name** list. **Return type** is unchangeable if you select **Stock**.|
82-
|**Custom**|Inserts a stub implementation of the method selected in the **Method name** list. For custom method types, you can provide your own return type, or you can select one from the **Return type** list.|
42+
The data type returned by the method. Provide your own return type or select from the list.
8343

8444
- **Parameter type**
8545

86-
Sets the data type of the parameter. You can type it or select the type from the list.
46+
Sets the data type of the parameter. You can type it with parameter name.
8747

8848
- **Parameter name**
8949

90-
Sets the name of a parameter. Select **+** to add the parameter to the list of parameters. If you don't provide a parameter name, the wizard ignores any parameter attributes (ATL only) or **Parameter type** selections.
91-
92-
> [!NOTE]
93-
> If you supply a parameter name and then select **OK** before you select **+**, the parameter isn't added to the method. You must find the method and insert the parameter manually.
50+
Sets the name of a parameter. Select **+** to add the parameter to the list of parameters.
9451

9552
- **+**
9653

97-
Adds the parameter to the list of parameters. Specify the parameter name in **Parameter name**, and its type and parameter attributes in **Parameters**.
54+
Adds the parameter to the list of parameters. Specify the parameter name and its type in **Parameters**.
9855

9956
- **x**
10057

@@ -103,54 +60,3 @@ Use this wizard to add a method to an interface.
10360
- **Parameters**
10461

10562
Displays all of the methods parameters, modifiers, and types. The wizard updates the **Parameters** list as you add parameters.
106-
107-
- **Parameter attributes**
108-
109-
Sets any other attributes for the parameter specified in **Parameter name**.
110-
1. **Infer in/out parameters values from types**
111-
112-
Infer in or out parameter values from their types.
113-
114-
1. **Set the last parameter as the return value (retval)**
115-
116-
Set the last parameter as the return value.
117-
118-
## IDL attributes, add method wizard
119-
120-
Use this page of the Add Method Wizard to specify any interface definition language (IDL) settings for the method.
121-
122-
- `id`
123-
124-
Sets the numerical ID that identifies the method. For more information, see [id](/windows/win32/Midl/id) in the *MIDL Reference*.
125-
126-
This box is unavailable for custom interfaces and isn't available for MFC dispinterfaces.
127-
128-
- `call_as`
129-
130-
Specifies the name of a remote method to which this local method can be mapped. For more information, see [call_as](/windows/win32/Midl/call-as) in the *MIDL Reference*.
131-
132-
Not available for MFC dispinterfaces.
133-
134-
- `helpcontext`
135-
136-
Specifies a context ID that lets the user view information about this method in the Help file. For more information, see [helpcontext](/windows/win32/Midl/helpcontext) in the *MIDL Reference*.
137-
138-
Not available for MFC dispinterfaces.
139-
140-
- `helpstring`
141-
142-
Specifies a character string that's used to describe the element to which it applies. It's set by default to "method *Method name*." For more information, see [helpstring](/windows/win32/Midl/helpstring) in the *MIDL Reference*.
143-
144-
Not available for MFC dispinterfaces.
145-
146-
- **Additional attributes**
147-
148-
Not available for MFC dispinterfaces.
149-
150-
|Attribute|Description|
151-
|---------------|-----------------|
152-
|`hidden`|Indicates that the method exists but shouldn't be displayed in a user-oriented browser. For more information, see [hidden](/windows/win32/Midl/hidden) in the *MIDL Reference*.|
153-
|`source`|Indicates that a member of the method is a source of events. For more information, see [source](/windows/win32/Midl/source) in the *MIDL Reference*.|
154-
|`local`|Specifies to the MIDL compiler that the method isn't remote. For more information, see [local](/windows/win32/Midl/local) in the *MIDL Reference*.|
155-
|`restricted`|Specifies that the method can't be called arbitrarily. For more information, see [restricted](/windows/win32/Midl/restricted) in the *MIDL Reference*.|
156-
|`vararg`|Specifies that the method takes a variable number of arguments. To accomplish this, the last argument must be a safe array of `VARIANT` type that contains the rest of the arguments. For more information, see [vararg](/windows/win32/Midl/vararg) in the *MIDL Reference*.|

docs/ide/media/add-method-wizard.png

12.7 KB
Loading

0 commit comments

Comments
 (0)