none
IConnectionPoint Advise and events firing too many times RRS feed

  • Question

  • I'm writing an application that sort of performs certain actions depending on what the user does inside a WebBrowser Control. I rely on the DocumentComplete event to create IConnectionPoint from the document in the WebBrowser control and I am able to detect events such as onclick, onfocusout, etc.

    I had a problem though with detecting events that happened in pages that contained frames or iframes. Basically, I didn't call IConnectionPoint.Advise on those documents so I couldn't intercept any events. Well, I recursively go through each frame and create connection points for each document so that I can detect those events.

    The problem though is this. Since I call Advise on multiple documents (multicasting) the events are fired for that many documents. So one interaction will fire 4 times if I have a connection point for the root document and the three frames.

    Does anyone know how to get around firing all those events repeatedly? I'd like for a click inside a frame to trigger just one onclick event, not 4 as I mentioned before. I'd be happy to post some code if that will help.
    Thursday, June 21, 2007 11:28 PM

Answers

  • Thanks for replying. I think I figured out the problem. I wasn't unadvising the connection points in the right order. I think I have it working now.
    Friday, June 22, 2007 8:59 PM

All replies

  • Is anyone familiar with this problem?
    Friday, June 22, 2007 4:06 PM
  • Not a lot of use for IConnectionPoint in this forum.  Note that the DocumentComplete event fires multiple times for each frame in the document.  You might want to count them off before wiring up the event.  Check this thread.
    Friday, June 22, 2007 6:58 PM
    Moderator
  • Thanks for replying. I think I figured out the problem. I wasn't unadvising the connection points in the right order. I think I have it working now.
    Friday, June 22, 2007 8:59 PM