I'm trying to show marquee progress bar on TOutputMarqueeProgressWizardPage while doing a long operation. I use SetTimer
function to call my UpdateProgress
callback. The idea is taken from this thread. Here is my script:
[Setup]
AppId={{F25E1D25-DF59-4B37-AD32-1EBD5F6A3CA6}
AppName="My Program"
AppVersion=1.5
CreateAppDir=no
OutputBaseFilename=setup
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "WhatsAppSetup.exe"; Flags: ignoreversion dontcopy
[Code]
var
CustomPage: TOutputMarqueeProgressWizardPage;
CustomPageAfterID: Integer;
procedure InitializeWizard;
begin
CustomPage := CreateOutputMarqueeProgressPage('CreateOutputMarqueeProgressPage', 'ADescription');
CustomPageAfterID := wpReady;
end;
function SetTimer(Wnd: LongWord; IDEvent, Elapse: LongWord; TimerFunc: LongWord): LongWord;
external 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd: LongWord; uIDEvent: LongWord): BOOL;
external 'KillTimer@user32.dll stdcall';
procedure UpdateProgress();
begin
Log('Animating');
CustomPage.Animate;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
ResultCode: Integer;
Timer: LongWord;
begin
Log('Page ID: ' + IntToStr(CurPageId));
if CurPageID = CustomPageAfterID then begin
try
Timer := SetTimer(0, 0, 250, CreateCallback(@UpdateProgress));
CustomPage.Show;
ExtractTemporaryFile('WhatsAppSetup.exe');
Exec(ExpandConstant('{tmp}\WhatsAppSetup.exe'), '--silent', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
Sleep(20000);
finally
KillTimer(0, Timer);
CustomPage.Hide;
end;
end;
Result := True;
end;
However, my callback is called only once, here is an excerpt from output:
[20:59:38,970] Extracting temporary file: C:\Users\user\AppData\Local\Temp\is-DCI5S.tmp\WhatsAppSetup.exe
[20:59:39,783] Animating
[20:59:59,931] Found 0 files to register with RestartManager.
How to fix that and animate progress bar periodically?