We recommend using Visual Studio 2017

Add Method Wizard


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Add Method Wizard.

Use this wizard to add a method to an interface. Depending on the project type or interface type to which you are adding a method, the wizard displays different options.

Return type
The data type returned by the method. HRESULT is recommended for all interface types, because it provides a standard way to return errors.

Interface typeDescription
Dual interfaceHRESULT. Unchangeable.
Custom interfaceHRESULT. Unchangeable.
Local custom interfaceProvide your own return type or select from the list.
DispinterfaceProvide your own return type or select from the list.
MFC ActiveX control dispinterfaceIf 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 click Custom under Select method type, select a return type from the list.

Method name
Sets the name for the method.

Interface typeDescription
ATL dual interface, custom interface, and local custom interfaceProvide your own method name.
MFC dispinterfaceProvide 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 is unchangeable.
MFC ActiveX control dispinterfaceProvide your own or select either of the stock methods DoClick and Refresh. See MFC ActiveX Controls: Adding Stock Methods for more information.

Method type
Available only for MFC ActiveX controls. If you provide a method name in the Method name box, rather than selecting a method from the list, this box is unavailable.

If you select one of the methods in the Method name list, select either the stock implementation or a custom implementation.

Method typeDescription
StockThe default. Inserts the stock implementation of the method you select in the Method name list. Return type is unchangeable if you select Stock.
CustomInserts 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.

Internal name
Available for only 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 are working with an MFC dispinterface or if you are adding a custom method to an MFC ActiveX control dispinterface.

Interface typeDescription
ATL dual interface, custom interface, and local custom interfaceNot available
MFC dispinterfaceSet to the method name by default. You can edit the internal name.
MFC ActiveX control dispinterfaceYou can set the internal name only for custom methods. Stock methods do not use an internal name.

Parameter attributes
Sets any additional attributes for parameter specified in Parameter name.

Parameter attributeDescriptionAllowed combinations
InIndicates that the parameter is passed from the calling procedure to the called procedure.in only

 in and out
OutIndicates that the pointer parameter is returned from the called procedure to the calling procedure (from the server to the client).out only

 in and out

 out and retval
RetvalIndicates that the parameter receives the return value of the member.retval and out

Parameter type
Sets the data type of the parameter. Select the type from the list.

Parameter name
Sets the name of a parameter to pass through your method. After typing the name, you must click Add to add it to the list of parameters that will pass through your method. If you do not provide a parameter name, the wizard ignores any parameter attributes (ATL only) or Parameter type selections.

Once you click Add, the parameter name appears in Parameter list.

Note If you supply a parameter name and then click Finish before you click Add, the parameter is not added to the method. You must find the method and insert the parameter manually.

Adds the parameter you specify in Parameter name, and its type and parameter attributes, to Parameter list. You must click Add to add a parameter to the list.

Removes the parameter you select in Parameter list from the list.

Parameter list
Displays all parameters and their modifiers and types currently added for the method. As you add parameters, the wizard updates Parameter list to display each parameter, with its modifier and type.

Adding a Method
IDL Attributes, Add Method Wizard