积极答复者
WebBrowser 在newwindow2 中获取即将转到的URL

问题
答案
-
你好,
你可以看下这篇帖子: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/8c43c6f5-4e9f-4491-8219-1b0eeb7b225b/
在项目里增加对于 SHDocVw (Microsoft Internet Controls) 的COM引用,(注意,VS2010需要手动地更改下 SHDocVw 引用后的属性, "Embed Interop Type" 改成 False)
((SHDocVw.DWebBrowserEvents2_Event)browser.ActiveXInstance).NewWindow3 += new SHDocVw.DWebBrowserEvents2_NewWindow3EventHandler(MainWindow_NewWindow3);
void MainWindow_NewWindow3(ref object ppDisp, ref bool Cancel, uint dwFlags, string bstrUrlContext, string bstrUrl) { browser.Navigate(bstrUrl); }
这样就可以实现! (相应的把C#转下即可)
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 feiyun0112Moderator 2011年1月10日 1:41
全部回复
-
-
你好,
你可以看下这篇帖子: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/8c43c6f5-4e9f-4491-8219-1b0eeb7b225b/
在项目里增加对于 SHDocVw (Microsoft Internet Controls) 的COM引用,(注意,VS2010需要手动地更改下 SHDocVw 引用后的属性, "Embed Interop Type" 改成 False)
((SHDocVw.DWebBrowserEvents2_Event)browser.ActiveXInstance).NewWindow3 += new SHDocVw.DWebBrowserEvents2_NewWindow3EventHandler(MainWindow_NewWindow3);
void MainWindow_NewWindow3(ref object ppDisp, ref bool Cancel, uint dwFlags, string bstrUrlContext, string bstrUrl) { browser.Navigate(bstrUrl); }
这样就可以实现! (相应的把C#转下即可)
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 feiyun0112Moderator 2011年1月10日 1:41