就是在执行
ColorDialog.Execute
fontDialog.Execute
以后的结果保存到INI文件中.

解决方案 »

  1.   

    颜色转换成整型保存
    字体用下面的函数转换成字符串,然后保存unit xFonts;interfaceuses Classes, Graphics, SysUtils;procedure StringToFont(sFont: string; Font: TFont; bIncludeColor: Boolean = True);
    function FontToString(Font: TFont; bIncludeColor: Boolean = True): string;implementationconst
      csfsBold      = '|Bold';
      csfsItalic    = '|Italic';
      csfsUnderline = '|Underline';
      csfsStrikeout = '|Strikeout';  //
      // Expected format:
      //   "Arial", 9, [Bold], [clRed]
      //
    procedure StringToFont(sFont: string; Font: TFont; bIncludeColor: Boolean = True);
    var
      P     : Integer;
      sStyle: string; 
    begin
      with Font do
        try
          // get font name
          P := Pos(',', sFont);
          name := Copy(sFont, 2, P - 3);
          Delete(sFont, 1, P);      // get font size
          P := Pos(',', sFont);
          Size := StrToInt(Copy(sFont, 2, P - 2));
          Delete(sFont, 1, P);      // get font style
          P := Pos(',', sFont);
          sStyle := '|' + Copy(sFont, 3, P - 4);
          Delete(sFont, 1, P);      // get font color
          if bIncludeColor then Color := StringToColor(Copy(sFont, 3, Length(sFont) - 3));      // convert str font style to
          // font style
          Style := [];
          if (Pos(csfsBold, sStyle) > 0) then Style := Style + [fsBold];
          if (Pos(csfsItalic, sStyle) > 0) then Style := Style + [fsItalic];
          if (Pos(csfsUnderline, sStyle) > 0) then Style := Style + [fsUnderline];
          if (Pos(csfsStrikeout, sStyle) > 0) then Style := Style + [fsStrikeOut];
        except
        end;
    end;//
    // Output format:
    //   "Aril", 9, [Bold|Italic], [clAqua]
    //
    function FontToString(Font: TFont; bIncludeColor: Boolean = True): string;
    var
      sStyle: string;
    begin
      with Font do
      begin
        // convert font style to string
        sStyle := '';
        if (fsBold in Style) then sStyle := sStyle + csfsBold;
        if (fsItalic in Style) then sStyle := sStyle + csfsItalic;
        if (fsUnderline in Style) then sStyle := sStyle + csfsUnderline;
        if (fsStrikeOut in Style) then sStyle := sStyle + csfsStrikeout;    if ((Length(sStyle) > 0) and ('|' = sStyle[1])) then
          sStyle := Copy(sStyle, 2, Length(sStyle) - 1);    Result := Format('"%s", %d, [%s]',[name, Size, sStyle]);
        if bIncludeColor then
          Result := Result + Format(', [%s]',[ColorToString(Color)]);
      end;
    end;end.
      

  2.   

    取得颜色和字体的属性后,写入ini文件,在下次启动时判断文件存在的话,就读取ini文件内容设置属性 如:需要使用inifiles单元procedure demo;
    var
      inifile: TIniFile;
    begin
      inifile := TIniFile.Create('file name');
      try
        inifile.WriteString('section', 'ident', 'value');
        //....
      finally
        FreeAndNil(inifile);
      end;
    end
      

  3.   

    回ascloudy:谢谢,我现在试一下,没问题了就给分,有问题了再请教.回growleaf:可能是我没有说清楚,我问的不是INI文件操作的问题.