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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. COM
  4. COM and deriveing

COM and deriveing

Scheduled Pinned Locked Moved COM
comhelpquestion
4 Posts 4 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.
  • O Offline
    O Offline
    orafal
    wrote on last edited by
    #1

    Hello, is it possible to create a COM objects structure as below: In a dll library I define:

    class T1
    {
    public:
    STDMETHOD(Method)();
    }

    STDMETHODIMP T1::Method()
    {
    AFX_MANAGE_STATE(AfxGetStaticModuleState())

    return S_OK;
    }

    which implements interface:

    interface IT1 : IDispatch
    {
    [id(1)] HRESULT Method();
    };

    coclass T1
    {
    [default] interface IT1;
    };

    and then I would like to have:

    class T2 : public T1
    {
    //something additional
    }

    I would like to create a COM objects from the class T2 and have all the functionality provided by class T1. E.g. I would like to call:

    CComQIPtr spiT1(piT2);
    spiT1->Method();

    Anyone can help?

    K _ C 3 Replies Last reply
    0
    • O orafal

      Hello, is it possible to create a COM objects structure as below: In a dll library I define:

      class T1
      {
      public:
      STDMETHOD(Method)();
      }

      STDMETHODIMP T1::Method()
      {
      AFX_MANAGE_STATE(AfxGetStaticModuleState())

      return S_OK;
      }

      which implements interface:

      interface IT1 : IDispatch
      {
      [id(1)] HRESULT Method();
      };

      coclass T1
      {
      [default] interface IT1;
      };

      and then I would like to have:

      class T2 : public T1
      {
      //something additional
      }

      I would like to create a COM objects from the class T2 and have all the functionality provided by class T1. E.g. I would like to call:

      CComQIPtr spiT1(piT2);
      spiT1->Method();

      Anyone can help?

      K Offline
      K Offline
      kcynic
      wrote on last edited by
      #2

      have you had a try? if it didn't work, maybe you could define a new interface: interface IT2:IT1

      1 Reply Last reply
      0
      • O orafal

        Hello, is it possible to create a COM objects structure as below: In a dll library I define:

        class T1
        {
        public:
        STDMETHOD(Method)();
        }

        STDMETHODIMP T1::Method()
        {
        AFX_MANAGE_STATE(AfxGetStaticModuleState())

        return S_OK;
        }

        which implements interface:

        interface IT1 : IDispatch
        {
        [id(1)] HRESULT Method();
        };

        coclass T1
        {
        [default] interface IT1;
        };

        and then I would like to have:

        class T2 : public T1
        {
        //something additional
        }

        I would like to create a COM objects from the class T2 and have all the functionality provided by class T1. E.g. I would like to call:

        CComQIPtr spiT1(piT2);
        spiT1->Method();

        Anyone can help?

        _ Offline
        _ Offline
        _Superman_
        wrote on last edited by
        #3

        Although this would work, T2 would be an ordinary class while T1 is a com class.

        «_Superman_» I love work. It gives me something to do between weekends.

        1 Reply Last reply
        0
        • O orafal

          Hello, is it possible to create a COM objects structure as below: In a dll library I define:

          class T1
          {
          public:
          STDMETHOD(Method)();
          }

          STDMETHODIMP T1::Method()
          {
          AFX_MANAGE_STATE(AfxGetStaticModuleState())

          return S_OK;
          }

          which implements interface:

          interface IT1 : IDispatch
          {
          [id(1)] HRESULT Method();
          };

          coclass T1
          {
          [default] interface IT1;
          };

          and then I would like to have:

          class T2 : public T1
          {
          //something additional
          }

          I would like to create a COM objects from the class T2 and have all the functionality provided by class T1. E.g. I would like to call:

          CComQIPtr spiT1(piT2);
          spiT1->Method();

          Anyone can help?

          C Offline
          C Offline
          CurtD
          wrote on last edited by
          #4

          I think you want to use aggregation. "To expose the interfaces of one COM class as though they were implemented on a second COM class, the second class aggregates the first. "

          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