惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
B
Blog RSS Feed
The GitHub Blog
The GitHub Blog
爱范儿
爱范儿
博客园 - 司徒正美
J
Java Code Geeks
酷 壳 – CoolShell
酷 壳 – CoolShell
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
D
Docker
Blog — PlanetScale
Blog — PlanetScale
Recent Announcements
Recent Announcements
罗磊的独立博客
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
Stack Overflow Blog
Stack Overflow Blog
M
MIT News - Artificial intelligence
腾讯CDC
T
The Blog of Author Tim Ferriss
小众软件
小众软件
U
Unit 42
T
Tailwind CSS Blog

博客园 - huadust

msdn 网络编程 委托用法 注册表操作 DateTime各种用法 [转]将dll汇入exe 用DataTable构建树 Lock Review String Review Class Review DataTable opertion Drag DataGridView Data To TreeView 2009_01_15_星期三 2009_01_02_星期五 2008_12_31_星期三 2008_12_24_星期三 2008_12_20_星期六 2008_12_17_星期三 2008_12_04_星期四
2008_12_06_星期六
huadust · 2008-12-06 · via 博客园 - huadust

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

今天周末来公司加班,主要是找了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);