Suppose that I'm using the example CodeDownloadFiles.iss and I would like to notice to the user the Status of Download writing the number of progress file download "N of Y file".
I thought to retrieve the Total Number of selected Components but how can change the label "Downloading additional files..."? I tried the following command but it is not supported by the class:
TDownloadWizardPage.DownloadingLabel := 'Downloading additional files... file 1 of 3, please wait...'
This is the function, as you can see I didn't write how to retrieve the Total Number of selected components; I'll appreciate getting a suggestion also for this task to retrieve it programmatically... maybe creating a New Function that checks any components? :
function NextButtonClick(CurPageID: Integer): Boolean;
begin
//Download Components
if CurPageID = wpReady then begin
DownloadPage.Clear;
if WizardIsComponentSelected('Database\ABC') then begin
TDownloadWizardPage.DownloadingLabel := 'Downloading additional files... file 1 of 3, please wait...'
DownloadPage.Add('https://example.com/MyDB1.sqlite', 'MyDB1.sqlite', '');
end;
if WizardIsComponentSelected('Database\DEF') then begin
TDownloadWizardPage.DownloadingLabel := 'Downloading additional files... file 2 of 3, please wait...'
DownloadPage.Add('https://example.com/MyDB2.sqlite', 'MyDB2.sqlite', '');;
end;
if WizardIsComponentSelected('Database\GHI') then begin
TDownloadWizardPage.DownloadingLabel := 'Downloading additional files... file 3 of 3, please wait...'
DownloadPage.Add('https://example.com/MyDB3.sqlite', 'MyDB3.sqlite', '');;
end;
DownloadPage.Show;
try
try
DownloadPage.Download;
Result := True;
except
SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
Result := False;
end;
finally
DownloadPage.Hide;
end;
end else
Result := True;
end;
How can I solve this problem? And how could I count the total number of selected components?
Thank you for any suggestions!
DownloadPage.Msg1Label.Caption, not TDownloadWizardPage.DownloadingLabelDownloadPage.Add does not download the file, so you cannot update the label on its call. It's DownloadPage.Download that downloads the files.What you can do:
Count the total number files to download by increasing a counter everytime you call DownloadPage.Add.
Global variables:
var
DownloadCount: Integer;
DownloadFile: Integer;
PreviousDownload: string;
After
DownloadPage.Clear;
add
DownloadCount := 0;
DownloadFile := 0;
PreviousDownload := '';
At each DownloadPage.Add do:
DownloadPage.Add(...);
Inc(DownloadCount);
Use TOnDownloadProgress to monitor the download process. On each change of Url, update the label.
Assuming your InitializeWizard (or other) creates the download page with TOnDownloadProgress handler like this:
procedure InitializeWizard;
begin
DownloadPage :=
CreateDownloadPage(
SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc),
@OnDownloadProgress);
end;
update your OnDownloadProgress handler (or any other) to do:
function OnDownloadProgress(
const Url, FileName: String; const Progress, ProgressMax: Int64): Boolean;
begin
if Url <> PreviousDownload then
begin
Inc(DownloadFile);
PreviousDownload := Url;
DownloadPage.Msg1Label.Caption :=
Format('Downloading additional files... file %d of %d, please wait...', [
DownloadFile, DownloadCount]);
end;
Result := True;
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With