Inno Setup: How to manipulate progress bar on Run section?

前端 未结 1 1371
谎友^
谎友^ 2020-11-27 21:25

Similar to this question:
How to set the progress bar value in the [Run] section of the Inno Setup install script?

When the Inno Setup gets to the [Run]

相关标签:
1条回答
  • 2020-11-27 22:01

    It would be rather difficult to update the progress bar, while another process is running.

    I do not see a point of endeavoring it, as you are unlikely able to tell the progress of the sub-installer, so you won't know what to update the progress bar to.

    Except for special cases, when the sub-installer provides an API to report its progress.
    For an example, see:

    • Inno Setup Get progress from .NET Framework 4.5 (or higher) installer to update progress bar position or
    • Inno Setup - Make Inno Setup Installer report its installation progress status to master installer.

    To update the progress bar according to number of sub-installers finished, you can do:

    [Run]
    FileName: "process1"; BeforeInstall: UpdateProgress(0); AfterInstall: UpdateProgress(33)
    FileName: "process2"; AfterInstall: UpdateProgress(66)
    FileName: "process3"; AfterInstall: UpdateProgress(100)
    
    [Code]
    
    procedure UpdateProgress(Position: Integer);
    begin
      WizardForm.ProgressGauge.Position := Position * WizardForm.ProgressGauge.Max div 100;
    end;
    

    To divide part of the progress range for installing files and the rest to running the sub-installers, see
    Inno Setup - Prevent extraction of files from setting progress bar to 100%


    Another option is to use a "marquee" (= infinite) progress bar style.

    See Progress bar control styles.

    [Run]
    FileName: "process1"; BeforeInstall: SetMarqueeProgress(True)
    FileName: "process2"
    FileName: "process3"; AfterInstall: SetMarqueeProgress(False)
    
    [Code]
    
    procedure SetMarqueeProgress(Marquee: Boolean);
    begin
      if Marquee then
      begin
        WizardForm.ProgressGauge.Style := npbstMarquee;
      end
        else
      begin
        WizardForm.ProgressGauge.Style := npbstNormal;
      end;
    end;
    

    Works even on Windows XP, despite not being listed in the official Microsoft documentation anymore. Tested on Windows XP SP3.

    0 讨论(0)
提交回复
热议问题