Inno Setup PageDescriptionLabel相互重叠

时间:2013-01-21 11:53:48

标签: installer windows-installer installation inno-setup

我最近切换到Inno Setup,这太棒了! 除了我遇到麻烦之外,我几乎能够完成大部分工作。

基本上,我正在尝试创建自己的标题设计,我试图使页面标题/页面描述透明。但是,它们在页面更改时相互重叠。 (请参考图片)。

http://img703.imageshack.us/img703/6180/88647320.png

代码:

procedure InheritBoundsRect(ASource, ATarget: TControl);
begin
  ATarget.Left := ASource.Left;
  ATarget.Top := ASource.Top;
  ATarget.Width := ASource.Width;
  ATarget.Height := ASource.Height;
end;

procedure CurPageChanged(CurPageID: Integer);
var
  TD: TLabel;
begin
    TD := TLabel.Create(WizardForm);
    TD.Parent := WizardForm.PageDescriptionLabel.Parent;
    TD.Caption := WizardForm.PageDescriptionLabel.Caption;
    TD.WordWrap := WizardForm.PageDescriptionLabel.WordWrap;
    TD.Transparent := True;
    InheritBoundsRect(WizardForm.PageDescriptionLabel, TD);
    TD.AutoSize := True;
end;

另外,我甚至不确定这是否是最佳方式,所以如果有人有任何建议,我很乐意听到它们。

1 个答案:

答案 0 :(得分:4)

正如您正确指出的那样,您多次创建标签。更具体地说,每次显示新页面时(每次按下下一个或后退按钮)。您只需要创建一次标签,最好是在向导表单初始化事件中,如InitializeWizard。除此之外,您需要在每次页面更改时更改标签的标题。最好的情况是,您需要使用CurPageChanged事件。因此,要制作透明的页面描述标签(我错过了),您可以使用如下脚本:

[Code]
var
  DescLabel: TLabel;

procedure InheritBoundsRect(ASource, ATarget: TControl);
begin
  ATarget.Left := ASource.Left;
  ATarget.Top := ASource.Top;
  ATarget.Width := ASource.Width;
  ATarget.Height := ASource.Height;
end;

procedure InitializeWizard;
begin
  DescLabel := TLabel.Create(WizardForm);
  DescLabel.Parent := WizardForm.PageDescriptionLabel.Parent;  
  DescLabel.WordWrap := WizardForm.PageDescriptionLabel.WordWrap;
  DescLabel.AutoSize := WizardForm.PageDescriptionLabel.AutoSize;
  DescLabel.Transparent := True;
  InheritBoundsRect(WizardForm.PageDescriptionLabel, DescLabel);

  WizardForm.PageDescriptionLabel.Visible := False;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  DescLabel.Caption := WizardForm.PageDescriptionLabel.Caption;
end;