在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
首先为项目添加引用 Microsoft Internet Controls public Form1() { InitializeComponent(); this.webBrowser1.AllowWebBrowserDrop = false; //可在属性里设置,很重要 //在新Form中的WebBrowser中打开 (this.webBrowser1.ActiveXInstance as SHDocVw.WebBrowser).NewWindow2 += new SHDocVw.DWebBrowserEvents2_NewWindow2EventHandler(Form1_NewWindow2); //在主WebBrowser中打开 //(this.webBrowser1.ActiveXInstance as SHDocVw.WebBrowser).NewWindow3 += new SHDocVw.DWebBrowserEvents2_NewWindow3EventHandler(Form1_NewWindow3); } void Form1_NewWindow2(ref object ppDisp, ref bool Cancel) { Form5 frm = new Form5(); //事先建好一个带WebBrowser的窗体 ppDisp = frm.webBrowser1.ActiveXInstance; frm.Show(); } void Form1_NewWindow3(ref object ppDisp, ref bool Cancel, uint dwFlags, string bstrUrlContext, string bstrUrl) { Cancel = true; this.webBrowser1.Navigate(bstrUrl); 转至:http://www.cnblogs.com/swtseaman/archive/2011/10/17/2215714.html |
请发表评论