惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google DeepMind News
Google DeepMind News
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
IT之家
IT之家
博客园 - 【当耐特】
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog
爱范儿
爱范儿
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
H
Help Net Security
J
Java Code Geeks
aimingoo的专栏
aimingoo的专栏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog RSS Feed
Blog — PlanetScale
Blog — PlanetScale
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - qevan

QCanvasTextWriter structures显示的模块的bpl - qevan - 博客园 delphi跟踪调试vcl代码的方法 QTrayIcon v1.0B 根据delphi版本进行编译 在气泡式提示窗口中显示关闭按钮 zz 中国共享软件注册提供商的比较 Delphi中资源文件使用详解 zz ShowBalloonTips @ TrayIcon 如何在DELPHI程序中顯示Balloon工具提示﹖ zz 分割人名的代码 电话薄的AT指令 zz 读取中文电话簿 AT+CPMS指令的意义以及AT+CNMI自动接收短信时的方法 一篇短信at指令介绍的文章, 摘过来 短信相关文章的连接 16进制字符转换为10进制 delphi c#的PDU-SMS编程代码 zz Delphi 2005纯WIN32开发环境
把字体保存到注册表或流中
qevan · 2005-04-18 · via 博客园 - qevan
把字体保存到注册表或流中
[ 作者:hubdog    转贴自:本站原创    点击数:201    更新时间:2004-7-7    文章录入:delphilxh
type 
  FontRec = packed record 
    Color: TColor; 
    LogFont: TLogFont; 
  end; 

// Save a font to the registry 保存到注册表
procedure SaveFontToReg(reg: TRegistry; const key, id: string; Font: TFont); 
var 
  fRec: FontRec; 
begin 
  if Windows.GetObject(Font.Handle, SizeOf(fRec.LogFont), @fRec.LogFont) > 0 then 
  begin 
    if reg.OpenKey(key, True) then 
      try 
        fRec.Color := Font.Color; 
        reg.WriteBinaryData(id, fRec, SizeOf(fRec)); 
      finally 
        reg.CloseKey; 
      end; 
  end; 
end; 

// Load a font from the registry 读取注册表
procedure LoadFont(reg: TRegistry; const key, id: string; Font: TFont); 
var 
  fRec: FontRec; 
begin 
  if reg.OpenKey(key, False) then 
    try 
      if reg.ReadBinaryData(id, frec, SizeOf(fRec)) = SizeOf(fRec) then 
        Font.Handle := CreateFontIndirect(fRec.LogFont); 
      Font.Color := fRec.Color; 
    finally 
      reg.CloseKey; 
    end; 
end; 

// Save a font to a stream 保存到流
procedure WriteFontToStream(s: TStream; Font: TFont); 
var 
  fRec: FontRec; 
  sz: integer; 
begin 
  sz := SizeOf(fRec.LogFont); 
  if Windows.GetObject(Font.Handle, sz, @fRec.LogFont) > 0 then 
  begin 
    s.Write(sz, SizeOf(Integer)); 
    fRec.Color := Font.Color; 
    s.Write(fRec, SizeOf(fRec)); 
  end 
  else 
  begin 
    sz := 0; 
    s.Write(sz, SizeOf(Integer)); 
  end; 
end; 

// Read a font from a stream 从流中读出
procedure ReadFont(s: TStream; Font: TFont); 
var 
  fRec: FontRec; 
  sz: integer; 
begin 
  s.read(sz, SizeOf(Integer)); 
  if sz = SizeOf(fRec.LogFont) then 
  begin 
    s.read(fRec, SizeOf(fRec)); 
    Font.Handle := CreateFontIndirect(fRec.LogFont); 
    Font.Color  := fRec.Color; 
  end; 
end;