delphi execCommand
WebBrowser1.Document as IHTMLDocument2
关键点
function execCommand(const cmdID:
WideString; showUI: WordBool; value: OleVariant): WordBool; safecall;
实现过程
|
uses OleCtrls,ComObj,Mshtml,ActiveX;
///网页查看模式
(WebBrowser1.Document as
IHTMLDocument2).designMode := 'on'; (WebBrowser1.Document as
IHTMLDocument2).execCommand('EditMode',False,1); ///网页编辑模式
(WebBrowser1.Document as
IHTMLDocument2).designMode := 'off'; (WebBrowser1.Document as
IHTMLDocument2).execCommand('BrowseMode',False,1); ///选中文本编辑
///设置字体
//////名称
(WebBrowser1.Document as IHTMLDocument2).execCommand('FontName', False, '宋体'); //////大小
(WebBrowser1.Document as IHTMLDocument2).execCommand('FontSize', False, 7);///字体大小是从1到7 ////样式
//////粗体
(WebBrowser1.Document as IHTMLDocument2).execCommand('Bold', False, 1); //////斜体
(WebBrowser1.Document as IHTMLDocument2).execCommand('Italic', False, 1); /////下划线
(WebBrowser1.Document as IHTMLDocument2).execCommand('Underline', False, 1); /////删除线
(WebBrowser1.Document as IHTMLDocument2).execCommand('StrikeThrough', False, 1); ///超链接
(WebBrowser1.Document as IHTMLDocument2).execCommand('CreateLink', False, 1); ///删除超链接 (WebBrowser1.Document
as IHTMLDocument2).execCommand('UnLink', False, 1); ///设置
///设置文字前景色 (WebBrowser1.Document as
IHTMLDocument2).execCommand('ForeColor',False, 'Red'); ///设置文字背景色 (WebBrowser1.Document as
IHTMLDocument2).execCommand('BackColor',False, 'Blue'); ///设置下标
(WebBrowser1.Document as Ihtmldocument2).execCommand('SubScript',False,1); ///设置上标
(WebBrowser1.Document as Ihtmldocument2).execCommand('SuperScript',False,1); ///设置对齐方式
///设置左对齐
(WebBrowser1.Document as IHTMLDocument2).execCommand('JustifyLeft', False, 0); ///设置中对齐
(WebBrowser1.Document as IHTMLDocument2).execCommand('JustifyCenter', False, 0); ///设置右对齐
(WebBrowser1.Document as IHTMLDocument2).execCommand('JustifyRight', False, 0); ///设置两端对齐 (WebBrowser1.Document
as IHTMLDocument2).execCommand('JustifyFull', False, 0); ///缩进
/// 向右缩进
(WebBrowser1.Document as Ihtmldocument2).execCommand('Indent',True,1); /// 向左缩进
(WebBrowser1.Document as Ihtmldocument2).execCommand('Outdent',True,1); ///清除格式 (WebBrowser1.Document as
Ihtmldocument2).execCommand('Removeformat',True,0); ///序列查看
///
数字格式 (WebBrowser1.Document as Ihtmldocument2).execCommand('InsertOrderedList',True,0); /// 圆点查看 (WebBrowser1.Document
as Ihtmldocument2).execCommand('InsertUnorderedList',True,0); ///插入图片(静态)
(WebBrowser1.Document as IHTMLDocument2).execCommand('InsertImage', True, ''); (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertImage', False, 'C:\1.png'); ///插入HTML组件
///后面的字符串为这个控件的ID号
///直线
Line (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertHorizontalRule', True, ''); ///按钮
Button (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertButton', True, ''); ///复选框
CheckBox (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertInputCheckbox', True, ''); ///单选框
Radio (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertInputRadio', True, ''); ///编辑框
Edit (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertInputText', True, ''); ///文本框
Memo (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertTextArea', True, ''); ///密码框
PswEdit (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertInputPassword', True, ''); ///组框架
GroupBox (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertIFrame', True, ''); ///列表框
ListBox (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertSelectListbox', True, ''); ///组合框
Combobox (WebBrowser1.Document as IHTMLDocument2).execCommand('InsertSelectDropdown', True, ''); |
图
备注
命令标识符指定了要在给定对象上执行的操作。请和下列方法一起使用命令标识符:
- execCommand
- queryCommandEnabled
- queryCommandIndeterm
- queryCommandState
- queryCommandSupported
- queryCommandValue
| ID | command identifier | |
| 1 | 2D-Position | 允许通过拖曳移动绝对定位的对象。 |
| 2 | AbsolutePosition | 设定元素的 position 属性为“absolute”(绝对)。 |
| 3 | BackColor | 设置或获取当前选中区的背景颜色。 |
| 4 | BlockDirLTR | 目前尚未支持。 |
| 5 | BlockDirRTL | 目前尚未支持。 |
| 6 | Bold | 切换当前选中区的粗体显示与否。 |
| 7 | BrowseMode | 目前尚未支持。 |
| 8 | Copy | 将当前选中区复制到剪贴板。 |
| 9 | CreateBookmark | 创建一个书签锚或获取当前选中区或插入点的书签锚的名称。 |
| 10 | CreateLink | 在当前选中区上插入超级链接,或显示一个对话框允许用户指定要为当前选中区插入的超级链接的 URL。 |
| 11 | Cut | 将当前选中区复制到剪贴板并删除之。 |
| 12 | Delete | 删除当前选中区。 |
| 13 | DirLTR | 目前尚未支持。 |
| 14 | DirRTL | 目前尚未支持。 |
| 15 | EditMode | 目前尚未支持。 |
| 16 | FontName | 设置或获取当前选中区的字体。 |
| 17 | FontSize | 设置或获取当前选中区的字体大小。 |
| 18 | ForeColor | 设置或获取当前选中区的前景(文本)颜色。 |
| 19 | FormatBlock | 设置当前块格式化标签。 |
| 20 | Indent | 增加选中文本的缩进。 |
| 21 | InlineDirLTR | 目前尚未支持。 |
| 22 | InlineDirRTL | 目前尚未支持。 |
| 23 | InsertButton | 用按钮控件覆盖当前选中区。 |
| 24 | InsertFieldset | 用方框覆盖当前选中区。 |
| 25 | InsertHorizontalRule | 用水平线覆盖当前选中区。 |
| 26 | InsertIFrame | 用内嵌框架覆盖当前选中区。 |
| 27 | InsertImage | 用图像覆盖当前选中区。 |
| 28 | InsertInputButton | 用按钮控件覆盖当前选中区。 |
| 29 | InsertInputCheckbox | 用复选框控件覆盖当前选中区。 |
| 30 | InsertInputFileUpload | 用文件上载控件覆盖当前选中区。 |
| 31 | InsertInputHidden | 插入隐藏控件覆盖当前选中区。 |
| 32 | InsertInputImage | 用图像控件覆盖当前选中区。 |
| 33 | InsertInputPassword | 用密码控件覆盖当前选中区。 |
| 34 | InsertInputRadio | 用单选钮控件覆盖当前选中区。 |
| 35 | InsertInputReset | 用重置控件覆盖当前选中区。 |
| 36 | InsertInputSubmit | 用提交控件覆盖当前选中区。 |
| 37 | InsertInputText | 用文本控件覆盖当前选中区。 |
| 38 | InsertMarquee | 用空字幕覆盖当前选中区。 |
| 39 | InsertOrderedList | 切换当前选中区是编号列表还是常规格式化块。 |
| 40 | InsertParagraph | 用换行覆盖当前选中区。 |
| 41 | InsertSelectDropdown | 用下拉框控件覆盖当前选中区。 |
| 42 | InsertSelectListbox | 用列表框控件覆盖当前选中区。 |
| 43 | InsertTextArea | 用多行文本输入控件覆盖当前选中区。 |
| 44 | InsertUnorderedList | 切换当前选中区是项目符号列表还是常规格式化块。 |
| 45 | Italic | 切换当前选中区斜体显示与否。 |
| 46 | JustifyCenter | 将当前选中区在所在格式化块置中。 |
| 47 | JustifyFull | 目前尚未支持。 |
| 48 | JustifyLeft | 将当前选中区所在格式化块左对齐。 |
| 49 | JustifyNone | 目前尚未支持。 |
| 50 | JustifyRight | 将当前选中区所在格式化块右对齐。 |
| 51 | LiveResize | 迫使 MSHTML 编辑器在缩放或移动过程中持续更新元素外观,而不是只在移动或缩放完成后更新。 |
| 52 | MultipleSelection | 允许当用户按住 Shift 或 Ctrl 键时一次选中多于一个站点可选元素。 |
| 53 | Open | 目前尚未支持。 |
| 54 | Outdent | 减少选中区所在格式化块的缩进。 |
| 55 | OverWrite | 切换文本状态的插入和覆盖。 |
| 56 | Paste | 用剪贴板内容覆盖当前选中区。 |
| 57 | PlayImage | 目前尚未支持。 |
| 58 | 打开打印对话框以便用户可以打印当前页。 | |
| 59 | Redo | 目前尚未支持。 |
| 60 | Refresh | 刷新当前文档。 |
| 61 | RemoveFormat | 从当前选中区中删除格式化标签。 |
| 62 | RemoveParaFormat | 目前尚未支持。 |
| 63 | SaveAs | 将当前 Web 页面保存为文件。 |
| 64 | SelectAll | 选中整个文档。 |
| 65 | SizeToControl | 目前尚未支持。 |
| 66 | SizeToControlHeight | 目前尚未支持。 |
| 67 | SizeToControlWidth | 目前尚未支持。 |
| 68 | Stop | 目前尚未支持。 |
| 69 | StopImage | 目前尚未支持。 |
| 70 | StrikeThrough | 目前尚未支持。 |
| 71 | Subscript | 目前尚未支持。 |
| 72 | Superscript | 目前尚未支持。 |
| 73 | UnBookmark | 从当前选中区中删除全部书签。 |
| 74 | Underline | 切换当前选中区的下划线显示与否。 |
| 75 | Undo | 目前尚未支持。 |
| 76 | Unlink | 从当前选中区中删除全部超级链接。 |
| 77 | Unselect | 清除当前选中区的选中状态。 |
相关链接
如何
获取当前光标所在的字符属性
delphi execCommand的更多相关文章
- delphi WebBrowser控件上网页验证码图片识别教程(一)
步骤一:获取网页中验证码图片的url地址 在delphi中加入一个BitBtn和一个memo以及WebBrowser控件实现网页中验证码图片的url地址的获取 程序如下:procedure TForm ...
- Delphi WebBrowser控件的使用(大全 good)
Delphi WebBrowser控件的使用 WebBrowser控件属性:1.Application 如果该对象有效,则返回掌管WebBrowser控件的应用程序实现的自动化对象(IDis ...
- Delphi TWebBrowser
Delphi WebBrowser控件的使用 WebBrowser控件属性:1.Application 如果该对象有效,则返回掌管WebBrowser控件的应用程序实现的自动化对象(IDis ...
- Delphi TWebBrowser编程简述(转帖)
Delphi 3开始有了TWebBrowser构件,不过那时是以ActiveX控件的形式出现的,而且需要自己引入,在其后的4.0和5.0中,它就在封装好shdocvw.dll之后作为Internet构 ...
- 学习笔记:7z在delphi的应用
最近做个发邮件的功能,需要将日志文件通过邮件发送回来用于分析,但是日志文件可能会超级大,测算下来一天可能会有800M的大小.所以压缩是不可避免了,delphi中的默认压缩算法整了半天不太好使,就看了看 ...
- delphi连接sql存储过程
针对返回结果为参数的 一. 先建立自己的存储过程 ALTER PROCEDURE [dbo].[REName] ) AS BEGIN select ROW_NUMBER() over(order by ...
- delphi 2010与delphi XE破解版的冲突
在系统中同时安装了Dephi 2010LITE版与Delphi XE lite后,总是会有一个有问题 是因为两者都是读取C:\ProgramData\Embarcadero目录下的license文件, ...
- [Delphi] Delphi版本号对照
VER300 Delphi Seattle / C++Builder Seattle 23 230 (Delphi:Win32/Win64/OSX/iOS32/iOS64/An ...
- delphi tidhttp 超时设置无效的解决方法
现在delphi都发布到xe8了,tidhttp还有缺陷,那就是超时设置在没有网络或者连不上服务器的时候是无效的,不管你设置为多少都要10-20秒.connectTimeout和readTimeout ...
随机推荐
- Jabber/XMPP协议与架构
一.概述 由Jeremie Miller于1998年开始这个项目.Jabber是一个开放源码形式组织产生的网络实时通信协议,第一个公开版本于2000年5月发行.Jabber已经由IETF XMPP协议 ...
- Oracle 课程一之Oracle体系结构
课程目标 •理解ORACLE数据库体系架构—内存结构和进程 •理解SQL在数据库中的运作流程 •理解UNDO&REDO原理 •理解commit原理 1.Oracle数据库概述 •数据库:物 ...
- SharePoint 2010中列表Add和Delete事件解析
转:http://winsystem.ctocio.com.cn/26/11400026_2.shtml [IT专家网独家撰稿]SharePoint 2010与以前的版本相比,天翻地覆的变化并不为过. ...
- 阿里云容器服务--配置自定义路由服务应对DDOS攻击
阿里云容器服务--配置自定义路由服务应对DDOS攻击 摘要: 容器服务中,除了slb之外,自定义路由服务(基于HAProxy)也可以作为DDOS攻击的一道防线,本文阐述了几种方法来应对普通规模的DDO ...
- POJ 1208 The Blocks Problem
The Blocks Problem Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5397 Accepted: 231 ...
- UVALive 5029
用字典树来查询,关键是怎么处理输入的8个数字代表的字符,把每个数分别除以0.95和1.05得到8的区间,按左区间从小到大排序,那么和第一个区间有交集的必然代表二进制0,与它没交集的之后都是1,因为题目 ...
- css样式表中的样式覆盖顺序
刚才写zenktodo的时候,通过动态添加class的方式修改一个div的样式,总是不起作用. #navigator { height: 100%; width: 200; position: abs ...
- codeforce 702D Road to Post Office 物理计算路程题
http://codeforces.com/contest/702 题意:人到邮局去,距离d,汽车在出故障前能跑k,汽车1公里耗时a,人每公里耗时b,修理汽车时间t,问到达终点最短时间 思路:计算车和 ...
- 高性能、高容错、基于内存的开源分布式存储系统Tachyon的简单介绍
Tachyon是什么? Tachyon是一个高性能.高容错.基于内存的开源分布式存储系统,并具有类Java的文件API.插件式的底层文件系统.兼容Hadoop MapReduce和Apache Spa ...
- Modules-nodejs
Modules Node有一个简易的模块加载系统.在node中,文件和模块是一一对应的.下面示例是foo.js加载同一目录下的circle.js. foo.js的内容: var circle = re ...