delphi 保存FontDialog设置到ini文件
public { Public declarations } procedure SetIniFile(Strtitle, StrName :String;FileName : String); function ReadIniFile(Strtitle, StrName :String): String; function TForm11.ReadIniFile(Strtitle, StrName: String): String; var iniFile : TIniFile; begin iniFile := TIniFile.Create(ExtractFileDir(Application.ExeName)+'\Config.ini'); Result := iniFile.ReadString(Strtitle,StrName,''); IniFile.Free; end; procedure TForm11.SetIniFile(Strtitle, StrName :String; FileName: String); var iniFile : TIniFile; begin iniFile := TIniFile.Create(ExtractFileDir(Application.ExeName)+'\Config.ini'); showmessage(ExtractFileDir(Application.ExeName)); iniFile.WriteString(Strtitle,StrName,fileName); IniFile.Free; end; //写入 procedure TForm11.Button1Click(Sender: TObject); begin if FontDialog1.Execute then label1.Font := FontDialog1.Font; SetIniFile('title','font-size',inttostr(fontDialog1.Font.Size)); SetIniFile('title','font-color',inttostr(fontDialog1.Font.Color)); // fsBold, fsItalic, fsUnderline, fsStrikeOut if (fsBold in FontDialog1.Font.Style) then SetIniFile('title','font-style','fsBold'); if (fsItalic in FontDialog1.Font.Style) then SetIniFile('title','font-style','fsItalic'); if (fsUnderline in FontDialog1.Font.Style) then SetIniFile('title','font-style','fsUnderline'); if (fsStrikeOut in FontDialog1.Font.Style) then SetIniFile('title','font-style','fsStrikeOut'); SetIniFile('title','font-name',Fontdialog1.Font.Name); end; //读取 procedure TForm11.Button2Click(Sender: TObject); var titlefontstyle : TFontStyles; titlestyle : String; begin titlestyle := ReadIniFile('title','font-style'); if pos ('fsBold', titlestyle) > 0 then titlefontstyle := titlefontstyle + [fsBold]; if pos ('fsItalic', titlestyle ) > 0 then titlefontstyle := titlefontstyle + [fsItalic]; if pos ('fsUnderline' , titlestyle) > 0 then titlefontstyle := titlefontstyle + [fsUnderline]; if pos ('fsStrikeOut',titlestyle) >0 then titlefontstyle := titlefontstyle + [fsStrikeOut]; label1.Font.Style := titlefontstyle; label1.Font.Size := strtoint(ReadIniFile('title','font-size')); end;
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!