Popup window webbrowser control

前端 未结 3 1715
情话喂你
情话喂你 2021-01-03 06:28

I am using a webbrowser control to get some information from a website. It has a detail link, which when clicked, opens a popup window and shows the details in the webbrowse

3条回答
  •  礼貌的吻别
    2021-01-03 06:55

    this is dynamic version. it doesnt require statically bind com interop which is always problem in future versions of windows.

        public partial class Form10 : Form
    {
        public Form10()
        {
            InitializeComponent();
            webBrowser1.Navigate("about:blank");
            dynamic ax = this.webBrowser1.ActiveXInstance;
            ax.NewWindow += new NewWindowDelegate(this.OnNewWindow);
            this.webBrowser1.Navigate("http://google.com");
        }
        private delegate void NewWindowDelegate(string URL, int Flags, string TargetFrameName, ref object PostData, string Headers, ref bool Processed);
        private void OnNewWindow(string URL, int Flags, string TargetFrameName, ref object PostData, string Headers, ref bool Processed)
        {
            Processed = true;
            //your own logic
        }
    }
    

提交回复
热议问题