欢迎来到天天文库
浏览记录
ID:40621750
大小:22.96 KB
页数:12页
时间:2019-08-05
《利用WebBrower封装的自己的浏览器MyIE源代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、利用WebBrower封装的自己的浏览器MyIE源代码用途:封装只能访问自己的web应用解决问题:1、弹出窗口不会跳出,解决了出现IE浏览器的问题2、获得访问界面的Title作为浏览器的Title一、封装WebBrowser(源自互联网网友提供的代码,已不知出处,非常感谢)usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.ComponentModel;usingSystem.Runtime.InteropService
2、s;namespaceMyQuery.MyBrower{[ComVisible(true)]publicclassExWebBrowser:System.Windows.Forms.WebBrowser{privateSHDocVw.IWebBrowser2Iwb2;protectedoverridevoidAttachInterfaces(objectnativeActiveXObject){Iwb2=(SHDocVw.IWebBrowser2)nativeActiveXObject;Iwb2.Silent=true;base.AttachInterfaces(
3、nativeActiveXObject);}protectedoverridevoidDetachInterfaces(){Iwb2=null;base.DetachInterfaces();}System.Windows.Forms.AxHost.ConnectionPointCookiecookie;WebBrowserExtendedEventsevents;//ThismethodwillbecalledtogiveyouachancetocreateyourowneventsinkprotectedoverridevoidCreateSink(){//M
4、AKESURETOCALLTHEBASEorthenormaleventswon'tfirebase.CreateSink();events=newWebBrowserExtendedEvents(this);cookie=newSystem.Windows.Forms.AxHost.ConnectionPointCookie(this.ActiveXInstance,events,typeof(DWebBrowserEvents2));}protectedoverridevoidDetachSink(){if(null!=cookie){cookie.Disco
5、nnect();cookie=null;}base.DetachSink();}//ThisneweventwillfirewhenthepageisnavigatingpubliceventEventHandlerBeforeNavigate;//////可用于替代原来的NewWindow事件,新增了事件的Url参数支持。///[CategoryAttribute("操作"),DescriptionAttribute("经过扩展的NewWindow事件,使用继承后的WebBrowserExtendedNavigatingEv
6、entArgs类型参数实现Url参数支持")]publiceventEventHandlerBeforeNewWindow;protectedvoidOnBeforeNewWindow(stringurl,outboolcancel){EventHandlerh=BeforeNewWindow;WebBrowserExtendedNavigatingEventArgsargs=newWebBrowserExtendedNavigatingEventArgs(url,null);if(null!=h){h(this,args);}cancel=args.Cancel
7、;}protectedvoidOnBeforeNavigate(stringurl,stringframe,outboolcancel){EventHandlerh=BeforeNavigate;WebBrowserExtendedNavigatingEventArgsargs=newWebBrowserExtendedNavigatingEventArgs(url,frame);if(null!=h){h(this,args);}//Passthecancellationchosenbackouttotheeventscancel=args.Cancel;}//
8、Thisc
此文档下载收益归作者所有