Inno Setup - how to center an animated gif in resized wizard

假装没事ソ 提交于 2020-12-04 03:57:11

问题


I would like to center my animated gif right in the middle of all pages in my installer ( WizardSizePercent=150) without using values.

Here is my code:

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;

How do I have to change the values of ContentHeight, Panel and BackImage?


回答1:


Either create the image only after the WizardSizePercent is applied. So e.g. in the CurPageChanged, not in InitializeWizard.

Or better, to have a more robust solution, that works e.g. even with WizardResizable, respond to WizardForm.OnResize by updating the image coordinates (or rather the Panel coordinates – though I do not understand its purpose). For an example, see Setting control width to half of custom page SurfaceWidth does not work correctly in Inno Setup.


Also note that you cannot use constant coordinates. Your image would not center correctly on high DPI displays. Either scale the coordinates – for that check for example Inno Setup Placing image/control on custom page. Or in your case, it would be better, if you calculate the centered coordinates programmatically based on the image and window sizes – for that, check the In Inno Setup, how do I center some text in the window?



来源:https://stackoverflow.com/questions/63502238/inno-setup-how-to-center-an-animated-gif-in-resized-wizard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!