views:

60

answers:

0

Suppose I open a new Internet Explorer window by, for example, clicking a link with target="_blank" in the HTML link. Further suppose I'm doing so programmatically via COM. I realize I can attach to the DWebBrowserEvents2::NewWindow3 event, and be notified when a new window will be opened. How do I get a reference to that newly opened window so I can manipulate it also?

Things to note:

  • I specifically do not want to cancel the NewWindow event and instantiate and return a new blank browser window in the ppDisp argument if I can help it.
  • I've thought about searching for each IE window (using FindWindow or some such), asking for its location, and comparing it to the bstrUrl argument, but I don't think that will work if the target has a redirection in it.
  • This is for an automated testing framework, so I am specifically driving Internet Explorer, not a hosted WebBrowser control.
  • I'm fully aware this will not find windows created by showModalDialog().