C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[56487] Re:Font형을 csv파일로 저장했다가 호출할려 합니다. 호출할때 Fitch, Style, Color의 자료형 변경이 궁
civilian [civilian] 1224 읽음    2009-03-22 13:07
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(); 같이 쉽게 변환 할수 있는 방법이 없을까요?

+ -

관련 글 리스트
56486 Font형을 csv파일로 저장했다가 호출할려 합니다. 호출할때 Fitch, Style, Color의 자료형 변경이 궁금합 장현건 1290 2009/03/22
56487     Re:Font형을 csv파일로 저장했다가 호출할려 합니다. 호출할때 Fitch, Style, Color의 자료형 변경이 궁 civilian 1224 2009/03/22
56488         Re:Re:Font형을 csv파일로 저장했다가 호출할려 합니다. 호출할때 Fitch, Style, Color의 자료형 변경 장현건 1244 2009/03/22
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.