Add a method

Use the 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 also adds the method to the class.

Add a method to your interface:

  1. From the Visual Studio main menu, choose View > Class view. In the Class View pane, expand the project node to display the interface you want to add the method to.

    Note

    You can also add methods to dispinterfaces. Unless the project is attributed, dispinterfaces are located under the library node.

  2. Right-click the name of the interface.

  3. On the shortcut menu, choose Add > Add Method.

  4. In the Add Method wizard dialog box, provide the information to create the method as described in the next section.

  5. Select OK to add the method.

Add method wizard

Add a method to an interface by using the add method wizard:

Screenshot of Add method wizard. Method name is aMethod, return type is H RESULT. Two parameters are defined: int x, bool clip

  • Method name

    Provide the method name.

  • Return type

    Type the return type or select it from the drop-down list.

  • Parameters

    Displays the method's parameters, modifiers, and types. The wizard updates the Parameters list as you add parameters.

  • +

    Add a parameter. In Parameters, type the parameter type, name, and any modifiers. For example, int x, and choose OK.

  • x

    Remove the selected parameter from the Parameters list.

  • Pencil icon

    Edit the selected parameter.

See also

Add an IDL method wizard
Add an IDL MFC method wizard
Adding functionality with code wizards