コード例 #1
0
        /// <summary>
        /// </summary>
        protected virtual void WebBrowserNavigateErrorHandler(object sender, WebBrowserNavigateErrorEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                e.Cancel = true;
                return;
            }

            if (_webBrowser.IsDisposed)
            {
                // we cancel all flow in disposed object.
                e.Cancel = true;
                return;
            }

            if (_webBrowser.ActiveXInstance != e.WebBrowserActiveXInstance)
            {
                // this event came from internal frame, ignore this.
                return;
            }

            if (e.StatusCode >= 300 && e.StatusCode < 400)
            {
                // we could get redirect flows here as well.
                return;
            }

            e.Cancel = true;
            StopWebBrowser();
            // in this handler object could be already disposed, so it should be the last method
            OnNavigationCanceled(e.StatusCode);
        }
 protected virtual void OnNavigateError(WebBrowserNavigateErrorEventArgs e)
 {
     if (NavigateError != null)
     {
         NavigateError(this, e);
     }
 }
コード例 #3
0
            public void NavigateError(object pDisp, ref object url, ref object frame, ref object statusCode,
                                      ref bool cancel)
            {
                string uriString     = (url == null) ? "" : ((string)url);
                string frameString   = (frame == null) ? "" : ((string)frame);
                int    statusCodeInt = (statusCode == null) ? 0 : ((int)statusCode);

                WebBrowserNavigateErrorEventArgs e = new WebBrowserNavigateErrorEventArgs(uriString, frameString,
                                                                                          statusCodeInt, pDisp);

                parent.OnNavigateError(e);
                cancel = e.Cancel;
            }