Inno Setup-更改PageNameLabel / PageDescriptionLabel字体参数(颜色,大小)

时间:2018-08-07 13:00:42

标签: inno-setup

所以我在.iss文件中找到了它:

[Files]
Source: "WizModernImageTop2.bmp"; Flags: dontcopy

[Code]

function CloneStaticTextToLabel(StaticText: TNewStaticText): TLabel;
begin
  Result := TLabel.Create(WizardForm);
  Result.Parent := StaticText.Parent;
  Result.Left := StaticText.Left;
  Result.Top := StaticText.Top;
  Result.Width := StaticText.Width;
  Result.Height := StaticText.Height;
  Result.AutoSize := StaticText.AutoSize;
  Result.ShowAccelChar := StaticText.ShowAccelChar;
  Result.WordWrap := StaticText.WordWrap;
  Result.Font := StaticText.Font;
  StaticText.Visible := False;
  WizardForm.PageDescriptionLabel.Font.Color := clRed;
  WizardForm.PageNameLabel.Font.Color := clRed;
end;

var
  PageDescriptionLabel: TLabel;
  PageNameLabel: TLabel;

procedure InitializeWizard;
var
  BitmapImage: TBitmapImage;
begin
  ExtractTemporaryFile('WizModernImageTop2.bmp');
  BitmapImage := TBitmapImage.Create(WizardForm);
  BitmapImage.Parent := WizardForm.MainPanel;
  BitmapImage.Width := WizardForm.MainPanel.Width;
  BitmapImage.Height := WizardForm.MainPanel.Height;
  BitmapImage.Stretch := True;
  BitmapImage.AutoSize := False;
  BitmapImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\WizModernImageTop2.bmp'));
  WizardForm.WizardSmallBitmapImage.Visible := True;
  WizardForm.PageDescriptionLabel.Visible := True;
  WizardForm.PageNameLabel.Visible := True;


  { Create TLabel equivalent of standard TNewStaticText components }
  PageNameLabel := CloneStaticTextToLabel(WizardForm.PageNameLabel);
  PageDescriptionLabel := CloneStaticTextToLabel(WizardForm.PageDescriptionLabel);
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  { Update the custom TLabel components from the standard hidden components }
  PageDescriptionLabel.Caption := WizardForm.PageDescriptionLabel.Caption;
  PageNameLabel.Caption := WizardForm.PageNameLabel.Caption;
end;

我想要实现的目标:

将PageNameLabel和PageDescriptionLabel的颜色/大小(必要时)更改为白色,以使其可见。现在黑底黑字。我不知道WizardForm元素的字体参数,嗯...

更新:如果有人要在其安装程序中使用图像,而不是在右侧显示小WizardSmallImage图标,请使用上面提供的代码,这样可以使标签显示在图像顶部并启用透明度。它需要Inno的Unicode版本才能工作。

1 个答案:

答案 0 :(得分:0)

使用TNewStaticText.Font.Color更改标签颜色。

WizardForm.PageDescriptionLabel.Font.Color := clWhite;
WizardForm.PageNameLabel.Font.Color := clWhite;