代码之家  ›  专栏  ›  技术社区  ›  Robert Wigley

Inno Setup定义十六进制颜色常量

  •  1
  • Robert Wigley  · 技术社区  · 10 年前

    我正在尝试使用 [ISPP] 节定义十六进制颜色,稍后将在 [Code] 节作为专色,其值可能会在将来更改,但我在运行时遇到类型不匹配错误。以下是代码的相关部分:

    [ISPP]
    #define ColorPetrol "$C8C264"
    
    [Code]
    procedure InitializeWizard();
    var
      PortLabel: TNewStaticText;
    begin
      PortLabel := TNewStaticText.Create(WizardForm);
      PortLabel.Caption := 'Port';
      PortLabel.Top := ScaleY(78);
      PortLabel.Parent := Page.Surface;
      PortLabel.Font.Color := ExpandConstant('{#ColorPetrol}');
    end;
    

    我假设错误是由define常量为字符串和 PortLabel.Font.Color 需要十六进制值。如何在 [国际标准普尔] 节并以这种方式正确使用?

    1 回复  |  直到 10 年前
        1
  •  2
  •   sschuberth    10 年前

    只需使用 PortLabel.Font.Color := {#ColorPetrol}; . ExpandConstant() 用于扩展内置的Inno Setup常量,而不是用于ISPP定义。后者实际上只是关于文本替换。

    顺便说一句,我不知道 [ISPP] 部分IMO你应该把定义移到 [Code] 部分

    推荐文章