设置/获取 字体属性
  1. 名称
  2. 大小
  3. 粗体
  4. 斜体
  5. 下划线
  6. 删除线
  7. 颜色1
  8. 颜色2
 
uses MSHTML;
 
//设置


//------------------------------------------------------------------------------
procedure WB_SetFontName();
begin
  (Form1.webbrowser1.Document as
IHTMLDocument2).execCommand('FontName', False,
Form1.cbb_FontNameList.Text);
end;
//------------------------------------------------------------------------------
procedure WB_SetFontSize();
begin
  (Form1.webbrowser1.Document as
IHTMLDocument2).execCommand('FontSize', false,
StrToInt(Form1.cbb_FontSize.Text));
end;
//------------------------------------------------------------------------------
procedure WB_SetBold();
begin
  (Form1.webbrowser1.Document as
IHTMLDocument2).execCommand('Bold', False, 1);
end;
//------------------------------------------------------------------------------
procedure WB_Setstrike();
begin
  (Form1.webbrowser1.Document as
IHTMLDocument2).execCommand('StrikeThrough', False,
1);
end;
//------------------------------------------------------------------------------
procedure WB_SetItalic();
begin
  (Form1.webbrowser1.Document as
IHTMLDocument2).execCommand('Italic', False, 1);
end;
//------------------------------------------------------------------------------
procedure WB_SetUnderline();
begin
  (Form1.webbrowser1.Document as
IHTMLDocument2).execCommand('Underline', False, 1);
end;

//------------------------------------------------------------------------------
//颜色要为 HTML 的颜色格式

procedure
WB_SetForeColor();
begin
  (Form1.WebBrowser1.Document as
IHTMLDocument2).execCommand('ForeColor', False, '#CD0000');
end;
//------------------------------------------------------------------------------
procedure WB_SetBackColor();
begin
  (Form1.WebBrowser1.Document as
IHTMLDocument2).execCommand('BackColor',false, '#8EE5EE');
end;

 
 
 
//获得
//------------------------------------------------------------------------------

//First chance exception at $759E9617.
Exception class EOleException with message '不支持该命令。'. Process Webbrowser.exe
(6472)
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 GetFontColor():TColor;
begin
      Result:=(Form1.webbrowser1.Document as
IHTMLDocument2).queryCommandValue('ForeColor');
end;
//------------------------------------------------------------------------------
function GetFontBgColor():TColor;
begin
      Result:=(Form1.webbrowser1.Document as
IHTMLDocument2).queryCommandValue('BackColor');
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);
begin

//------------------------------------------------------------------------------
  if WebBrowser1.ReadyState =READYSTATE_COMPLETE  then
  if GetSelText<>'' then
  begin
      mni_Copy.Enabled:=True;
      btn_Copy.Enabled:=True;
      btn_Cut.Enabled:=True;
      mni_Cut.Enabled:=True;
  end
  else
  begin
       mni_Copy.Enabled:=false;
       btn_Copy.Enabled:=False;
       btn_Cut.Enabled:=False;
       mni_Cut.Enabled:=false;
  end;
  //如果剪切板上没有内容则
  if IsClipboardFormatAvailable(CF_TEXT) then
  begin
     btn_Paste.Enabled:=True;
     mni_Paste.Enabled:=True;
  end
  else
  begin
     btn_Paste.Enabled:=False;
     mni_Paste.Enabled:=False;
  end;

//------------------------------------------------------------------------------

try
  //cbb_FontNameList.Text:=GetFontName();
  cbb_FontNameList.ItemIndex
:=cbb_FontNameList.Items.IndexOf(
GetFontName());
  //cbb_FontSize.Text:=GetFontSize();
   cbb_FontSize.ItemIndex
:=cbb_FontSize.Items.IndexOf(
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;

  case Command of
    CSC_NAVIGATEBACK:
ToolButton_Back.Enabled :=
Enable;    //“后退”按钮
    CSC_NAVIGATEFORWARD:
ToolButton_Forward.Enabled :=
Enable;    //“前进”按钮
    CSC_UPDATECOMMANDS:
ToolButton_Stop.Enabled :=
TWebBrowser(ASender).Busy;  //“停止”按钮
  end;
end;

 
 

delphi 01设置 字体属性的更多相关文章

  1. Delphi: TLabel设置EllipsisPosition属性用...显示过长文本时,以Hint显示其全文本

    仍然是处理多语言中碰到问题. Delphi自2006版以后,TLabel有了EllipsisPosition属性,当长文本超过其大小时,显示以...,如下图: 这样虽然解决显示问题,但很显然,不知道. ...

  2. CSS3中设置字体的抗锯齿或光滑度的属性

    刚刚接触前端开发,对于-webkit-font-smoothing: antialiased; 这个属性不了解.上网查找了一些资料. 总结一下: -webkit-font-smoothing  :  ...

  3. {03--CSS布局设置} 盒模型 二 padding bode margin 标准文档流 块级元素和行内元素 浮动 margin的用法 文本属性和字体属性 超链接导航栏 background 定位 z-index

    03--CSS布局设置 本节目录 一 盒模型 二 padding(内边距) 三 boder(边框) 四 简单认识一下margin(外边距) 五 标准文档流 六 块级元素和行内元素 七 浮动 八 mar ...

  4. 字体属性设置(一):谷歌浏览器12px以下字体的显示;方法和原理

    前言: chrome 谷歌浏览器默认的字体大小为16px:可以通过设置font-size来设置字体大小但是当设置到12px以下的时候字体大小不再改变:对于想设置其他大小的字体就很头疼,本文参考网上的方 ...

  5. JAVA学习绘图颜色及其笔画属性设置字体显示文字

    package com.graphics; import java.awt.*; import java.awt.geom.Rectangle2D; import java.util.Date; im ...

  6. gispro设置标注属性字体样式设置

    为了应对电子地图和卫星影像的底图,标注样式选择比较关键.挑选了黑字白色晕圈效果.记住不是设置字体轮廓. 因为字体宽度(字粗)有限,设置轮廓直接把字体本身的颜色覆盖了

  7. Delphi中Menu设置Images属性后快捷按键下划线被隐藏解决方法

    现象:MainMenu设置Images属性后,看不到快捷按键的下划线,如:新建(&N) 分析:VCL中Menus.pas单元的代码,看到如下语句procedure TMenuItem.Adva ...

  8. Delphi部份函数,命令,属性中文说明

    Abort 函数 引起放弃的意外处理 Abs 函数 绝对值函数 AddExitProc 函数 将一过程添加到运行时库的结束过程表中 Addr 函数 返回指定对象的地址 AdjustLineBreaks ...

  9. python 之 前端开发(CSS三大特性、字体属性、文本属性、背景属性)

    11.38 css三大特性 11.381 继承性 1.定义:给某一个元素设置一些属性,该元素的后代也可以使用,这个我们就称之为继承性​2.注意:    1.只有以color.font-.text-.l ...

随机推荐

  1. C# DataGridView的列对象属性探讨 (未完待续)

    比较难的几个属性的释义[1]:

  2. C#中的值类型(value type)与引用类型(reference type)的区别

    ylbtech- .NET-Basic:C#中的值类型与引用类型的区别 C#中的值类型(value type)与引用类型(reference type)的区别 1.A,相关概念返回顶部     C#中 ...

  3. android模块化app开发-3远程动态更新插件

    前两章用apkplug框架实现了两个基本的功能,但它们都是在本地安装测试的,在实际开发过程中我们肯定是需要与服务器联网将更新的插件远程推送给用户手机客户端.今天利用apkplug提供的插件托管服务轻松 ...

  4. 基于Fragment实现Tab的切换,滑出侧边栏

    最近在学习Fragment(碎片)这是android3.0以后提出的概念,很多pad上面的设置部分都是通过Fragment来实现的,先看看具体的效果吧(图一)  (图二) (图三)第一章图片是初始时的 ...

  5. HDU5731 Solid Dominoes Tilings 状压dp+状压容斥

    题意:给定n,m的矩阵,就是求稳定的骨牌完美覆盖,也就是相邻的两行或者两列都至少有一个骨牌 分析:第一步: 如果是单单求骨牌完美覆盖,请先去学基础的插头dp(其实也是基础的状压dp)骨牌覆盖 hiho ...

  6. 使用Redis的理由

    Redis是一个远程内存数据库,它不仅性能强劲,而且还具有复制特性以及为解决问题而生的独一无二的数据模型.Redis提供了5种不同类型的数据结构,各式各样的问题都可以很自然地映射到这些数据结构上:Re ...

  7. Java连接Oracle10g

    1.导入驱动包: a.找到oracle安装目录下的jdbc/lib中的文件classes12.jar: b.右击你创建的JAVA工程,找到Build path,选择Add External Archi ...

  8. uC/OS - III 移植 IAR平台

    关于移植uC/OS-III 网上已经有很多教程了此处只是做个记录 首先下载源码然后解压得到下面的文件: 然后在模版工程里新建各种文件夹: 最后全部都添加进工程: OK了,编译一下,惊呆了,竟然 0错误 ...

  9. 转储oracle的redo文件

    1.确定当前使用的redo文件 SQL> select member from v$logfile where group# = ( select group# from v$log where ...

  10. ACM2033

    /**人见人爱A+B Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Su ...