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