type
TTargetControl =
class
(TControl);
procedure
SaveControlFont(Root: TWinControl;ini: TIniFile);
var
i,style:
Integer
;
begin
for
i :=
0
to
ROot
.
ControlCount -
1
do
begin
ini
.
WriteString(Root
.
Controls[i].Name+
'_Font'
,
'Name'
,TTargetControl(Root
.
Controls[i]).Font
.
Name);
ini
.
WriteInteger(root
.
Controls[i].Name+
'_Font'
,
'Size'
,TTargetControl(Root
.
Controls[i]).Font
.
SIZE);
ini
.
WriteInteger(root
.
Controls[i].Name+
'_Font'
,
'Color'
,TTargetControl(Root
.
Controls[i]).Font
.
Color);
if
fsBold
in
TTargetControl(Root
.
Controls[i]).Font
.
Style
then
style :=
1
else
style :=
0
;
if
fsItalic
in
TTargetControl(Root
.
Controls[i]).Font
.
Style
then
style := style
or
2
;
if
fsUnderline
in
TTargetControl(Root
.
Controls[i]).Font
.
Style
then
style := style
or
4
;
if
fsStrikeOut
in
TTargetControl(Root
.
Controls[i]).Font
.
Style
then
style := style
or
8
;
ini
.
WriteInteger(root
.
Controls[i].Name+
'_Font'
,
'Style'
,style);
end
;
end
;
procedure
LoadFont(Root:TWinControl;ini: TIniFile);
var
i,style:
Integer
;
st:
string
;
fstyle: TFontStyles;
begin
for
i :=
0
to
Root
.
ControlCount -
1
do
begin
st := ini
.
ReadString(Root
.
Controls[i].Name+
'_Font'
,
'Name'
,
''
);
if
st <>
''
then
begin
TTargetControl(Root
.
Controls[i]).Font
.
Name := st;
TTargetControl(Root
.
Controls[i]).Font
.
SIZE := ini
.
ReadInteger(root
.
Controls[i].Name+
'_Font'
,
'Size'
,TTargetControl(Root
.
Controls[i]).Font
.
SIZE);
TTargetControl(Root
.
Controls[i]).Font
.
Color := ini
.
ReadInteger(root
.
Controls[i].Name+
'_Font'
,
'Color'
,TTargetControl(Root
.
Controls[i]).Font
.
Color);
style := ini
.
ReadInteger(root
.
Controls[i].Name+
'_Font'
,
'Style'
,
0
);
if
style
and
1
=
1
then
fstyle := [fsBold]
else
fstyle := [];
if
style
and
2
=
2
then
Include(fstyle,fsItalic);
if
style
and
4
=
4
then
Include(fstyle,fsUnderline);
if
style
and
8
=
8
then
Include(fstyle,fsStrikeOut);
TTargetControl(Root
.
Controls[i]).Font
.
Style := fstyle;
end
;
end
;
end
;
SaveControlFont(Panel1,iniFile);
LoadFont(Panel1,IniFile);