Răsfoiți Sursa

Add SuppressibleTaskDialogMsgBox.

Martijn Laan 6 ani în urmă
părinte
comite
9aa9f0ad30
5 a modificat fișierele cu 36 adăugiri și 40 ștergeri
  1. 1 1
      ISHelp/isxfunc.xml
  2. 5 9
      Projects/ScriptFunc.pas
  3. 0 1
      Projects/ScriptFunc_C.pas
  4. 29 28
      Projects/ScriptFunc_R.pas
  5. 1 1
      whatsnew.htm

+ 1 - 1
ISHelp/isxfunc.xml

@@ -2398,7 +2398,7 @@ end;</pre></example>
       </function>
       </function>
       <function>
       <function>
         <name>SuppressibleTaskDialogMsgBox</name>
         <name>SuppressibleTaskDialogMsgBox</name>
-        <prototype>function SuppressibleTaskDialogMsgBox(const Instruction, TaskDialogText, MsgBoxText: String; const Typ: TMsgBoxType; const Buttons: Cardinal; const ButtonLabels: TArrayOfString; const ShieldButton: Integer; const ForceMsgBox: Boolean; const Default: Integer): Integer;): Integer;</prototype>
+        <prototype>function SuppressibleTaskDialogMsgBox(const Instruction, TaskDialogText, MsgBoxText: String; const Typ: TMsgBoxType; const Buttons: Cardinal; const ButtonLabels: TArrayOfString; const ShieldButton: Integer; const ForceMsgBox: Boolean; const Default: Integer): Integer;</prototype>
         <description><p>Displays a suppressible task dialog. If message boxes are being suppressed (see <link topic="setupcmdline" window="main">Setup Command Line Parameters</link>), <tt>Default</tt> is returned. Otherwise, SuppressibleTaskDialogMsgBox acts the same as the regular <link topic="isxfunc_TaskDialogMsgBox">TaskDialogMsgBox</link>.</p></description>
         <description><p>Displays a suppressible task dialog. If message boxes are being suppressed (see <link topic="setupcmdline" window="main">Setup Command Line Parameters</link>), <tt>Default</tt> is returned. Otherwise, SuppressibleTaskDialogMsgBox acts the same as the regular <link topic="isxfunc_TaskDialogMsgBox">TaskDialogMsgBox</link>.</p></description>
       </function>
       </function>
       <function>
       <function>

+ 5 - 9
Projects/ScriptFunc.pas

@@ -47,9 +47,8 @@ const
   );
   );
 
 
   { CmnFunc }
   { CmnFunc }
-  CmnFuncTable: array [0..1] of AnsiString =
+  CmnFuncTable: array [0..0] of AnsiString =
   (
   (
-    'function MsgBox(const Text: String; const Typ: TMsgBoxType; const Buttons: Integer): Integer;',
     'function MinimizePathName(const Filename: String; const Font: TFont; MaxLen: Integer): String;'
     'function MinimizePathName(const Filename: String; const Font: TFont; MaxLen: Integer): String;'
   );
   );
 
 
@@ -181,7 +180,7 @@ const
   );
   );
 
 
   { Main }
   { Main }
-  MainTable: array [0..23] of AnsiString =
+  MainTable: array [0..26] of AnsiString =
   (
   (
     'function WizardForm: TWizardForm;',
     'function WizardForm: TWizardForm;',
     'function MainForm: TMainForm;',
     'function MainForm: TMainForm;',
@@ -196,7 +195,10 @@ const
     'function GetWindowsVersion: Cardinal;',
     'function GetWindowsVersion: Cardinal;',
     'procedure GetWindowsVersionEx(var Version: TWindowsVersion);',
     'procedure GetWindowsVersionEx(var Version: TWindowsVersion);',
     'function GetWindowsVersionString: String;',
     'function GetWindowsVersionString: String;',
+    'function MsgBox(const Text: String; const Typ: TMsgBoxType; const Buttons: Integer): Integer;',
     'function SuppressibleMsgBox(const Text: String; const Typ: TMsgBoxType; const Buttons, Default: Integer): Integer;',
     'function SuppressibleMsgBox(const Text: String; const Typ: TMsgBoxType; const Buttons, Default: Integer): Integer;',
+    'function TaskDialogMsgBox(const Instruction, TaskDialogText, MsgBoxText: String; const Typ: TMsgBoxType; const Buttons: Cardinal; const ButtonLabels: TArrayOfString; const ShieldButton: Integer; const ForceMsgBox: Boolean): Integer;',
+    'function SuppressibleTaskDialogMsgBox(const Instruction, TaskDialogText, MsgBoxText: String; const Typ: TMsgBoxType; const Buttons: Cardinal; const ButtonLabels: TArrayOfString; const ShieldButton: Integer; const ForceMsgBox: Boolean;'+'const Default: Integer): Integer;',
     'function IsWin64: Boolean;',
     'function IsWin64: Boolean;',
     'function Is64BitInstallMode: Boolean;',
     'function Is64BitInstallMode: Boolean;',
     'function ProcessorArchitecture: TSetupProcessorArchitecture;',
     'function ProcessorArchitecture: TSetupProcessorArchitecture;',
@@ -304,12 +306,6 @@ const
     'procedure Log(const S: String);'
     'procedure Log(const S: String);'
   );
   );
 
 
-  { TaskDialog }
-  TaskDialogTable: array [0..0] of AnsiString =
-  (
-    'function TaskDialogMsgBox(const Instruction, TaskDialogText, MsgBoxText: String; const Typ: TMsgBoxType; const Buttons: Cardinal; const ButtonLabels: TArrayOfString; const ShieldButton: Integer; const ForceMsgBox: Boolean): Integer;'
-  );
-
   { Other }
   { Other }
   OtherTable: array [0..27] of AnsiString =
   OtherTable: array [0..27] of AnsiString =
   (
   (

+ 0 - 1
Projects/ScriptFunc_C.pas

@@ -157,7 +157,6 @@ begin
   RegisterFunctionTable(WindowsTable);
   RegisterFunctionTable(WindowsTable);
   RegisterFunctionTable(Ole2Table);
   RegisterFunctionTable(Ole2Table);
   RegisterFunctionTable(LoggingTable);
   RegisterFunctionTable(LoggingTable);
-  RegisterFunctionTable(TaskDialogTable);
   RegisterFunctionTable(OtherTable);
   RegisterFunctionTable(OtherTable);
 
 
   RegisterConst('MaxInt', MaxInt);
   RegisterConst('MaxInt', MaxInt);

+ 29 - 28
Projects/ScriptFunc_R.pas

@@ -360,9 +360,7 @@ begin
   PStart := Stack.Count-1;
   PStart := Stack.Count-1;
   Result := True;
   Result := True;
 
 
-  if Proc.Name = 'MSGBOX' then begin
-    Stack.SetInt(PStart, LoggedMsgBox(Stack.GetString(PStart-1), GetMsgBoxCaption, TMsgBoxType(Stack.GetInt(PStart-2)), Stack.GetInt(PStart-3), False, 0));
-  end else if Proc.Name = 'MINIMIZEPATHNAME' then begin
+  if Proc.Name = 'MINIMIZEPATHNAME' then begin
     Stack.SetString(PStart, MinimizePathName(Stack.GetString(PStart-1), TFont(Stack.GetClass(PStart-2)), Stack.GetInt(PStart-3)));
     Stack.SetString(PStart, MinimizePathName(Stack.GetString(PStart-1), TFont(Stack.GetClass(PStart-2)), Stack.GetInt(PStart-3)));
   end else
   end else
     Result := False;
     Result := False;
@@ -967,6 +965,11 @@ var
   MinVersion, OnlyBelowVersion: TSetupVersionData;
   MinVersion, OnlyBelowVersion: TSetupVersionData;
   WizardComponents, WizardTasks: TStringList;
   WizardComponents, WizardTasks: TStringList;
   S: String;
   S: String;
+  Suppressible: Boolean;
+  Default: Integer;
+  Arr: TPSVariantIFC;
+  N, I: Integer;
+  ButtonLabels: array of String;
 begin
 begin
   PStart := Stack.Count-1;
   PStart := Stack.Count-1;
   Result := True;
   Result := True;
@@ -1021,8 +1024,29 @@ begin
   end else if Proc.Name = 'GETWINDOWSVERSIONSTRING' then begin
   end else if Proc.Name = 'GETWINDOWSVERSIONSTRING' then begin
     Stack.SetString(PStart, Format('%u.%.2u.%u', [WindowsVersion shr 24,
     Stack.SetString(PStart, Format('%u.%.2u.%u', [WindowsVersion shr 24,
       (WindowsVersion shr 16) and $FF, WindowsVersion and $FFFF]));
       (WindowsVersion shr 16) and $FF, WindowsVersion and $FFFF]));
-  end else if Proc.Name = 'SUPPRESSIBLEMSGBOX' then begin
-    Stack.SetInt(PStart, LoggedMsgBox(Stack.GetString(PStart-1), GetMsgBoxCaption, TMsgBoxType(Stack.GetInt(PStart-2)), Stack.GetInt(PStart-3), True, Stack.GetInt(PStart-4)));
+  end else if (Proc.Name = 'MSGBOX') or (Proc.Name = 'SUPPRESSIBLEMSGBOX') then begin
+    if Proc.Name = 'MSGBOX' then begin
+      Suppressible := False;
+      Default := 0;
+    end else begin
+      Suppressible := True;
+      Default := Stack.GetInt(PStart-4);
+    end;
+    Stack.SetInt(PStart, LoggedMsgBox(Stack.GetString(PStart-1), GetMsgBoxCaption, TMsgBoxType(Stack.GetInt(PStart-2)), Stack.GetInt(PStart-3), Suppressible, Default));
+  end else if (Proc.Name = 'TASKDIALOGMSGBOX') or (Proc.Name = 'SUPPRESSIBLETASKDIALOGMSGBOX') then begin
+    if Proc.Name = 'TASKDIALOGMSGBOX' then begin
+      Suppressible := False;
+      Default := 0;
+    end else begin
+      Suppressible := True;
+      Default := Stack.GetInt(PStart-9);
+    end;
+    Arr := NewTPSVariantIFC(Stack[PStart-6], True);
+    N := PSDynArrayGetLength(Pointer(Arr.Dta^), Arr.aType);
+    SetLength(ButtonLabels, N);
+    for I := 0 to N-1 do
+      ButtonLabels[I] := VNGetString(PSGetArrayField(Arr, I));
+    Stack.SetInt(PStart, LoggedTaskDialogMsgBox('', Stack.GetString(PStart-1), Stack.GetString(PStart-2), Stack.GetString(PStart-3), GetMsgBoxCaption, TMsgBoxType(Stack.GetInt(PStart-4)), Stack.GetInt(PStart-5), ButtonLabels, Stack.GetInt(PStart-7), Stack.GetBool(PStart-8), Suppressible, Default));
   end else if Proc.Name = 'ISWIN64' then begin
   end else if Proc.Name = 'ISWIN64' then begin
     Stack.SetBool(PStart, IsWin64);
     Stack.SetBool(PStart, IsWin64);
   end else if Proc.Name = 'IS64BITINSTALLMODE' then begin
   end else if Proc.Name = 'IS64BITINSTALLMODE' then begin
@@ -1518,28 +1542,6 @@ begin
     Result := False;
     Result := False;
 end;
 end;
 
 
-{ TaskDialog }
-function TaskDialogProc(Caller: TPSExec; Proc: TPSExternalProcRec; Global, Stack: TPSStack): Boolean;
-var
-  PStart: Cardinal;
-  Arr: TPSVariantIFC;
-  N, I: Integer;
-  ButtonLabels: array of String;
-begin
-  PStart := Stack.Count-1;
-  Result := True;
-
-  if Proc.Name = 'TASKDIALOGMSGBOX' then begin
-    Arr := NewTPSVariantIFC(Stack[PStart-6], True);
-    N := PSDynArrayGetLength(Pointer(Arr.Dta^), Arr.aType);
-    SetLength(ButtonLabels, N);
-    for I := 0 to N-1 do
-      ButtonLabels[I] := VNGetString(PSGetArrayField(Arr, I));
-    Stack.SetInt(PStart, LoggedTaskDialogMsgBox('', Stack.GetString(PStart-1), Stack.GetString(PStart-2), Stack.GetString(PStart-3), GetMsgBoxCaption, TMsgBoxType(Stack.GetInt(PStart-4)), Stack.GetInt(PStart-5), ButtonLabels, Stack.GetInt(PStart-7), Stack.GetBool(PStart-8), False, 0));
-  end else
-    Result := False;
-end;
-
 { Other }
 { Other }
 function OtherProc(Caller: TPSExec; Proc: TPSExternalProcRec; Global, Stack: TPSStack): Boolean;
 function OtherProc(Caller: TPSExec; Proc: TPSExternalProcRec; Global, Stack: TPSStack): Boolean;
 
 
@@ -1869,7 +1871,6 @@ begin
   RegisterFunctionTable(WindowsTable, @WindowsProc);
   RegisterFunctionTable(WindowsTable, @WindowsProc);
   RegisterFunctionTable(Ole2Table, @Ole2Proc);
   RegisterFunctionTable(Ole2Table, @Ole2Proc);
   RegisterFunctionTable(LoggingTable, @LoggingProc);
   RegisterFunctionTable(LoggingTable, @LoggingProc);
-  RegisterFunctionTable(TaskDialogTable, @TaskDialogProc);
   RegisterFunctionTable(OtherTable, @OtherProc);
   RegisterFunctionTable(OtherTable, @OtherProc);
 
 
   ScriptInterpreter.RegisterDelphiFunction(@_FindFirst, 'FindFirst', cdRegister);
   ScriptInterpreter.RegisterDelphiFunction(@_FindFirst, 'FindFirst', cdRegister);

+ 1 - 1
whatsnew.htm

@@ -83,7 +83,7 @@ For conditions of distribution and use, see <a href="http://www.jrsoftware.org/f
 <li>Pascal Scripting changes:
 <li>Pascal Scripting changes:
 <ul>
 <ul>
   <li>Using event attributes it is now possible to have multiple implementations of the same event function in your script. This is especially useful in included scripts implementing an event function to avoid conflicts with the main script. See the help file for more information and the <i>CodeExample1.iss</i> example script for an example.</li>
   <li>Using event attributes it is now possible to have multiple implementations of the same event function in your script. This is especially useful in included scripts implementing an event function to avoid conflicts with the main script. See the help file for more information and the <i>CodeExample1.iss</i> example script for an example.</li>
-  <li>Added new <tt>TaskDialogMsgBox</tt> support function which displays a task dialog if supported by the system and a regular message box otherwise (<a href="https://i.imgur.com/hU4RQP2.png">example</a>). See the help file for more information and the <i>CodeClasses.iss</i> example script for an example.</li>
+  <li>Added new <tt>TaskDialogMsgBox</tt> and <tt>SuppressibleTaskDialogMsgBox</tt> support functions which display a task dialog if supported by the system and a regular message box otherwise (<a href="https://i.imgur.com/hU4RQP2.png">example</a>). See the help file for more information and the <i>CodeClasses.iss</i> example script for an example.</li>
   <li>[Setup] section directives <tt>ChangesAssociations</tt> and <tt>ChangesEnvironment</tt> may now be set to a boolean expression, which may contain calls to check functions.</li>
   <li>[Setup] section directives <tt>ChangesAssociations</tt> and <tt>ChangesEnvironment</tt> may now be set to a boolean expression, which may contain calls to check functions.</li>
   <li>Added new special-purpose <i>HelpTextNote</i> message that can be used to specify one or more lines of text that are added to the list of parameters in the summary shown when passing /HELP on the command line. This message defaults to an empty string so make sure to provide a non-empty default for all languages from your main script if you want to use it.</li>
   <li>Added new special-purpose <i>HelpTextNote</i> message that can be used to specify one or more lines of text that are added to the list of parameters in the summary shown when passing /HELP on the command line. This message defaults to an empty string so make sure to provide a non-empty default for all languages from your main script if you want to use it.</li>
   <li>Added new <tt>SameStr</tt> and <tt>SameText</tt> support functions.</li>
   <li>Added new <tt>SameStr</tt> and <tt>SameText</tt> support functions.</li>