The Proxy Generator

The ATL proxy generator generates proxies for interfaces defined in a type library. Otherwise, hand coding these proxies would be very tedious.

Use the proxy generator when you want to support a connection point or a smart pointer. The proxy generator creates a class that represents a particular interface and its methods. For a connection point, the proxy generator also writes the code needed to broadcast a method call to all connected sinks.

For a connection point proxy, the class created derives from IConnectionPointImpl and each method enumerates the connections (making calls on each one) inside a critical section.

For a smart pointer proxy, the class derives from CComPtr. Each method simply calls through to the underlying interface. When the target interface is a dispinterface, the methods automatically call Invoke.

The proxy generator generates the class derived from IConnectionPointImpl or from CComPtr by reading the type library and implementing a function for each method. Before you can use the proxy generator, you must generate the type library. To do this, either build your project or right click on the .idl file in FileView. On the submenu that appears, click Compile ThisProj.idl where ThisProj will be the name of your project.

To generate a proxy for a Connection Point or a Smart Pointer:

  1. From the Insert menu select Component.
  2. Inside the Component Gallery, choose the ATL tab and double-click the ProxyGen icon:


    The ATL Proxy Generator dialog box appears.

  3. In the TypeLibrary name edit box, click the ... button.
  4. In the Open dialog box that appears, double-click the type library that contains the interfaces you want to wrap. A list of all the interfaces inside the type library appears in the Not selected list box. Highlight the names of the interfaces that you want to generate wrappers for.
  5. Click the -> button to move the highlighted interfaces from the Not Selected to the Selected box.
  6. For the Proxy Type, click Connection Point or Smart Pointer.
  7. Click Insert and select a file name for the proxy header.
  8. Select Save. The ATL proxy generator generates the header file.

For more information about using the ATL Proxy Generator, see the ATL Tutorial.

See Also Connection Points