This sample shows how different COM interface map entry macros are used. The text on each button below indicates the type of the map entry used to expose each interface on the outer object. When a button is pressed, the GetName() method on the outer object is called. This method calls QueryInterface on the controlling unknown for the interface exposed using the particular type of map entry you chose. GetName() retrieves the Name property of the returned interface, and the name is displayed on the button.


This macro is used very frequently. Its job is to expose an interface that you have multiply-inherited into your object.


This macro exposes a tear-off interface. Tear-off interfaces are implemented using a seperate class. They are typically used for interfaces that not commonly required at runtime.


Cached tear-off interfaces are similar to a tear-off interface. Regular tear-off interfaces are created on every QueryInterface for the IID they implement. A cached tear-off instantiates the implementing object only the first time the interface is requested, and responds to subsequent requests for that interface by reusing the existing instance.


This macro causes the COM_MAP to chain to another COM_MAP. You can imagine the other COM_MAP inserted at the position you use this macro.


Exposes an interface from an object that you are aggregating on. The punk parameter is the inner unknown of the aggregate.


Autoaggregate implements delayed aggregation, which means that ATL will automatically create and aggregate on the inner object when someone QIs for this interface. This only happens if the aggregate hasn't already been created--that is, only when punk is not NULL.


This macro causes ATL to blindly exposes all the interfaces on an aggregate.


Combines delayed (AUTOAGGREGATE) and blind (AUTOAGGREGATE_BLIND) aggregation.



Best experienced with
Microsoft Internet Explorer