Inno Setup-如何在调整大小的向导中居中放置动画gif

问题描述

我想将动画gif居中放置在安装程序(WizardSizePercent=150)中所有页面的中间,而不使用值。

这是我的代码

var
  ParentForm: TSetupForm;

begin
  TimerID := 0;
  SlideID := 0;
  ContentHeight := ParentForm.Top + ParentForm.Height;
  ExtractTemporaryFile('Image1.bmp');
  ExtractTemporaryFile('Image2.bmp');
  ExtractTemporaryFile('Image3.bmp');
  ExtractTemporaryFile('Image4.bmp');
  ExtractTemporaryFile('Image5.bmp');
  ExtractTemporaryFile('Image6.bmp');


  Panel := TPanel.Create(ParentForm);
  Panel.Parent := ParentForm;
  Panel.Left := 185;
  Panel.Top := ParentForm.Top + 130;
  Panel.Width := 1000;
  Panel.Height := 380;
  Panel.Visible := True;

  BackImage := TBitmapImage.Create(ParentForm);
  BackImage.Parent := Panel;
  BackImage.Width:= 1000;
  BackImage.Height:= 380;
  BackImage.Left := (Panel.Height - BackImage.Height) div 2;
  BackImage.Top := (Panel.Height - BackImage.Height) div 2;
  BackImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\Image1.bmp'));
  StartSlideTimer;
end;

如何更改ContentHeightPanelBackImage的值?

解决方法

仅在应用WizardSizePercent之后创建图像。所以在CurPageChanged中,而不在InitializeWizard中。

或者更好的是,拥有一个更强大的解决方案,例如即使使用WizardResizable,也要通过更新图像坐标(或更确切地说是WizardForm.OnResize坐标来响应Panel,尽管我不了解其目的)。有关示例,请参见Setting control width to half of custom page SurfaceWidth does not work correctly in Inno Setup


还请注意,您不能使用常量坐标。您的图片在DPI高的显示器上无法正确居中。要么缩放坐标-例如检查Inno Setup Placing image/control on custom page。或者,以您的情况为佳,如果您根据图像和窗口的大小以编程方式计算居中坐标,请检查In Inno Setup,how do I center some text in the window?