您的位置:首页 > 其它

用户自定义控件颜色:用ColorDialog自定义颜色,并从配置文件中读取和写入

2010-03-10 17:43 477 查看


ColorToString(ColorDialog.Color)

StringToColor('$800080')

实现自定义颜色

 

procedure TFormBreakSiteStat.SpeedButton1Click(Sender: TObject);
var
  lIniPath: string;
  ini: TIniFile;
begin
  lIniPath:= ExtractFilePath(Application.ExeName)+'ProjectCFMS_Client.ini';
  ini:= TIniFile.Create(lIniPath);
  try
    if ColorDialog.Execute then
    begin
      if RBCaption.Checked then
      begin
        ini.WriteString('Color','CaptionColor',ColorToString(ColorDialog.Color));
        FG_RepShow.CaptionColor:= ColorDialog.Color;
      end;
      if RBLabel.Checked then
      begin
        ini.WriteString('Color','LabelColor',ColorToString(ColorDialog.Color));
        FG_RepShow.LabelColor:= ColorDialog.Color;
      end;
      if RBData.Checked then
      begin
        ini.WriteString('Color','DataColor',ColorToString(ColorDialog.Color));
        FG_RepShow.DataColor:= ColorDialog.Color;
      end;
      if RBBackground.Checked then
      begin
        ini.WriteString('Color','BackgroundColor',ColorToString(ColorDialog.Color));
        FG_RepShow.Color:= ColorDialog.Color;
      end;
    end;
  finally
    ini.Free;
  end;
end;

procedure TFormBreakSiteStat.GetRepColor;
var
  lIniPath: string;
  ini: TIniFile;
begin
  lIniPath:= ExtractFilePath(Application.ExeName)+'ProjectCFMS_Client.ini';
  if FileExists(lIniPath) then
  begin
    ini:= TIniFile.Create(lIniPath);
    try
      FG_RepShow.CaptionColor:= StringToColor(ini.ReadString('Color','CaptionColor','clPurple'));
      FG_RepShow.LabelColor:= StringToColor(ini.ReadString('Color','LabelColor','clSkyBlue'));
      FG_RepShow.DataColor:= StringToColor(ini.ReadString('Color','DataColor','clTeal'));
      FG_RepShow.Color:= StringToColor(ini.ReadString('Color','BackgroundColor','clInactiveCaptionText'));
    finally
      ini.Free;
    end;
  end;

 
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ini string