function FontToStr(Font: TFont): string;
var
i: TFontStyle;
begin
with Font do
begin
Result := '"'+Name+ '",$'+IntToHex(Color,8)+','+IntToStr(Size)
+','+IntToStr(Ord(Pitch))+',';
for i:=low(TFontStyle) to high(TFontStyle) do
if i in style then
Result := Result + IntToStr(Ord(i));
end;
end;
procedure StrToFont(Font: TFont; val: string);
var
w: TStringList;
f: TFont;
i: integer;
begin
w := TStringList.Create;
f := TFont.Create;
try
try
w.CommaText := val;
if (w.Count=4) or (w.Count=5) then
begin
f.Name := w[0];
f.Color := StrToInt(w[1]);
f.Size := StrToInt(w[2]);
f.Pitch := TFontPitch(StrToInt(w[3]));
end else
raise Exception.Create('');
if (w.Count=5) then
begin
for i:=1 to length(w[4]) do
f.Style := f.Style + [TFontStyle(StrToInt(w[4][i]))];
end else
f.Style := [];
Font.Assign(f);
except
end;
finally
w.free;
f.Free;
end;
end;
장현건 님이 쓰신 글 :
: 잘아시는 분들한테 문의 드릴려고 이렇게 염치 없이 적습니다.
: 오전 내내 찾는데 답이 안나오네요 ㅠ
:
: memo를 통하여 csv파일에
: sFont.sprintf(" Name : %s", FontDialog_Line1->Font->Color);
: Memo_InitialData->Lines->Insert(1, sFont);
: //이런식으로 저장을 해서..(여기까지는 잘 됩니다. ㅠ)
:
:
: Form_Line1->FontDialog_Line1->Font->Color = Form_Line1->Memo_InitialData->Lines->operator [](1).SubString(24,Memo_Temp->Lines->operator [](1).Length()-2);
: //이런식으로 호출을 할려 하는데..
:
: [C++ Error] Unit_SetLine.cpp(3142): E2034 Cannot convert 'AnsiString' to 'TColor'
: //이런 에러가 발생합니다.
:
: TColor같은 자료형에 넣을 수 있도록 변환할때 .ToInt(); 같이 쉽게 변환 할수 있는 방법이 없을까요?
|