예제 #1
0
파일: RibbonForm1.cs 프로젝트: qwdingyu/C-
        private void testButton_ItemClick(object sender, ItemClickEventArgs e)
        {
            //XtraTabPage xpage = new XtraTabPage();
            TabPageWithWebBrowser page = new TabPageWithWebBrowser();

            page.Name            = "test";
            page.Text            = "test";
            page.WebBrowser1.Url = new Uri("http://www.baidu.com/s?wd=devexpress+tab&ie=UTF-8");
            this.xtraTabControl1.TabPages.Add(page);
            xtraTabControl1.SelectedTabPage = page;//显示该页
        }
예제 #2
0
        /// <summary>
        /// 拦截弹出窗口。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void WebBrowser_NewWindow3(object sender, WebBrowserNavigatingEventArgs e)
        {
            e.Cancel = true;
            WebBrowser  browser = sender as WebBrowser;
            HtmlElement element = browser.Document.ActiveElement;

            while (element != null)
            {
                if (element.TagName == "FRAME" || element.TagName == "IFRAME")
                {
                    if (string.IsNullOrEmpty(element.Id))
                    {
                        foreach (HtmlWindow wnd in element.Document.Window.Frames)
                        {
                            if (wnd.WindowFrameElement == element)
                            {
                                element = wnd.Document.ActiveElement;
                                break;
                            }
                        }
                    }
                    else
                    {
                        element = element.Document.Window.Frames[element.Id].Document.ActiveElement;
                    }
                }
                else
                {
                    break;
                }
            }
            HtmlDocument          opener         = element == null ? null : element.Document;
            TabPageWithWebBrowser page           = new TabPageWithWebBrowser(opener.Window.DomWindow as IHTMLWindow2);
            WebFillManager        webFillManager = _fillManager as WebFillManager;

            if (webFillManager != null)
            {
                webFillManager.AttachWebBrowser(page.WebBrowser1);
            }
            page.FillManager = webFillManager;
            XtraTabControl tabControl = this.Parent as XtraTabControl;

            tabControl.TabPages.Add(page);
            tabControl.SelectedTabPage = page; //显示该页
        }