Inno Setup 在自定义页面上放置图像/控件

778*_*899 8 inno-setup pascalscript

我正在尝试在自定义页面上显示图像 我可以让自定义页面显示或在预定义页面上显示图像,但不能在自定义页面上显示。

我认为问题在于Parent := CustomPage.ID;.

Parent := WizardForm.SelectTasksPage; 虽然有效。

如何正确地做到这一点?

procedure ImageOnClick(Sender: TObject);
var
  ErrorCode: Integer;
begin
  ShellExec('', 'http://test.com', '', '', SW_SHOW, ewNoWait, ErrorCode);
end;

var
  CustomPage: TWizardPage;
  BtnImage: TBitmapImage;

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

  ExtractTemporaryFile('image.bmp');

  BtnImage := TBitmapImage.Create(WizardForm);
  with BtnImage do
  begin
    Parent := CustomPage.ID;
    Bitmap.LoadFromFile(ExpandConstant('{tmp}')+'\image.bmp');
    AutoSize := True;
    Left := 90;
    Top := WizardForm.SelectTasksPage.Top + WizardForm.SelectTasksPage.Height - Height - 8;
    Cursor := crHand;
    OnClick := @ImageOnClick;
  end;
end;
Run Code Online (Sandbox Code Playgroud)

Mar*_*ryl 7

这就是TWizardPage.SurfacetypeTNewNotebookPage的用途。

with BtnImage do
begin
  Parent := CustomPage.Surface;
  { ... }
end;
Run Code Online (Sandbox Code Playgroud)

相关问题:


此外,永远不要使用绝对坐标和大小。当向导显示在高 DPI/缩放显示器上时,您的布局将中断,这在如今“视网膜”显示器上很常见。用途ScaleXScaleY功能。出于同样的原因,您应该准备好具有不同分辨率的图像(请参阅Inno Setup WizardImageFile 在 Windows 7 上使用字体缩放看起来很糟糕)。或者至少缩放/拉伸位图。

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 := ScaleY(Height);
  Width := ScaleX(Width);
  Stretch := True;
  Left := ScaleX(90);
  Top := WizardForm.SelectTasksPage.Top + WizardForm.SelectTasksPage.Height -
         Height - ScaleY(8);
  Cursor := crHand;
  OnClick := @ImageOnClick;
end;
Run Code Online (Sandbox Code Playgroud)

100% 缩放 (96 DPI) 的布局:

100% 缩放 (96 DPI) 的布局

150% 缩放 (144 DPI) 的布局:

150% 缩放 (144 DPI) 的布局

150% 缩放 (144 DPI) 布局,偏移/尺寸缩放和图像拉伸:

150% 缩放 (144 DPI) 布局,偏移/尺寸缩放和图像拉伸