首页 > 解决方案 > Inno Setup - 更改 PageNameLabel / PageDescriptionLabel 字体参数(颜色、大小)

问题描述

所以我在我的 .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 图标,请使用上面提供的代码,这样标签就会显示在启用透明度的图像顶部。它需要 Unicode 版本的 Inno 才能工作。

标签: inno-setup

解决方案


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

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

推荐阅读