Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Multiple Inheritance by IDispatch

Multiple Inheritance by IDispatch

Scheduled Pinned Locked Moved ATL / WTL / STL
helpcomoopquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ajitatif angajetor
    wrote on last edited by
    #1

    Hi everyone, I have a class that implements an interface that derives from IDispatch directly,and I want to add a new interface which also derives from IDispatch,and then derive my class from this interface too.Expectedly,my problem is ambiguouty (did I spell it correctly??).I use COM_INTERFACE_ENTRY2 macro,but i keep getting error "cannot instantiate abstract class" error in atlcom.h this is the IDL file:

    library TheLibrary
    {
    	importlib("stdole2.tlb");
    	[
    		object,
    		uuid(),
    		dual,
    		nonextensible,
    		helpstring("Primary dispatch interface for the class."),
    		pointer_default(unique)
    	]
    	interface ISomething : IDispatch
    	{
    	};
    
    	[
    		uuid(),
    		helpstring("help string.")
    	]
    	coclass CSomething
    	{
    		[default] interface ISomething};
    
    	[
    		uuid(),
    		nonextensible,
    		helpstring("the new Interface"),
    	]
    	dispinterface INewInterface
    	{
    	properties:
    	methods:
    			[id(0), helpstring("method default"), local] HRESULT DefaultMethod(void);
            };
    

    and this is the COM mapping

    	BEGIN_COM_MAP(CSomething)
    		COM_INTERFACE_ENTRY(ISomething)
    		COM_INTERFACE_ENTRY2(IDispatch, ISomething)
    		COM_INTERFACE_ENTRY(IObjectWithSite)
    		COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IDeskBand)
    		COM_INTERFACE_ENTRY_IID(IID_IDockingWindow, IDeskBand)
    		COM_INTERFACE_ENTRY(IDeskBand)
    		COM_INTERFACE_ENTRY_IID(IID_IInputObject,IInputObject)
    		COM_INTERFACE_ENTRY(IPropertyNotifySink)
    		COM_INTERFACE_ENTRY(INewInterface)
    	END_COM_MAP()
    

    I tried using interface instead of dispinterface.Didn't help either.I know I'm missing something,but can't figure out what it is...

    S 1 Reply Last reply
    0
    • A ajitatif angajetor

      Hi everyone, I have a class that implements an interface that derives from IDispatch directly,and I want to add a new interface which also derives from IDispatch,and then derive my class from this interface too.Expectedly,my problem is ambiguouty (did I spell it correctly??).I use COM_INTERFACE_ENTRY2 macro,but i keep getting error "cannot instantiate abstract class" error in atlcom.h this is the IDL file:

      library TheLibrary
      {
      	importlib("stdole2.tlb");
      	[
      		object,
      		uuid(),
      		dual,
      		nonextensible,
      		helpstring("Primary dispatch interface for the class."),
      		pointer_default(unique)
      	]
      	interface ISomething : IDispatch
      	{
      	};
      
      	[
      		uuid(),
      		helpstring("help string.")
      	]
      	coclass CSomething
      	{
      		[default] interface ISomething};
      
      	[
      		uuid(),
      		nonextensible,
      		helpstring("the new Interface"),
      	]
      	dispinterface INewInterface
      	{
      	properties:
      	methods:
      			[id(0), helpstring("method default"), local] HRESULT DefaultMethod(void);
              };
      

      and this is the COM mapping

      	BEGIN_COM_MAP(CSomething)
      		COM_INTERFACE_ENTRY(ISomething)
      		COM_INTERFACE_ENTRY2(IDispatch, ISomething)
      		COM_INTERFACE_ENTRY(IObjectWithSite)
      		COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IDeskBand)
      		COM_INTERFACE_ENTRY_IID(IID_IDockingWindow, IDeskBand)
      		COM_INTERFACE_ENTRY(IDeskBand)
      		COM_INTERFACE_ENTRY_IID(IID_IInputObject,IInputObject)
      		COM_INTERFACE_ENTRY(IPropertyNotifySink)
      		COM_INTERFACE_ENTRY(INewInterface)
      	END_COM_MAP()
      

      I tried using interface instead of dispinterface.Didn't help either.I know I'm missing something,but can't figure out what it is...

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      ajitatif angajetor wrote:

      ambiguouty (did I spell it correctly??)

      No - ambiguity - close, though :-) Anyway - I've had a look through my code collection - I have a class that implements two IDispatch interfaces, in ATL 3.0 (it's an old VC6 project). Here's the relevant bit of the IDL:

      [
          uuid(01b836c6-51c8-4476-bf15-ae91b0fe74f6),
          oleautomation,
          dual
      ]
      interface ICommands : IDispatch
      {
          [id(1), helpstring("method RereadEnvironment")] 
          HRESULT RereadEnvironment();
      };
      
      [ hidden, uuid(0309A24D-B3E7-4C6A-8ACD-B3F0F8FAA483) ]
      coclass ApplicationEvents
      {
          [default] dispinterface IDispApplicationEvents;
      }
      
      [
          uuid(6c5658bc-946b-4bc7-94bf-5530cad3d654)
      ]
      coclass Commands
      {
          [default] interface ICommands;
      };
      

      and code

      class ATL_NO_VTABLE CCommands : 
          public CComObjectRootEx<CComSingleThreadModel>,
          public CComCoClass<CCommands, &CLSID_Commands>,
          public IDispatchImpl<ICommands, &IID_ICommands, &LIBID_DSWENVLib>,
          public IDispatchImpl<IApplicationEvents, &IID_IApplicationEvents, &LIBID_DSWENVLib>
      {
      
      BEGIN_COM_MAP(CCommands)
          COM_INTERFACE_ENTRY(ICommands)
          COM_INTERFACE_ENTRY2(IDispatch, ICommands)
          COM_INTERFACE_ENTRY(IApplicationEvents)
      END_COM_MAP()
      DECLARE_NOT_AGGREGATABLE(CCommands)
      
         <class continues>
      

      Don't know if there's anything obvious there - the COM map looks very similar to yours - what about the inheritance? Do you have an IDispatchImpl inheritance for each IDispatch interface you want to implement?

      A 1 Reply Last reply
      0
      • S Stuart Dootson

        ajitatif angajetor wrote:

        ambiguouty (did I spell it correctly??)

        No - ambiguity - close, though :-) Anyway - I've had a look through my code collection - I have a class that implements two IDispatch interfaces, in ATL 3.0 (it's an old VC6 project). Here's the relevant bit of the IDL:

        [
            uuid(01b836c6-51c8-4476-bf15-ae91b0fe74f6),
            oleautomation,
            dual
        ]
        interface ICommands : IDispatch
        {
            [id(1), helpstring("method RereadEnvironment")] 
            HRESULT RereadEnvironment();
        };
        
        [ hidden, uuid(0309A24D-B3E7-4C6A-8ACD-B3F0F8FAA483) ]
        coclass ApplicationEvents
        {
            [default] dispinterface IDispApplicationEvents;
        }
        
        [
            uuid(6c5658bc-946b-4bc7-94bf-5530cad3d654)
        ]
        coclass Commands
        {
            [default] interface ICommands;
        };
        

        and code

        class ATL_NO_VTABLE CCommands : 
            public CComObjectRootEx<CComSingleThreadModel>,
            public CComCoClass<CCommands, &CLSID_Commands>,
            public IDispatchImpl<ICommands, &IID_ICommands, &LIBID_DSWENVLib>,
            public IDispatchImpl<IApplicationEvents, &IID_IApplicationEvents, &LIBID_DSWENVLib>
        {
        
        BEGIN_COM_MAP(CCommands)
            COM_INTERFACE_ENTRY(ICommands)
            COM_INTERFACE_ENTRY2(IDispatch, ICommands)
            COM_INTERFACE_ENTRY(IApplicationEvents)
        END_COM_MAP()
        DECLARE_NOT_AGGREGATABLE(CCommands)
        
           <class continues>
        

        Don't know if there's anything obvious there - the COM map looks very similar to yours - what about the inheritance? Do you have an IDispatchImpl inheritance for each IDispatch interface you want to implement?

        A Offline
        A Offline
        ajitatif angajetor
        wrote on last edited by
        #3

        :-D uuuuuuh,no. I added an IDispEventImpl to inheritance list and it worked.Great help,thanks:)

        S 1 Reply Last reply
        0
        • A ajitatif angajetor

          :-D uuuuuuh,no. I added an IDispEventImpl to inheritance list and it worked.Great help,thanks:)

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          Cool - glad I could help :-)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups