Prechádzať zdrojové kódy

Document CreateDownloadPage.

Martijn Laan 5 rokov pred
rodič
commit
2243c968ae
3 zmenil súbory, kde vykonal 26 pridanie a 2 odobranie
  1. 7 0
      ISHelp/isxclasses.pas
  2. 18 1
      ISHelp/isxfunc.xml
  3. 1 1
      whatsnew.htm

+ 7 - 0
ISHelp/isxclasses.pas

@@ -729,6 +729,13 @@ TOutputProgressWizardPage = class(TWizardPage)
   procedure Show;
 end;
 
+TDownloadWizardPage = class(TOutputProgressWizardPage)
+  property AbortButton: TNewButton; read;
+  procedure Add(const Url, BaseName, RequiredSHA256OfFile: String);
+  procedure Clear;
+  function Download: Int64;
+end;
+
 TUIStateForm = class(TForm)
 end;
 

+ 18 - 1
ISHelp/isxfunc.xml

@@ -1755,6 +1755,7 @@ end;</pre></example>
 <p><tt>TOnDownloadProgress = function(const Url, FileName: string; const Progress, ProgressMax: Int64): Boolean;</tt></p>
 <p>ProgressMax will be 0 if the file size is still unknown. Return True to allow the download to continue, False otherwise.</p></remarks>
         <seealso><p><link topic="isxfunc_DownloadTemporaryFileSize">DownloadTemporaryFileSize</link><br />
+<link topic="isxfunc_CreateDownloadPage">CreateDownloadPage</link><br />
 <link topic="isxfunc_ExtractTemporaryFile">ExtractTemporaryFile</link></p></seealso>
         <example><pre>
 [Code]
@@ -1778,7 +1779,7 @@ begin
     Result := False;
   end;
 end;</pre>
-<p>See <i>CodeDownloadFiles.iss</i> for another example.</p></example>
+<p>See <i>CodeDownloadFiles.iss</i> for another example which uses <link topic="isxfunc_CreateDownloadPage">CreateDownloadPage</link> instead.</p></example>
       </function>
       <function>
         <name>DownloadTemporaryFileSize</name>
@@ -2462,6 +2463,22 @@ Page := CreateOutputMsgMemoPage(wpWelcome,
         <example><p>See <i>CodeDlg.iss</i> and <i>AllPagesExample.iss</i> for examples.</p></example>
         <seealso><p><link topic="scriptclasses" anchor="TOutputProgressWizardPage">TOutputProgressWizardPage</link></p></seealso>
       </function>
+      <function>
+        <name>CreateDownloadPage</name>
+        <prototype>function CreateDownloadPage(const ACaption, ADescription: String; const OnDownloadProgress: TOnDownloadProgress): TDownloadWizardPage;</prototype>
+        <description><p>Creates a wizard page to download files and show progress.</p>
+<p>Set OnDownloadProgress to a function to be informed of progress, or <tt>nil</tt> otherwise.</p>    
+<p>Unlike the other types of wizard pages, progress pages are not displayed as part of the normal page sequence (note that there is no <tt>AfterID</tt> parameter). A progress page can only be displayed programmatically by calling its <tt>Show</tt> method.</p></description>
+        <remarks><p>Call the <tt>Show</tt> method to activate and show the page. When you're finished with it, call the <tt>Hide</tt> method to revert to the previous page.</p>
+<p>Always put the <tt>Hide</tt> call inside the <tt>finally</tt> part of a <tt>try..finally</tt> language construct, as demonstrated in <i>CodeDownloadFiles.iss</i>. Not calling <tt>Hide</tt> will result in the wizard being permanently stuck on the progress page.</p>
+<p>To add a new file to download, call the <tt>Add</tt> method. Always call the <tt>Clear</tt> method before adding the first file.</p>
+<p>To start the download, call the <tt>Download</tt> method. An exception will be raised if there was an error. Otherwise, <tt>Download</tt> returns the number of bytes downloaded.</p>
+<p>See <link topic="isxfunc_DownloadTemporaryFile">DownloadTemporaryFile</link> for other considerations and the definition of <tt>TOnDownloadProgress</tt>.</p></remarks>
+        <example><p>See <i>CodeDownloadFiles.iss</i> for an example.</p></example>
+        <seealso><p><link topic="scriptclasses" anchor="TDownloadWizardPage">TDownloadWizardPage</link><br />
+<link topic="isxfunc_DownloadTemporaryFile">DownloadTemporaryFile</link><br />
+<link topic="isxfunc_CreateOutputProgressPage">CreateOutputProgressPage</link></p></seealso>
+      </function>
       <function>
         <name>CreateCustomPage</name>
         <prototype>function CreateCustomPage(const AfterID: Integer; const ACaption, ADescription: String): TWizardPage;</prototype>

+ 1 - 1
whatsnew.htm

@@ -59,7 +59,7 @@ For conditions of distribution and use, see <a href="https://jrsoftware.org/file
     <li>Supports basic authentication.</li>
   </ul>
   </li>
-  <li>Added new <tt>CreateDownloadPage</tt> support function to easily <a href="https://i.imgur.com/ZLmiS3t.png">show the download progress</a> to the user. See the new <i><a href="https://jrsoftware.github.io/issrc/Examples/CodeDownloadFiles.iss">CodeDownloadFiles.iss</a></i> example script for an example.</li>
+  <li>Added new <tt>CreateDownloadPage</tt> support function to easily <a href="https://i.imgur.com/deliPb8.png">show the download progress</a> to the user. See the new <i><a href="https://jrsoftware.github.io/issrc/Examples/CodeDownloadFiles.iss">CodeDownloadFiles.iss</a></i> example script for an example.</li>
   <li>Added new <tt>DownloadTemporaryFileSize</tt> support function to get the size of a file without downloading it.</li>
   <li>Added new <tt>GetSHA256OfFile</tt>, <tt>GetSHA256OfString</tt>, and <tt>GetSHA256OfUnicodeString</tt> support functions to calculate SHA-256 hashes.</li>
   <li><b>Change in default behavior:</b> Setup no longer disables itself entirely while <tt>PrepareToInstall</tt> is running. Instead only the Cancel button is disabled.</li>