public void OnNewWindow(NewWindowEventArgs e)
 {
     if (StartNewWindow != null)
     {
         StartNewWindow(this, e);
     }
 }
        public bool OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
        {
            var chromiumWebBrowser = (ExtChromiumBrowser)browserControl;

            chromiumWebBrowser.Invoke(new Action(() =>
            {
                NewWindowEventArgs e = new NewWindowEventArgs(windowInfo, targetUrl);
                chromiumWebBrowser.OnNewWindow(e);
            }));

            newBrowser = null;
            return(true);
        }
Beispiel #3
0
        private void Browser_StartNewWindow(object sender, NewWindowEventArgs e)
        {
            TabPage tp = new TabPage();

            // tabPage1
            //
            tp.AutoScroll = true;
            tp.Location   = new System.Drawing.Point(4, 26);
            tp.Margin     = new System.Windows.Forms.Padding(0);
            tp.Name       = "tabPage" + tpidx;
            tp.Size       = new System.Drawing.Size(1358, 738);
            tp.TabIndex   = tpidx - 1;
            tp.Text       = "新标签页";
            tp.UseVisualStyleBackColor = true;
            tp.Width = 100;
            ;

            var control = new ExtChromiumBrowser(e.url);

            control.Dock = DockStyle.Fill;
            //control.CreateControl();
            //host.Child = control;
            control.Focus();
            control.StartNewWindow += Browser_StartNewWindow;
            control.TitleChanged   += Browser_TitleChanged1;
            control.KeyboardHandler = new CEFKeyBoardHander();
            control.DownloadHandler = new MyDownloadHandler();
            control.MenuHandler     = new MenuHandler();

            tp.Controls.Add(control);
            tp.Show();
            this.tabControl1.Controls.Add(tp);
            this.tabControl1.SelectedTab           = tp;
            this.tabControl1.SelectedIndex         = tpidx - 1;
            this.tabControl1.SelectedIndexChanged += TabControl1_SelectedIndexChanged;
            this.tabControl1.Focus();
            //tbc.Pages.Add(tp);
            //tabFormControl1.SelectedPage = tp;
            //tp.Text = control.Text;
            //e.WindowInfo.SetAsChild(control.Handle, 0, 0, (int)host.ActualWidth, (int)host.ActualHeight);
            tpidx++;
        }