visual-c++comatl

Visual C++: ATL Implementation of an Interface


I guess this is a real dumb question, but I couldn't find an answer. I'm trying to implement an COM interface using ATL. According to this I should use the Implement Interface Wizard. My question is how can I find the desired interface in this wizard. Do I have to go over all the libraries? Does is specified somewhere in the documentation of the interface (IOleCommandTarget)


Solution

  • To implement an interface you need:

    For example:

    class CFoo : 
      // regular COM object base class, esp. those generated by ATL Simple Object Class Wizard
      public IOleCommandTarget
    {
    
    BEGIN_COM_MAP(CFoo)
      // ...
      COM_INTERFACE_ENTRY(IOleCommandTarget)
    END_COM_MAP()
    
    // ...
    
    public:
    // IOleCommandTarget
      STDMETHOD(Exec)(...) // IOleCommandTarget methods go here
      {
        // ...
      }
    };