public ExtendedWebBrowser New(bool navigateHome, TaskBrowser.IEItem ieItem = new TaskBrowser.IEItem()) { TabPage page = new TabPage(); ExtendedWebBrowser browser = new ExtendedWebBrowser(); if (ieItem != null) { ieItem.AddBrowser(browser); } page.Text = "新建窗口"; page.Tag = browser; browser.Tag = page; browser.Dock = DockStyle.Fill; browser.DownloadComplete += new EventHandler(this._browser_DownloadComplete); browser.StartNavigate += new EventHandler <BrowserExtendedNavigatingEventArgs>(this._browser_StartNavigate); browser.StartNewWindow += new EventHandler <BrowserExtendedNavigatingEventArgs>(this._browser_StartNewWindow); browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(this._browser_DocumentCompleted); browser.StatusTextChanged += new EventHandler(this._browser_StatusTextChanged); browser.DocumentTitleChanged += new EventHandler(this.WebBrowser_DocumentTitleChanged); browser.Quit += new EventHandler(this.WebBrowser_Quit); page.Controls.Add(browser); if (navigateHome) { browser.GoHome(); } this.tabControl.TabPages.Add(page); this.tabControl.SelectedTab = page; return(browser); }
private void _browser_StartNewWindow(object sender, BrowserExtendedNavigatingEventArgs ev) { try { if ((ev.NavigationContext & UrlContext.HtmlDialog) != UrlContext.HtmlDialog) { TaskBrowser.IEItem iEItem = this.GetIEItem(sender as ExtendedWebBrowser); ExtendedWebBrowser browser = this.New(false, null); if (iEItem != null) { iEItem.AddBrowser(browser); } iEItem = null; ev.AutomationObject = browser.Application; } } catch (Exception) { } }