易截截图软件、单文件、免安装、纯绿色、仅160KB

delphi 读取剪粘板内的html格式数据

根据剪贴板的原理,在获取剪贴板内容之前,必须指定要获取内容的格式。由于剪贴板中的数据可能存在多种格式,所以有必要对剪贴板的格式类型先做一些了解。W写下了以下的测试代码:
procedure TForm1.Button3Click(Sender: TObject);
var
  i: integer;
  Buffer: PChar;
  s: string;
begin
  Memo1.Lines.Clear;  //增加了一个Memo控件来跟踪数据
  with TClipboard.Create do  //利用TClipboard追踪剪贴板
  begin
    GetMem(Buffer, 20);
    for i:=0 to FormatCount - 1 do
    begin
      GetClipboardFormatName(Formats[i], Buffer, 20);
      s := StrPas(Buffer);
      Memo1.Lines.Add(Format('%s:%d', [s, Formats[i]]));
    end;
    FreeMem(Buffer);
    Free;
  end;
end;
点击Button3,在Memo1文本框中显示出以下的内容:
DataObject:49161
Object Descriptor:49166
Rich Text Format:49312
HTML Format:49394
HTML Format:14
HTML Format:3
PNG:49672
GIF:49536
JFIF:49538
……
很明显,第4行的“HTML Format:49394”应该就是HTML编辑器真正需要的格式。由于“HTML Format”并不是剪贴板默认支持的格式,所以W需要使用API函数RegisterClipboardFormat先进行注册。
procedure TForm1.Button4Click(Sender: TObject);
var
  s: string;
  hMem: DWORD;
  CF_HTML: DWORD; // 声明一个CF_HTML剪贴板格式
  txtPtr: PChar;
begin
  CF_HTML := RegisterClipboardFormat('HTML Format');  //注册HTML Format格式
  with TClipboard.Create do
  begin
    hMem := GetAsHandle(CF_HTML);
    txtPtr := GlobalLock(hMem);
    s := StrPas(txtPtr);
    GlobalUnlock(hMem);
    Memo1.Lines.Add(UF8Decode(s));
    Free;
  end;
end;
单击Button4就可以在memo1中看到真定html格式文本。


相关文档:

测试在博客中加入html的支持


    for 
(tmp 

m_commentHead

tmp

tmp 

tmp->next)
    {
        nCommentNum ++
;
        
memset(wBuffer,
0
......

struts property escape 输出 html 标签

有时,在数据取出一大段文字要输出到页面上,如果有回车符号,在页面会显示不出来。要显示要用到escape参数
escape="false".
<s:property value="aaa<br>aaa" escape="false"/>
这样就能分行显示了。
......

HTML编码对照表


特殊符号
命名实体
十进制编码
特殊符号
命名实体
十进制编码
特殊符号
命名实体
十进制编码
Α
&Alpha;
&#913;
Β
&Beta;
&#914;
Γ
&Gamma;
&#915;
Δ
&Delta;
&#916;
Ε
&Epsilon;
&#917;
Ζ
&Zeta;
&#918; ......

DELPHI基础教程读书笔记

设置字体的过程
Procedure TForm1.FontDlgApply(Sender:Tobject);
begin
Button1.Font:= FontDialog1.Font;
end; 
该程序只有当用户按动About框的按钮或被About窗控制图标关闭窗口后,才会回到主窗体中,而不能与第一个窗体发生交互行为。这就是方法Show和ShowModal的主要不同之处
集合类型是一群相同类型元素的组合 ......

Delphi 嵌入汇编 进Ring0 360tray.exe

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, TlHelp32;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Pub ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号