webBrowser 事件委托如何引用之前的对象?
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Control.CheckForIllegalCrossThreadCalls = false;
this.webBrowser1.Navigate("about:blank"); (this.webBrowser1.ActiveXInstance as SHDocVw.WebBrowser).NewWindow2 += new SHDocVw.DWebBrowserEvents2_NewWindow2EventHandler(Form1_NewWindow2);
this.webBrowser1.Navigate("http://127.0.0.1/");
//if (this.webBrowser1.ReadyState == WebBrowserReadyState.Complete) { this.Text = webBrowser1.DocumentTitle; }
}
public void Form1_NewWindow2(ref object ppDisp, ref bool Cancel)
{
Form1 frm = new Form1();
ppDisp = frm.webBrowser1.ActiveXInstance;
//frm.webBrowser1.ScrollBarsEnabled = true;
frm.StartPosition = FormStartPosition.CenterParent;
frm.Width = 880;
frm.Height = 580;
frm.Show();
frm.webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
public void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
我想在这里获取设置frm.Text属性,但不知道怎么样获取这个对象 }
}
webBrowser?事件对象传递?
------解决方案--------------------Form1 frm=null;
public void Form1_NewWindow2(ref object ppDisp, ref bool Cancel)
{
frm = new Form1();
ppDisp = frm.webBrowser1.ActiveXInstance;