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 ...
随机推荐
- Oracle 课程一之Oracle体系结构
课程目标 •理解ORACLE数据库体系架构—内存结构和进程 •理解SQL在数据库中的运作流程 •理解UNDO&REDO原理 •理解commit原理 1.Oracle数据库概述 •数据库:物 ...
- JavaEE参考示例 SpringSide 4.0 GA版杀青
SpringSide是以Spring Framework为核心的,Pragmatic风格的JavaEE应用参考示例,是JavaEE世界中的主流技术选型,较佳实践的总结与演示. 经过漫长的7个月和6个R ...
- IIS部署网站
- bjfu1097 图标排列
这是2011年百度之星的一道题.这题的做法就是找规律,规律找对了,代码极水.规律我一开始也没有找到,后来经人提醒,发现如下规律:对于每个开发者,其所有应用的分离度和一定是其第一个应用与最后一个应用的距 ...
- Cadence原理图与Allegro交互
1:激活orCAD与Allegro的交互程序 打开原理图,Options->Preference在Miscellaneous里勾选 2:打开用到的工程 原理图,还有Allegro PCB Des ...
- 使用 svn://ip/filename 方式访问svn 资源库
a. 下载 SVN的官方网站为 http://subversion.tigris.org/,当前最新版本为1.4.2.Windows下的二进制安装包分为两种,一种是以setup结尾的安装文件,另一种是 ...
- 对ArrayList 进行深拷贝
ArrayList arr = new ArrayList(); arr.Add()); arr.Add()); arr.Add()); ArrayList arr2 = new ArrayList( ...
- 注意 sizeof 中不要有复杂运算操作
http://github.tiankonguse.com/blog/2014/12/05/c-base/ 一个比较有意思的问题 #include<stdio.h> ; int f() { ...
- iOS WebServiceFramework网络服务框架浅解
网络服务几乎是每一款成功APP的必备条件,打开你手机你会发现里面不用联网的应用数量十只手指可以数出来,就算是一些以独特技术切入市场的APP如美颜相机,都至少加入了分享功能.下面我先做下简单的回顾兼扫盲 ...
- [iOS UI进阶 - 3.2] 手势识别器UIGestureRecognizer
A.系统提供的手势识别器 1.敲击手势 UITapGestureRecognizer numberOfTapsRequired: 敲击次数 numberOfTouchesRequired: 同时敲 ...