日期:2014-05-17 浏览次数:21075 次
public Form1()
{
InitializeComponent();
this.webBrowser1.AllowWebBrowserDrop = false;
var nativeBrowser = (SHDocVw.WebBrowser)webBrowser1.ActiveXInstance;
nativeBrowser.NewWindow2 += new SHDocVw.DWebBrowserEvents2_NewWindow2EventHandler(nativeBrowser_NewWindow2);
}
void nativeBrowser_NewWindow2(ref object ppDisp, ref bool Cancel)
{
FrmBaseBrowser frm = new FrmBaseBrowser(); //事先建好一个带WebBrowser的窗体
frm.Show();
ppDisp = frm.webBrowser1.ActiveXInstance;
}
private void Form1_Load(object sender, EventArgs e)
{
axWebBrowser1.Navigate("https://www.google.com.au");
}
private void axWebBrowser1_NewWindow2(object sender, AxSHDocVw.DWebBrowserEvents2_NewWindow2Event e)
{
Form1 frmWB = new Form1();
frmWB.axWebBrowser1.RegisterAsBrowser = true;
e.ppDisp = frmWB.axWebBrowser1.Application;
frmWB.Visible = true;
&