Inno Setup在自定义页面上放置图像/控件 [英] Inno Setup Placing image/control on custom page

查看:174
本文介绍了Inno Setup在自定义页面上放置图像/控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我认为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;
 

解决方案

这就是类型TNewNotebookPageTWizardPage.Surface的作用.

 with BtnImage do
begin
  Parent := CustomPage.Surface;
  { ... }
end;
 

有关带有更多代码的单选按钮的类似问题:带有单选按钮的TInputDirWizardPage .


也不要使用绝对坐标和大小.当向导显示在高DPI/缩放显示器上时,您的布局将中断,如今,视网膜"和视网膜"已经很普遍了.显示.使用 ScaleX 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 := 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;
 

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

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

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

I'm trying to have an image on a custom page I can get the custom page to show or the image on a predefined page but not on the custom page.

Problem I think is with Parent := CustomPage.ID;.

Parent := WizardForm.SelectTasksPage; works though.

How to do this properly?

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;

解决方案

That's what TWizardPage.Surface of type TNewNotebookPage is for.

with BtnImage do
begin
  Parent := CustomPage.Surface;
  { ... }
end;

Similar question about radio buttons with more code: TInputDirWizardPage with Radio Buttons.


Also, never use absolute coordinates and sizes. Your layout will break, when the wizard is shown on high DPI/scaled display, what is quite common nowadays with "retina" displays. Use ScaleX and ScaleY functions. For the same reason, you should have images with different resolutions ready (see Inno Setup WizardImageFile looks bad with font scaling on Windows 7). Or at least scale/stretch the bitmap.

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;

Layout on 100% zoom (96 DPI):

Layout on 150% zoom (144 DPI):

Layout on 150% zoom (144 DPI) with offset/sizes scaling and image stretching:

这篇关于Inno Setup在自定义页面上放置图像/控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆