Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
746 views
in Technique[技术] by (71.8m points)

pascalscript - Inno Setup Placing image/control on custom page

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;
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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

Related questions:


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 := 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;

Layout on 100% zoom (96 DPI):

Layout on 100% zoom (96 DPI)

Layout on 150% zoom (144 DPI):

Layout on 150% zoom (144 DPI)

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...