var
ProgressLabel: TLabel;
procedure ExtLog();
begin
with WizardForm.ProgressGauge do begin
ProgressLabel.Caption:=IntToStr((Position-Min)/((Max - Min)/100)) + '%'
if (Position-Min)/((Max - Min)/100) > 50 then ProgressLabel.Font.Color:= clWhite
end
end;
procedure Progress;
begin
ProgressLabel:=TLabel.Create(WizardForm)
ProgressLabel.Top:= 4
ProgressLabel.Left:= 200
ProgressLabel.Caption:= '0%'
ProgressLabel.AutoSize:= True
ProgressLabel.Font.Color:= clBlue
ProgressLabel.Font.Style:= [fsBold]
ProgressLabel.Transparent:= True
ProgressLabel.Parent:= WizardForm.ProgressGauge
end;
var
TotalSpaceLabel, FreeSpaceLabel, InstallSpaceLabel: TLabel;
FreeMB, TotalMB: Cardinal;
Function NumToStr(Float: Extended): String;
Begin
Result:= Format('%.2n', [Float]); StringChange(Result, ',', '.');
while ((Result[Length(Result)] = '0') or (Result[Length(Result)] = '.')) and (Pos('.', Result) > 0) do
SetLength(Result, Length(Result)-1);
End;
Function MbOrTb(Byte: Extended): String;
begin
if Byte < 1024 then Result:= NumToStr(Byte) + ' Mb' else
if Byte/1024 < 1024 then Result:= NumToStr(round(Byte/1024*100)/100) + ' Gb' else
Result:= NumToStr(round((Byte/(1024*1024))*100)/100) + ' Tb'
end;
procedure DirEditOnChange(Sender: TObject);
var Drive: String;
begin
Drive:= ExtractFileDrive(WizardForm.DirEdit.Text);
GetSpaceOnDisk(Drive, True, FreeMB, TotalMB);
TotalSpaceLabel.Caption:= ExpandConstant('{cm:TotalSpaceLabel} ')+MbOrTb(TotalMB);
FreeSpaceLabel.Caption:= ExpandConstant('{cm:FreeSpaceLabel} ')+MbOrTb(FreeMB)+' ('+IntToStr(round(FreeMB*100/TotalMB))+'%)';
InstallSpacelabel.Caption:= ExpandConstant('{cm:InstallSpacelabel} ')+MbOrTb({#NeedInstallSize});
if (FreeMB<{#NeedInstallSize}) then
InstallSpacelabel.Font.Color:=clRed
else
InstallSpacelabel.Font.Color:=InstallSpacelabel.Font.Color;
WizardForm.NextButton.Enabled:= (FreeMB>{#NeedInstallSize})
end;
procedure TotalSpace;
begin
Progress;
TotalSpaceLabel:= TLabel.Create(WizardForm);
TotalSpaceLabel.AutoSize:= False;
TotalSpaceLabel.SetBounds(0, 140, 300, 20);
TotalSpaceLabel.Parent:= WizardForm.SelectDirpage;
FreeSpaceLabel:= TLabel.Create(WizardForm);
FreeSpaceLabel.AutoSize:= False;
FreeSpaceLabel.SetBounds(0, 160, 300, 20);
FreeSpaceLabel.Parent:= WizardForm.SelectDirpage;
InstallSpacelabel:= TLabel.Create(WizardForm);
InstallSpacelabel.AutoSize:= False;
InstallSpacelabel.SetBounds(0, 180, 300, 20);
InstallSpacelabel.Parent:= WizardForm.SelectDirpage;
WizardForm.DirEdit.OnChange:=@DirEditOnChange;
end;
function GetTickCount: DWORD;
external 'GetTickCount@kernel32.dll stdcall';
var
StartTick: DWORD;
PercentLabel: TNewStaticText;
ElapsedLabel: TNewStaticText;
RemainingLabel: TNewStaticText;
function TicksToStr(Value: DWORD): string;
var
I: DWORD;
Hours, Minutes, Seconds: Integer;
begin
I := Value div 1000;
Seconds := I mod 60;
I := I div 60;
Minutes := I mod 60;
I := I div 60;
Hours := I mod 24;
Result := Format('%.2d:%.2d:%.2d', [Hours, Minutes, Seconds]);
end;
procedure InitializeWizard;
begin
TotalSpace;
PercentLabel := TNewStaticText.Create(WizardForm);
PercentLabel.Parent := WizardForm.ProgressGauge.Parent;
PercentLabel.Left := 0;
PercentLabel.Top := WizardForm.ProgressGauge.Top +
WizardForm.ProgressGauge.Height + 12;
ElapsedLabel := TNewStaticText.Create(WizardForm);
ElapsedLabel.Parent := WizardForm.ProgressGauge.Parent;
ElapsedLabel.Left := 0;
ElapsedLabel.Top := PercentLabel.Top + PercentLabel.Height + 4;
RemainingLabel := TNewStaticText.Create(WizardForm);
RemainingLabel.Parent := WizardForm.ProgressGauge.Parent;
RemainingLabel.Left := 0;
RemainingLabel.Top := ElapsedLabel.Top + ElapsedLabel.Height + 4;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID=wpSelectDir then begin
DirEditOnChange(nil)
if CurPageID = wpInstalling then
StartTick := GetTickCount;
end;
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
if CurPageID = wpInstalling then
begin
Cancel := False;
if ExitSetupMsgBox then
begin
Cancel := True;
Confirm := False;
PercentLabel.Visible := False;
ElapsedLabel.Visible := False;
RemainingLabel.Visible := False;
end;
end;
end;
procedure CurInstallProgressChanged(CurProgress, MaxProgress: Integer);
var
CurTick: DWORD;
begin
CurTick := GetTickCount;
PercentLabel.Caption :=Format(ExpandConstant('{cm:Percent} ') + '%.2f %%' , [(CurProgress * 100.0) / MaxProgress]);
ElapsedLabel.Caption :=Format(ExpandConstant('{cm:Elapsed} ') + '%s', [TicksToStr(CurTick - StartTick)]);
if CurProgress > 0 then
begin
RemainingLabel.Caption :=Format(ExpandConstant('{cm:Remaining} ') + '%s', [TicksToStr(((CurTick - StartTick) / CurProgress) * (MaxProgress - CurProgress))]);
end;
end;
[/SPOILER]