2008_12_06_星期六

今天北京的气温比前二天好多了,风也小了不少。

今天周末来公司加班,主要是找了WebBrowser的一些使用方法,其中最主要的还是查看选定区域的源码功能。

// IHTMLDocument 接口没多大用, 只有个Script属性, 是管理页面脚本用的
// IHTMLDocument2接口用起来其实跟C#的HtmlDocument类(System.Windows.Forms.HtmlDocument)差不多的
// IHTMLDocument3就是跟VB6里的文档对象差不多的一个接口, 推荐大家都用这个, 基本上要用的方法都在
// IHTMLDocument4接口是跟导航有关的吧
// IHTMLDocument5接口几乎都是事件管理的成员

IHTMLDocument2 htmlDoc 
=  (IHTMLDocument2)wb_Browser.Document.DomDocument;
IHTMLTxtRange select 
=  (IHTMLTxtRange)htmlDoc.selection.createRange();
if  (select  !=   null )
{
    selectHtmlCode 
=  select.htmlText;
}

其中 mshtml 是个非常有用的类。

下面是设置WebBrowser为可编辑状态的语句是

// m1
HTMLDocument htmlDoc  =  (HTMLDocument)wb_Browser.Document.DomDocument;
htmlDoc.designMode 
=   " On " ;

// m2
wb_Browser.Document.DomDocument.GetType().GetProperty( " designMode " ).SetValue(wb_Browser.Document.DomDocument,  " On " null );

你可能感兴趣的:(2008)