【问题标题】:How to change wizard size (width and height) in an Inno Setup installer?如何在 Inno Setup 安装程序中更改向导大小(宽度和高度)?
【发布时间】:2021-06-23 04:42:56
【问题描述】:

Inno Setup 设置向导大小是固定的,但我想更改向导设置大小并更改一些项目,包括图像和...

【问题讨论】:

    标签: inno-setup


    【解决方案1】:

    Inno 设置 6

    Inno Setup 6 支持更改向导窗口的大小。

    您可以使用WizardSizePercent 更改向导窗口的大小。

    您也可以使用WizardResizable 来允许用户调整向导的大小(这是默认行为,如果您使用modern WizardStyle)。

    Inno 设置 5

    没有神奇的方法可以让向导页面变大。它们专为特定尺寸而设计。如果您想让它们更大,您必须逐页、逐个控制地进行操作,并仔细决定如何根据您的新尺寸布置它们。

    以下代码只是一个示例,您可能需要选择其他布局更改。

    procedure ShiftDown(Control: TControl; DeltaY: Integer);
    begin
      Control.Top := Control.Top + DeltaY;
    end;
    
    procedure ShiftRight(Control: TControl; DeltaX: Integer);
    begin
      Control.Left := Control.Left + DeltaX;
    end;
    
    procedure ShiftDownAndRight(Control: TControl; DeltaX, DeltaY: Integer);
    begin
      ShiftDown(Control, DeltaY);
      ShiftRight(Control, DeltaX);
    end;
    
    procedure GrowDown(Control: TControl; DeltaY: Integer);
    begin
      Control.Height := Control.Height + DeltaY;
    end;
    
    procedure GrowRight(Control: TControl; DeltaX: Integer);
    begin
      Control.Width := Control.Width + DeltaX;
    end;
    
    procedure GrowRightAndDown(Control: TControl; DeltaX, DeltaY: Integer);
    begin
      GrowRight(Control, DeltaX);
      GrowDown(Control, DeltaY);
    end;
    
    procedure GrowRightAndShiftDown(Control: TControl; DeltaX, DeltaY: Integer);
    begin
      GrowRight(Control, DeltaX);
      ShiftDown(Control, DeltaY);
    end;
    
    procedure GrowWizard(DeltaX, DeltaY: Integer);
    begin
      GrowRightAndDown(WizardForm, DeltaX, DeltaY);
    
      with WizardForm do
      begin
        GrowRightAndShiftDown(Bevel, DeltaX, DeltaY);
        ShiftDownAndRight(CancelButton, DeltaX, DeltaY);
        ShiftDownAndRight(NextButton, DeltaX, DeltaY);
        ShiftDownAndRight(BackButton, DeltaX, DeltaY);
        GrowRightAndDown(OuterNotebook, DeltaX, DeltaY);
        GrowRight(BeveledLabel, DeltaX);
    
        { WelcomePage }
        GrowDown(WizardBitmapImage, DeltaY);
        GrowRight(WelcomeLabel2, DeltaX);
        GrowRight(WelcomeLabel1, DeltaX);
    
        { InnerPage }
        GrowRight(Bevel1, DeltaX);
        GrowRightAndDown(InnerNotebook, DeltaX, DeltaY);
    
        { LicensePage }
        ShiftDown(LicenseNotAcceptedRadio, DeltaY);
        ShiftDown(LicenseAcceptedRadio, DeltaY);
        GrowRightAndDown(LicenseMemo, DeltaX, DeltaY);
        GrowRight(LicenseLabel1, DeltaX);
    
        { SelectDirPage }
        GrowRightAndShiftDown(DiskSpaceLabel, DeltaX, DeltaY);
        ShiftRight(DirBrowseButton, DeltaX);
        GrowRight(DirEdit, DeltaX);
        GrowRight(SelectDirBrowseLabel, DeltaX);
        GrowRight(SelectDirLabel, DeltaX);
    
        { SelectComponentsPage }
        GrowRightAndShiftDown(ComponentsDiskSpaceLabel, DeltaX, DeltaY);
        GrowRightAndDown(ComponentsList, DeltaX, DeltaY);
        GrowRight(TypesCombo, DeltaX);
        GrowRight(SelectComponentsLabel, DeltaX);
    
        { SelectTasksPage }
        GrowRightAndDown(TasksList, DeltaX, DeltaY);
        GrowRight(SelectTasksLabel, DeltaX);
    
        { ReadyPage }
        GrowRightAndDown(ReadyMemo, DeltaX, DeltaY);
        GrowRight(ReadyLabel, DeltaX);
    
        { InstallingPage }
        GrowRight(FilenameLabel, DeltaX);
        GrowRight(StatusLabel, DeltaX);
        GrowRight(ProgressGauge, DeltaX);
    
        { MainPanel }
        GrowRight(MainPanel, DeltaX);
        ShiftRight(WizardSmallBitmapImage, DeltaX);
        GrowRight(PageDescriptionLabel, DeltaX);
        GrowRight(PageNameLabel, DeltaX);
    
        { FinishedPage }
        GrowDown(WizardBitmapImage2, DeltaY);
        GrowRight(RunList, DeltaX);
        GrowRight(FinishedLabel, DeltaX);
        GrowRight(FinishedHeadingLabel, DeltaX);
      end;
    end;
    

    使用来自InitializeWizard 事件函数(或其他地方)的GrowWizard 函数,将宽度和高度作为参数进行更改:

    procedure InitializeWizard();
    begin
      GrowWizard(ScaleX(100), ScaleY(80));
    end;
    

    代码负责以下页面:

    • 欢迎页面

    • 许可证页面

    • 选择目录页

    • 选择组件页面

    • 选择任务页面

    • 就绪页面

    • 安装页面

    • 完成页面


    其他不太常见的页面留给读者作为练习:

    • 密码页
    • InfoBeforePage(与 LicensePage 相同)
    • 用户信息页
    • 选择程序组页面
    • 准备页面
    • InfoAfterPage(与 LicensePage 相同)

    类似问题:

    【讨论】:

    • 对于InforBeforePage 使用GrowRightAndDown(InfoBeforeMemo, DeltaX, DeltaY);
    【解决方案2】:

    我正在用最新的答案更新这个问题:

    Inno Setup 6 引入了许多更改,其中之一是调整向导窗口大小的可能性,这现在是 Inno Setup 的标准功能:

    可调整大小的向导窗口

    向导窗口现在可以随意调整大小:

    Added new [Setup] section directive: WizardResizable. If this directive is set to yes, the user will be able to resize the main Setup wizard window.
    Added new [Setup] section directive: WizardSizePercent, which can be used to increase the default size of all Setup and Uninstall wizard windows without increasing the font size.
    Pascal Scripting changes:
        Added new Anchors property to all controls and new KeepSizeY property to TSetupForm which allows you to add full support for WizardResizable and WizardSizePercent to all your custom controls, custom wizard pages and TSetupForm forms if you have any. See the CodeClasses.iss example script for an example. This example also shows other changes done to TSetupForm.
        Added new Constraints property to the TForm support class.
    

    新的现代巫师风格

    向导窗口现在支持更现代的外观:

    Added new [Setup] section directive: WizardStyle. If this directive is set to modern, Setup and Uninstall will show a more modern look and also the defaults for WizardResizable and WizardSizePercent change to respectively yes and 120,120.
    Change in default behavior: Earlier versions of Inno Setup also supported WizardStyle and if you still have WizardStyle=modern in your script (which was allowed for backward compatibility but didn't actually change anything) and don't want to new modern look, you should remove this line or change it to WizardStyle=classic.
    Updated all examples and the Compiler IDE's New Script Wizard to use WizardStyle=modern.
    Pascal Scripting change: Added new SurfaceColor property to the TWizardPage support class.
    

    现在无需任何特殊的技巧或代码即可轻松调整向导窗口的大小。

    【讨论】:

      【解决方案3】:

      我强烈建议使用 NSIS 而不是 InnoSetup 来创建 Windows 安装程序。

      它具有您所要求的所有灵活性,以及​​更多:

      • NSIS 可以在任何方向上完全编写脚本,我能够实现我所需要的安装程序的每一个自定义。
      • NSIS 创建技术上更好的安装程序:没有混乱的临时文件和多个解压阶段。
      • 因此,创建的安装程序非常快。
      • NSIS 可用于在交叉编译设置中创建 Windows 安装程序,参见例如Debian nsis package
      • 也就是说,您可以创建一个非常好的 Windows 安装程序,而无需接触 Windows 系统。这就是为什么它也成为 Windows 交叉编译工具链的一部分 MXE

      到目前为止,我遇到的 NSIS 的唯一缺点是:

      • 它的脚本语言有点特别,需要一些初步的学习才能习惯。

      【讨论】:

        猜你喜欢
        • 2017-04-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-05-18
        • 2020-06-22
        • 2017-01-19
        • 1970-01-01
        相关资源
        最近更新 更多