-
January 17th, 2003, 04:59 AM
#1
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
-
January 17th, 2003, 05:40 AM
#2
By usual way. OuterObject will be the common client of InnerObject.
With best wishes,
Vita
-----------------------
Russian Software Development Network -- http://www.rsdn.ru
-
January 17th, 2003, 06:08 AM
#3
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
-
January 17th, 2003, 08:56 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|