从INI文件中读取颜色值

时间:2014-08-25 11:13:28

标签: inno-setup

我想更改标题背景颜色 - WizardForm.MainPanel.Color。 我试图从ini文件中读取颜色值(clWhite),但没有成功。 我想这是因为WizardForm.MainPanel.Color无法接收字符串值,我使用GetIniString从ini获取值。 有没有办法从ini读取颜色值? 如果没有,有没有办法将字符串转换为值?

1 个答案:

答案 0 :(得分:0)

no built-in function将颜色字符串转换为TColor值。即使该线程中的答案显示了如何制作此类函数,但它们都不包括从颜色常量转换(clWhiteclBlue等值)。那是因为您需要为所有颜色常量声明一系列常量(这不是不可能的,但在许多情况下是不必要的)。

如果现在还不太晚,并且你有一个自由的格式,你将存储颜色,我建议你使用整数类型。您可以使用(代码)我为您编写的这些帮助函数:

[Code]
function SetIniColor(const FileName, Section, Key: string;
  Value: TColor): Boolean;
begin
  Result := SetIniInt(Section, Key, Value, FileName);
end;

function GetIniColor(const FileName, Section, Key: string;
  Default: TColor): TColor;
begin
  Result := GetIniInt(Section, Key, Default, Low(Result), High(Result), FileName);
end;