Retrieving WebBrowser Object of child IE windows

mithrandiir42

Member
Joined
Mar 7, 2006
Messages
16
Programming Experience
3-5
Hey everyone, I'm writing an toolbar for IE that interacts with IE and all of it is done through a WebBrowser object that is set to the instance of IE that it loads in. I'm wondering how could i retrieve an object representing any child windows that are spawned from that one? (if a link opens in a new window) the reason i want to do this is to receive events from the child windows all in the parent window.. or just be able to pass information back to the parent.

Also i should mention that i have a BHO that is a part of this so each time a window loads, the the BHO can get the WebBrowser object of that window, but since they're only in the instance of that window, how do i get that information from one to the other?

Any help would be appreciated.. it seems so simple yet i can't figure it out.

Thanks!

Jeremy
 
I figured it out. just thought i'd post incase anyone else ran into the same situation. i added an event handler for NewWindow3 and then in the event handler i set the ref Object pDisp argument (which is null at first) to a new instance of InternetExplorerClass()

one i had that done i had a private varable WebBrowserChild in my class which i set to (SHDocVw.WebBrowser)pDisp.

then from there i could access the childwindow from that.

the one problem i ran into then was updating controls on the parent form from the childwindow which i had to do using a delegate because apparently .Net doesn't allow a secondary thread to access controls in another thread.

Here's the code i used to invoke the update function to update the control in the parent.
controlname.BeginInvoke(new DelegateFunc(UpdateHandler), new Object[] {"updated text"});

my delegate looked like this:
public delegate void DelegateFunc(string newtext);

and my update handler was something like this

private void UpdateHandler(string newtext)
{
controlname.Text = newtext;
}

sorry the code is in c# but it shouldn't be too hard to translate over to VB.

Hope this helps someone.
 
Back
Top