CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2002
    Posts
    77

    Events of an aggregated object

    Hi COM gurus,

    here comes a nice question for you:

    I've a simple COM object (named for example InnerObject) which fires events.
    Now I'm aggregating this inner object in a second object (say OuterObject).

    When I create an OuterObject it works fine to query interface for InnerObject and call the methods of InnerObjects.
    But how can I catch the events of InnerObject (create an event sink)?

    Thanks for any help.

    Alpha137

  2. #2
    Join Date
    Mar 2002
    Location
    Izhevsk, Udmurtia, Russia
    Posts
    930
    By usual way. OuterObject will be the common client of InnerObject.
    With best wishes,
    Vita
    -----------------------
    Russian Software Development Network -- http://www.rsdn.ru

  3. #3
    Join Date
    Sep 2002
    Posts
    77
    Hello Vita,

    thanks for your fast reply but I don't understand.

    To keep it small and simple I've tested it under VB:
    Code:
    Public WithEvents inner As InnerObject
    
    Private Sub DoIt()
    Dim outer As New OuterObject
    
    Set inner = outer
    End Sub
    This gives me a 'runtime error 459: object or class does not support the set of events'.
    Is this just another VB restriction?

    Alpha137

  4. #4
    Join Date
    Mar 2002
    Location
    Izhevsk, Udmurtia, Russia
    Posts
    930
    If
    Private WithEvents inner As InnerObject
    will not help you, then it's not VB limitation. It's your problem with OuterObject and InnerObject objects or their TypeLib.

    Your InnerObject coclass must have
    Code:
    [uuid(...),helpstring("InnerObject Class")]
    coclass CInnerObject
    {
    	[default] interface InnerObject;
    	[default, source] dispinterface _InnerObjectEvents;
    };
    Also the OuterObject class must redirect all interface's Query to InnerObject class. Something like
    Code:
    BEGIN_COM_MAP(COuterObject)
    ...
    	COM_INTERFACE_ENTRY_AGGREGATE_BLIND(pInnerObject)
    ***EDIT***
    Or other COM_INTERFACE_ENTRY_***AGGREGATE*** macros family.
    Last edited by Vi2; January 17th, 2003 at 08:58 AM.
    With best wishes,
    Vita
    -----------------------
    Russian Software Development Network -- http://www.rsdn.ru

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured