【问题标题】:Inno Setup - how to center an animated gif in resized wizardInno Setup - 如何在调整大小的向导中居中动画 gif
【发布时间】:2020-08-20 09:33:03
【问题描述】:

我想将我的动画 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;

如何更改ContentHeight、Panel 和BackImage 的值?

【问题讨论】:

    标签: inno-setup pascalscript


    【解决方案1】:

    WizardSizePercent(WizardStyle=modern 明示和暗示)仅适用于InitializeWizard。因此,明确定位在InitializeWizard 中的控件之后可能会错位。

    仅在应用WizardSizePercent 之后才定位图像。所以例如在CurPageChanged 中,而不是在InitializeWizard 中。

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

    在很多情况下,您还可以使用Anchors 属性让控件自动调整大小。举个例子,见Inno Setup - aligning custom button with the Cancel button。


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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-18
      • 1970-01-01
      • 1970-01-01
      • 2011-11-01
      • 2012-09-07
      • 2011-02-23
      • 2012-04-16
      相关资源
      最近更新 更多