Этот код рабочий! Возможно кому-то это также будет полезно ))
+ 1500 лайков




Код: Выделить всё
[Setup]
AppName=ProgressBar
AppVerName=ProgressBar
OutputBaseFilename=ProgressBar
DefaultDirName=ProgressBar
OutputDir=userdocs:..\desktop
Uninstallable=no
[Files]
Source: "compiler:Examples\MyProg.exe"; DestDir: "{app}"
Source: "compiler:Examples\MyProg-x64.exe"; DestDir: "{app}";
[ Code]
procedure InitializeWizard;
begin
WizardForm.ProgressGauge.Parent:=WizardForm;
WizardForm.ProgressGauge.SetBounds(ScaleX(-1), ScaleY(290), ScaleX(500), ScaleY(30));
//WizardForm.ProgressGauge.Position:=10;
end;
var
ProgressPage: TOutputProgressWizardPage;
I, Step, Wait: Integer;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
Wait:=2000;
Step:=5;
ProgressPage:=CreateOutputProgressPage(WizardForm.PageNameLabel.Caption, WizardForm.PageDescriptionLabel.Caption);
ProgressPage.SetProgress(0, Wait);
ProgressPage.Show;
try
for I := 0 to Wait div Step do
begin
ProgressPage.SetProgress(I * Step, Wait);
Sleep(Step);
end;
finally
ProgressPage.Hide;
ProgressPage.Free;
end;
end;
end;Код: Выделить всё
[Setup]
AppName=ProgressBar
AppVerName=ProgressBar
OutputBaseFilename=ProgressBar
DefaultDirName=ProgressBar
OutputDir=userdocs:..\desktop
Uninstallable=no
[ Code]
function GetWindowLong(Wnd: HWnd; Index: Integer): Longint; external 'GetWindowLongA@user32.dll stdcall';
function SetWindowLong(Wnd: HWnd; Index: Integer; NewLong: Longint): Longint; external 'SetWindowLongA@user32.dll stdcall';
function GetTickCount: DWord; external 'GetTickCount@kernel32 stdcall';
function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: LongWord): LongWord; external 'SetTimer@User32.dll stdcall';
function KillTimer(hWnd, nIDEvent: LongWord): LongWord; external 'KillTimer@User32.dll stdcall';
var
ProgressBar: TNewProgressBar;
Timer: LongWord;
Done: Boolean;
InitialTime: DWord;
procedure Install;
var
ErrorCode: Integer;
begin
if ShellExec('Open', 'Timeout.exe', '/T ' + IntToStr(10000 div 1000), '', SW_HIDE, ewWaitUntilTerminated, ErrorCode) then
begin
Done:=True;
end;
end;
procedure UpdateProgressBar(HandleW, msg, idEvent, TimeSys: LongWord);
begin
if Done then
begin
KillTimer(0, Timer);
ProgressBar.Position:=ProgressBar.Max;
end
else
begin
ProgressBar.Position:=GetTickCount - InitialTime;
end;
end;
procedure InitializeWizard;
begin
WizardForm.OuterNotebook.SetBounds(ScaleX(0), ScaleY(0), ScaleX(0), ScaleY(0));
ProgressBar:=TNewProgressBar.Create(WizardForm);
ProgressBar.Parent:=WizardForm;
ProgressBar.SetBounds(ScaleX(-1), ScaleY(250), ScaleX(500), ScaleY(30));
ProgressBar.Max:=10000;
SetWindowLong(ProgressBar.Handle, -20, GetWindowLong(ProgressBar.Handle, -20) or $2000000);
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID=wpInstalling then
begin
Timer:=SetTimer(0, 0, 50, CreateCallback(@UpdateProgressBar));
InitialTime:=GetTickCount;
Install;
end
end;Код: Выделить всё
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
Wait:=2000;
Step:=5;
ProgressPage:=CreateOutputProgressPage(WizardForm.PageNameLabel.Caption, WizardForm.PageDescriptionLabel.Caption);
ProgressPage.SetProgress(0, Wait);
ProgressPage.Show;
try
for I := 0 to Wait div Step do
begin
ProgressPage.SetProgress(I * Step, Wait);
Sleep(Step);
end;
finally
ProgressPage.Hide;
ProgressPage.Free;
end;
end;
end;