Skip to content

Latest commit

 

History

History
39 lines (26 loc) · 2.42 KB

adding-a-new-interface-in-an-atl-project.md

File metadata and controls

39 lines (26 loc) · 2.42 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Adding a New Interface in an ATL Project
Adding a New Interface in an ATL Project
11/04/2016
vc.appwiz.ATL.interface
interfaces, adding to ATL objects
Implement Interface ATL wizard
controls [ATL], interfaces
ATL projects, adding interfaces
7d34b023-2c6b-4155-aca3-d47a40968063

Adding a New Interface in an ATL Project

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.

See also

ATL Project Wizard
C++ project types in Visual Studio
Programming with ATL and C Run-Time Code
Fundamentals of ATL COM Objects
Default ATL Project Configurations