Adding a New Interface in an ATL Project


For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

When you add an interface to your object or control, you create stubbed-out functions for each method in that interface. In your object or control, you can add only interfaces currently found in an existing type library. Also, the class in which you add the interface must implement the BEGIN_COM_MAP macro or, if the project is attributed, it must have the coclass attribute.

You can add a new interface to your control in one of two ways: manually or using code wizards in Class View.

To use code wizards in Class View to add an interface to an existing object or control

  1. In Class View, right-click the class name of a control. For example, a full control or composite control, or any other control class that implements a BEGIN_COM_MAP macro in its header file.

  2. On the shortcut menu, click Add, and then click Implement Interface.

  3. Select the interfaces to implement in the Implement Interface Wizard. If the interface does not exist in any available typelib, then you must add it manually to the .idl file.

To add a new interface manually

  1. Add the definition of your new interface to the .idl file.

  2. Derive your object or control from the interface.

  3. Create a new COM_INTERFACE_ENTRY for the interface or, if the project is attributed, add the coclass attribute.

  4. Implement methods on the interface.

ATL Project Wizard
Visual C++ Project Types
Creating Desktop Projects By Using Application Wizards
Programming with ATL and C Run-Time Code
Fundamentals of ATL COM Objects
Default ATL Project Configurations