I have a class that inherits from "DispEventAdvise" (for outlook2010, but its not important):
class item_2010_event_handler :
public IDispEventSimpleImpl<IDC_OUTLOOK_ITEM_2010_EVENTS,
item_2010_event_handler,
&outlook_item_2010_ev_id>
Now, I want to register a single instance of item_2010_event_handler to get events from multiple objects, so I call DispEventAdvise() multiple times (once for each object), but from the 2nd time I call DispEventAdvise() I get "Unknown Error" exception from the function.
Is it possible it is not supported? and if not, why not???
If it is possible, what am I missing (obviously I'll add more code if it is needed...)?
Each "copy" of IDispEventSimpleImpl
you inherit from keeps a so called "cookie", a value you provide back to the connection point later when you need to unadvise/disconnect from events. Having said that, IDispEventSimpleImpl
class (note word "simple" in the name) supports only one connection.
Your choices are:
IDispEventSimpleImpl
class so that replacement class could connect to multiple points properly managing the connectionsIDispEventSimpleImpl
bases to support more (fixed amount though - lacks flexibility, good for several connections one per source type) connections on a single instance