delphi queryCommandState
如何
获取当前光标所在的字符属性
关键点
function queryCommandState(const cmdID: WideString): WordBool;
safecall;
- 粗体
- 斜体
- 下划线
- 删除线
- 对齐方式 左 中 右
- 数字排序
- 圆的排序
- 上标
- 下标
function queryCommandValue(const cmdID: WideString): OleVariant;
safecall;
- 字体名称
- 字符大小
实现过程
|
function GetFontName():string;
begin
Result:=(Form1.webbrowser1.Document as
IHTMLDocument2).queryCommandValue('FontName'); end;
function GetFontSize():string;
begin
Result:=(Form1.webbrowser1.Document as
IHTMLDocument2).queryCommandValue('FontSize'); end;
function IsBold():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as
IHTMLDocument2).queryCommandState('Bold'); if bRtn then
Result:=True
else
Result:=False;
end;
function IsItalic():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as
IHTMLDocument2).queryCommandState('Italic'); if bRtn then
Result:=True
else
Result:=False;
end;
function IsUnderline():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as
IHTMLDocument2).queryCommandState('Underline'); if bRtn then
Result:=True
else
Result:=False;
end;
function IsStrikeThrough():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as
IHTMLDocument2).queryCommandState('StrikeThrough'); if bRtn then
Result:=True
else
Result:=False;
end;
function IsSubScript():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as
IHTMLDocument2).queryCommandState('SubScript'); if bRtn then
Result:=True
else
Result:=False;
end;
function IsSuperScript():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as
IHTMLDocument2).queryCommandState('SuperScript'); if bRtn then
Result:=True
else
Result:=False;
end;
function IsJustifyLeft():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as
IHTMLDocument2).queryCommandState('JustifyLeft'); if bRtn then
Result:=True
else
Result:=False;
end;
function IsJustifyCenter():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as
IHTMLDocument2).queryCommandState('JustifyCenter'); if bRtn then
Result:=True
else
Result:=False;
end;
function IsJustifyRight():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as
IHTMLDocument2).queryCommandState('JustifyRight'); if bRtn then
Result:=True
else
Result:=False;
end;
function IsJustifyFull():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as
IHTMLDocument2).queryCommandState('JustifyFull'); if bRtn then
Result:=True
else
Result:=False;
end;
function IsInsertOrderedList():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as
IHTMLDocument2).queryCommandState('InsertOrderedList'); if bRtn then
Result:=True
else
Result:=False;
end;
function IsInsertUnorderedList():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as
IHTMLDocument2).queryCommandState('InsertUnorderedList'); if bRtn then
Result:=True
else
Result:=False;
end;
///使用
procedure TForm1.WebBrowser1CommandStateChange(ASender:
TObject; Command: Integer; Enable: WordBool);
Var bRtn:Boolean;
begin
try
cbb_FontNameList.Text:=GetFontName();
cbb_FontSize.Text:=GetFontSize();
btn_Bold.Down:=IsBold();
btn_Italic.Down:=IsItalic();
btn_Underline.Down:=IsUnderline();
btn_strikethrough.Down:=IsStrikeThrough();
btn_SubScript.Down:=IsSubScript();
btn_SuperScript.Down:=IsSuperScript();
ToolButton_AlignTwo.Down:=IsJustifyFull();
ToolButton_AlignLeft.Down:=IsJustifyLeft();
ToolButton_AlignCenter.Down:=IsJustifyCenter();
ToolButton_AlignRight.Down:=IsJustifyRight();
ToolButton_UnoredredList.Down:=IsInsertUnorderedList();
ToolButton_OrderedList.Down:=IsInsertOrderedList();
//格式化
except
Exit;
end;
end;
|
图
备注
这个主要应用在工具栏按钮感应上
相关链接
delphi queryCommandState的更多相关文章
- Delphi WebBrowser控件的使用(大全 good)
Delphi WebBrowser控件的使用 WebBrowser控件属性:1.Application 如果该对象有效,则返回掌管WebBrowser控件的应用程序实现的自动化对象(IDis ...
- Delphi TWebBrowser
Delphi WebBrowser控件的使用 WebBrowser控件属性:1.Application 如果该对象有效,则返回掌管WebBrowser控件的应用程序实现的自动化对象(IDis ...
- 学习笔记: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 ...
- Delphi Code Editor 之 编辑器选项
Delphi Code Editor 之 编辑器选项 可从Code Editor的右键菜单中选择“Properties”菜单项来查看编辑器选项.也可以从主菜单[Tools | Editor Optio ...
- Delphi使用ADO进行数据库编程
Delphi是一个可视化的编程工具,ADO编程也是这样,所以话不多言,直接通过代码.截图和语言来说明. 我的数据库是Oracle,为了测试,先建一个表:create table practice(un ...
随机推荐
- Android02--debug.keystore的注册信息
1 -- 签名文件的密钥 默认签名文件的密码是:android 该文件的存放点是: 2 -- 签名文件的签名信息 keytool -list -v -keystore C:\Users\motadou ...
- mysql explain中key_len的计算
ken_len表示索引使用的字节数,根据这个值,就可以判断索引使用情况,特别是在组合索引的时候,判断是否所有的索引字段都被查询用到. key_len显示了条件检索子句需要的索引长度,但 ORDER B ...
- [转]LINK:fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
LINK:fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 原文地址:http://yacare.iteye.com/blog/2010049 很多伙伴在更新VS ...
- POJ2976 Dropping tests 01分数规划
裸题 看分析请戳这里:http://blog.csdn.net/hhaile/article/details/8883652 #include<stdio.h> #include<a ...
- HDU5778 abs
http://acm.hdu.edu.cn/showproblem.php?pid=5778 思路:只有平方质因子的数,也就是这题所说的 y的质因数分解式中每个质因数均恰好出现2次 满足条件的数 ...
- Python面向对象2
方法 公共方法 私有方法 类方法 静态方法 #!usr/bin/python #coding:utf8 class Milo(): name = 'csvt' def fun1(self): prin ...
- 初识JAVA(【面向对象】:pub/fri/pro/pri、封装/继承/多态、接口/抽象类、静态方法和抽象方法;泛型、垃圾回收机制、反射和RTTI)
JAVA特点: 语法简单,学习容易 功能强大,适合各种应用开发:J2SE/J2ME/J2EE 面向对象,易扩展,易维护 容错机制好,在内存不够时仍能不崩溃.不死机 强大的网络应用功能 跨平台:JVM, ...
- Spring For Android初体验
Spring For Android是Spring框架的一个扩展,其主要目的在乎简化Android本地应用的开发,这其中包括了你可以使用该项目提供的 RestTemplate来为你的Android客户 ...
- 转载-清除Linux中MySQL的使用痕迹~/.mysql_history
原文地址:清除Linux中MySQL的使用痕迹~/.mysql_history 作者:RogerZhuo 原贴:http://bbs.chinaunix.net/thread-3676498-1-1. ...
- 第二百七十九天 how can I 坚持
竟然说我是猪,也是有点受不了了.其实也没什么,无所谓. 一个人有了信仰,不管成不成功,至少不会迷茫. sql语句,left on and 和where,left on是先检索,再关联,主表是完整 ...