views:

485

answers:

2

Hi,

Greetings!

Situation:

My ActiveX DLL contains a customized webbrowser. The webbrowser displays a web page. When user clicks the link within the displayed page, a new IE window pop up and navigate to the clicked link URL.

Question:

How can I capture the DocumenComplete and NavigateComplete events fired from the NEW pop up IE window?

What I already tried:

I tried to capture the *NewWindow2(IDispatch **ppDisp, VARIANT_BOOL Cancel) event fired from customized webbrowser (not new IE window), and obtained the pointer ppDisp which points to the new IE windown. I tried to use this pointer as event source to advise or connect to the event handler (IDispatch::Invoke) for event capture. However it does not work. Maybe the failure is because the document in new IE window has not been loaded yet. I am not sure.

Can you please give me an suggestion what I should do?

Thanks!

A: 

You don't obtain the new web browser in ppDisp. You create one, sink events, and return its application property in ppDisp to the event.

Sheng Jiang 蒋晟
Can you please elaborate on the difference between obtaining new WebBrowser pointer from ppDisp and creating new one? According to MSDN, ppDisp is the pointer receives the IDispatch interface pointer of a new WebBrowser object.
bionicoder
As I said, You don't obtain the new web browser from ppDisp. You create a new webbrowser control, sink its events and get its application property. Put the return value of application property in ppDisp.
Sheng Jiang 蒋晟
A: 

void CYourDlg::OnNewWindow2(LPDISPATCH FAR* ppDisp, BOOL FAR* Cancel) { CDlgNewWB* dlgNewWB = new CYourDlg; this.listDialogWeb.Add(dlgNewWB); dlgNewWB ->Create(IDD_WBDLG_DIALOG);

  dlgNewWB ->m_webBrowser.SetRegisterAsBrowser(TRUE);

  *ppDisp = dlgNewWB ->m_webBrowser.GetApplication();

}

Sheng Jiang 蒋晟