ive been fiddling around with a popup killer app that i was working on a while back. how would i capture the NewWindow2 event a webbrowser object fires when a new window is to be created?
Posted on 2001-11-26 21:07:53 by smurf
Events are handled by COM thru a process (or dance really) called Connection Points. These are very nicely described in "Essential COM," let me try to babble my way thru what I remember.

To see if an object sources events, you QueryInterface it for IConnectionPointContainer. If you get this interface back, events are supported.

You then call IConnectionPointContainer::FindConnectionPoint with the IID of the event interface you wish to sink.

You'll get back an IConnectionPoint interface. You call IConnectionPoint::Advise when you want to sink events, and call IConnectionPoint::Unadvise when done to break the connection.

In the ::Advice call, you pass in the object reference of your event handling interface (here the NewWindow2 interface). That's how the existing object knows where in your code to call.

Hopefully it should be obvious that your event handling interface should not only have the same proto as described for NewWindow2. What may not be obvious is this event handler is a fully COM compliant interface, and thus it must inherate from IUnknown, or possibly IDispatch (some literature say events demands the latter for script host use, I do not know for sure).
Posted on 2001-11-27 23:37:23 by Ernie