Bill: C # Suppresses script error prompts in WebBrowser, automatically masks pop-up windows

Source: Internet
Author: User

usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Runtime.CompilerServices;usingSystem.Runtime.InteropServices;namespacehcsem{ Public classMyWebBrowser:System.Windows.Forms.WebBrowser {#regionExtendedwebbrowsersiteclassExtendedWebBrowserSite:WebBrowser.WebBrowserSite, Unsafenativemethods.idochostshowui { PublicExtendedwebbrowsersite (WebBrowser host):Base(host) {}voidUnsafeNativeMethods.IDocHostShowUI.ShowMessage (refUnsafenativemethods._remotablehandle hwnd,stringLpstrtext,stringLpstrcaption,UINTDwtype,stringLpstrhelpfile,UINTDwhelpcontext, out intPlresult) {Plresult=0; //TODO: Customizing            }            voidUnsafeNativeMethods.IDocHostShowUI.ShowHelp (refUnsafenativemethods._remotablehandle hwnd,stringPszhelpfile,UINTUcommand,UINTDwdata, Unsafenativemethods.tagpoint Ptmouse,Objectpdispatchobjecthit) {                //TODO: Customizing            }        }        protected Overridewebbrowsersitebase createwebbrowsersitebase () {return NewExtendedwebbrowsersite ( This); }        #endregion    }     Public classUnsafeNativeMethods {#regionIdochostshowui[StructLayout (layoutkind.explicit, Pack=4)]         Public struct__midl_iwintypes_0009 {// Fields[FieldOffset (0)]             Public intHinproc; [FieldOffset (0)]             Public intHremote; } [StructLayout (LayoutKind.Sequential, Pack=4)]         Public struct_RemotableHandle { Public intFcontext;  Public__midl_iwintypes_0009 u; } [StructLayout (LayoutKind.Sequential, Pack=4)]         Public structTagpoint { Public intx;  Public inty; } [ComImport, Guid ("c4d244b0-d43e-11cf-893b-00aa00bdce1a"), InterfaceType (( Short)1)]         Public InterfaceIdochostshowui {[MethodImpl (Methodimploptions.internalcall, Methodcodetype=Methodcodetype.runtime)]voidShowMessage ([In, Comaliasname ("ExtendedWebBrowser2.UnsafeNativeMethods.wireHWND")]ref_RemotableHandle hwnd, [In, MarshalAs (UNMANAGEDTYPE.LPWSTR)]stringLpstrtext, [In, MarshalAs (UNMANAGEDTYPE.LPWSTR)]stringLpstrcaption, [in]UINTDwtype, [In, MarshalAs (UNMANAGEDTYPE.LPWSTR)]stringLpstrhelpfile, [in]UINTDwhelpcontext, [Comaliasname ("ExtendedWebBrowser2.UnsafeNativeMethods.LONG_PTR")] out intplresult); [MethodImpl (Methodimploptions.internalcall, Methodcodetype=Methodcodetype.runtime)]voidShowHelp ([In, Comaliasname ("ExtendedWebBrowser2.UnsafeNativeMethods.wireHWND")]ref_RemotableHandle hwnd, [In, MarshalAs (UNMANAGEDTYPE.LPWSTR)]stringPszhelpfile, [in]UINTUcommand, [in]UINTDwdata, [in] Tagpoint ptmouse, [out, MarshalAs (Unmanagedtype.idispatch)]Objectpdispatchobjecthit); }        #endregion    }}

Bill: C # Suppresses script error prompts in WebBrowser, automatically masks pop-up windows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.