用
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;