Ejemplo n.º 1
0
        public RawBrowserPopup()
        {
            this.webBrowser = new RawWebBrowser();

            this.webBrowser.Initialized += (s, e) =>
            {
                var ax = (SHDocVw.WebBrowser) this.webBrowser.ActiveXInstance;
                ax.NewWindow2 += (ref object ppDisp, ref bool Cancel) =>
                {
                    var popup = new RawBrowserPopup();
                    popup.Visible = true;
                    ppDisp        = popup.WebBrowser.ActiveXInstance;
                };

                ax.WindowClosing += (bool IsChildWindow, ref bool Cancel) =>
                {
                    Cancel = true;
                    //Close();
                };
            };

            this.webBrowser.Dock = DockStyle.Fill;
            this.Controls.Add(this.webBrowser);
            this.webBrowser.Visible = true;
        }
Ejemplo n.º 2
0
        public MainForm()
        {
            InitializeComponent();

            if (this.webBrowser.Document == null && this.webBrowser.ActiveXInstance == null)
            {
                throw new ApplicationException("Unable to initialize WebBrowser ActiveX control.");
            }

            var ax = (SHDocVw.WebBrowser) this.webBrowser.ActiveXInstance;

            ax.NewWindow2 += (ref object ppDisp, ref bool Cancel) =>
            {
                var popup = new RawBrowserPopup();
                popup.Visible = true;
                ppDisp        = popup.WebBrowser.ActiveXInstance;
            };

            this.Load += (s, e) =>
            {
                this.webBrowser.DocumentText = "<a target=\"_blank\" href=\"javascript:'<button onclick=\\'window.close()\\'>Close</button>'\">Go</a>";
            };
        }