delphi 颜色,字体保存到INI文件
颜色转换成整型保存{也可以用ColorToString / stringTOColor}
字体用下面的函数转换成字符串,然后保存
unit xFonts;
interface
uses Classes, Graphics, SysUtils;
procedure StringToFont(sFont: string; Font: TFont; bIncludeColor: Boolean = True);
function FontToString(Font: TFont; bIncludeColor: Boolean = True): string;
implementation
const
csfsBold = '|Bold';
csfsItalic = '|Italic';
csfsUnderline = '|Underline';
csfsStrikeout = '|Strikeout';
//
// Expected format:
// "Arial", 9, [Bold], [clRed]
//
procedure StringToFont(sFont: string; Font: TFont; bIncludeColor: Boolean = True);
var
P : Integer;
sStyle: string;
begin
with Font do
try
// get font name
P := Pos(',', sFont);
name := Copy(sFont, 2, P - 3);
Delete(sFont, 1, P);
// get font size
P := Pos(',', sFont);
Size := StrToInt(Copy(sFont, 2, P - 2));
Delete(sFont, 1, P);
// get font style
P := Pos(',', sFont);
sStyle := '|' + Copy(sFont, 3, P - 4);
Delete(sFont, 1, P);
// get font color
if bIncludeColor then Color := StringToColor(Copy(sFont, 3, Length(sFont) - 3));
// convert str font style to
// font style
Style := [];
if (Pos(csfsBold, sStyle) > 0) then Style := Style + [fsBold];
if (Pos(csfsItalic, sStyle) > 0) then Style := Style + [fsItalic];
if (Pos(csfsUnderline, sStyle) > 0) then Style := Style + [fsUnderline];
if (Pos(csfsStrikeout, sStyle) > 0) then Style := Style + [fsStrikeOut];
except
end;
end;
//
// Output format:
// "Aril", 9, [Bold|Italic], [clAqua]
//
function FontToString(Font: TFont; bIncludeColor: Boolean = True): string;
var
sStyle: string;
begin
with Font do
begin
// convert font style to string
sStyle := '';
if (fsBold in Style) then sStyle := sStyle + csfsBold;
if (fsItalic in Style) then sStyle := sStyle + csfsItalic;
if (fsUnderline in Style) then sStyle := sStyle + csfsUnderline;
if (fsStrikeOut in Style) then sStyle := sStyle + csfsStrikeout;
if ((Length(sStyle) > 0) and ('|' = sStyle[1])) then
sStyle := Copy(sStyle, 2, Length(sStyle) - 1);
Result := Format('"%s", %d, [%s]',[name, Size, sStyle]);
if bIncludeColor then
Result := Result + Format(', [%s]',[ColorToString(Color)]);
end;
end;
end.
{对INI文件的操作,这里就在叙述了,需要的朋友 必应一下 一大堆}
文档转载『http://bbs.csdn.net/topics/100124538』
最新文章
- Android 如何在 ListView 中更新 ProgressBar 进度
- C++基本语法
- 在項目中快速部署SLF4J+LOGBACK
- coursera机器学习笔记-机器学习概论,梯度下降法
- ci中与类名相同 的方法 index控制器 下面index方法 会输出两份
- 用ie调试的时候显示:脚本调试程序无法连接到目标进程,已附加调试程序。
- Xamarin.Android之转换,呼叫,查看历史纪录
- MyEclipse 编写 ExtJS 卡死问题解决方法
- Smallest unused ID
- 吧php脚本打包成 exe程序
- android之字体阴影效果
- SQL Server 权限的分类
- CSS3秘笈:第二章
- yum groupinstall ";Development Tools"; 批量安装软件
- SpringCloud学习之Ribbon
- Meltdown Attack
- 接口签名进行key排序,并MD5加密
- 分析servlet injection
- Mysql删除重复记录,保留id最小的一条
- C++_友元函数总结(转)
热门文章
- REGEXP_LIKE,REGEXP_INSTR,REGEXP_SUBSTR,REGEXP_REPLACE
- 6.2、Android硬件访问服务编写系统代码
- 【习题 5-6 UVA-1595】Symmetry
- ArcSDE中空间数据的备份与恢复
- js进阶 12-5 jquery中表单事件如何使用
- imresize() 函数——matlab
- C#判断操作系统类型
- [Angular 2] Set Values on Generated Angular 2 Templates with Template Context
- JavaScript对象的创建
- WP8.1开发:后台任务详解(求推荐)