在Inno Setup中覆盖整页的图像

时间:2017-06-10 09:58:31

标签: inno-setup pascalscript

继续:Inno Setup Placing image/control on custom page

这就是我需要的:

CustomPage := CreateCustomPage(wpLicense, 'Heading', 'Sub heading.');

ExtractTemporaryFile('image.bmp');

BtnImage := TBitmapImage.Create(WizardForm);
with BtnImage do
begin
  Parent := CustomPage.Surface;
  Bitmap.LoadFromFile(ExpandConstant('{tmp}')+'\image.bmp');
  AutoSize := True;
  AutoSize := False;
  Height := ScaleX(Height);
  Width := ScaleY(Width);
  Stretch := True;
  Left := ScaleX(90);
  Top := WizardForm.SelectTasksPage.Top + WizardForm.SelectTasksPage.Height -
         Height - ScaleY(8);
  Cursor := crHand;
  OnClick := @ImageOnClick;
end;

但是我希望背景图像是标题下方和页脚上方没有侧边的空间的完整大小。我正在尝试各种拉伸/边距/高度/宽度,但结果很混乱。无论DPI如何,实现这一目标的最佳方法是什么?

1 个答案:

答案 0 :(得分:1)

您可以使用TWizardPage.SurfaceHeight and TWizardPage.SurfaceWidth检索(自定义)网页表面的大小。

BtnImage.Height := CustomPage.SurfaceHeight;
BtnImage.Width := CustomPage.SurfaceWidth;

虽然您会看到(自定义)页面未覆盖“标题”(MainPanel)和“页脚”(带按钮的底部)之间的整个区域。

enter image description here

如果要在“标题”和“页脚”之间的整个区域显示图像,则无法将其放在(自定义)页面上。您必须将它放在InnerPage上(所有页面的父控件都是“标题”)。

BtnImage.Parent := WizardForm.InnerPage;

BtnImage.Left := 0;
BtnImage.Top := WizardForm.Bevel1.Top + 1;
BtnImage.Width := WizardForm.InnerPage.ClientWidth;
BtnImage.Height := WizardForm.InnerPage.ClientHeight - BtnImage.Top;

但是这样,当自定义页面显示/隐藏时,图像不会自动显示/隐藏。你必须编码。使用CurPageChanged event function

procedure CurPageChanged(CurPageID: Integer);
begin
  WizardForm.InnerNoteBook.Visible := (CurPageID <> CustomPage.ID);
  BtnImage.Visible := (CurPageID = CustomPage.ID);
end;

enter image description here

类似的问题: