如何读出TFont中的值,并将其保存为文本型,下次运行时读取! 如何读出TFont中的值,并将其保存为文本型,下次运行时读取! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 自定义一个记录类型,将TFont的各个属性保存在一个记录中。然后将记录保存在记录文件中,,下次Load这个文件. 建立一INI文件用来专门保存字体文件信息,如大小,颜色等。 非常感谢!我怎么将诸如TColor,TCharset类型值转化为string型呢? 你调用fontdialogif fontdialog.execute thenfont:=fontdialog.filename;//保存savefileto var MyFile: file of Tfont; MyFont: TFont;beginend; 那就随便给你段代码吧:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,IniFiles;type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}//saveprocedure TForm1.Button1Click(Sender: TObject);var IniFileName:String; MyIniFile:Tinifile; FFont:TFont;begin IniFileName:=ExpandFileName(ExtractFilePath(Application.ExeName)+'\SystemSet.ini'); MyIniFile:=Tinifile.Create(inifilename); MyIniFile.WriteString('Font','FontName',FFont.Name); MyIniFile.WriteInteger('Font','FontSize',FFont.Size); //其它你自己加上;end;//loadprocedure TForm1.FormCreate(Sender: TObject);var IniFileName:String; MyIniFile:Tinifile;begin IniFileName:=ExpandFileName(ExtractFilePath(Application.ExeName)+'\SystemSet.ini'); MyIniFile:=Tinifile.Create(inifilename); //下面就比如说你要把字体信息赋给Button; Button1.Font.Name:=MyIniFile.ReadString('Font','FontName','wrong'); Button1.Font.Size:=MyIniFile.ReadInteger('Font','FontSize',0); //其它的自己加上;end;end. TFont 本身就可以持久化,不需要另外多写代码 多条件满足以后才能保存,应该怎么做? 怎样对Table中的数据进行update! 动态调用窗体,中动态执行表单的问题!! delphi中把整型数据转换成浮点型的函数 delphi中能否调用access的“压缩和修复数据库”功能?? 一个sql语句的错误问题! master/detail問題 各位老大,快救命啊,我的D6要激活码,哪儿有生成器 怎样可以屏蔽掉ALT+F4按下的事件 怎样对二进制位操作?...各位大虾帮忙 如何通过注册表禁止Activex和Flash? 100分不够可另加 机上装两个显卡,接两台显示器,要求不同输出?
if fontdialog.execute then
font:=fontdialog.filename;//保存
savefileto
MyFile: file of Tfont;
MyFont: TFont;
beginend;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,IniFiles;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}//save
procedure TForm1.Button1Click(Sender: TObject);
var
IniFileName:String;
MyIniFile:Tinifile;
FFont:TFont;
begin
IniFileName:=ExpandFileName(ExtractFilePath(Application.ExeName)+'\SystemSet.ini');
MyIniFile:=Tinifile.Create(inifilename);
MyIniFile.WriteString('Font','FontName',FFont.Name);
MyIniFile.WriteInteger('Font','FontSize',FFont.Size);
//其它你自己加上;
end;//load
procedure TForm1.FormCreate(Sender: TObject);
var
IniFileName:String;
MyIniFile:Tinifile;
begin
IniFileName:=ExpandFileName(ExtractFilePath(Application.ExeName)+'\SystemSet.ini');
MyIniFile:=Tinifile.Create(inifilename);
//下面就比如说你要把字体信息赋给Button;
Button1.Font.Name:=MyIniFile.ReadString('Font','FontName','wrong');
Button1.Font.Size:=MyIniFile.ReadInteger('Font','FontSize',0);
//其它的自己加上;
end;end.