浏览代码

Removed the length limitation when entering a Sign Tool command and increased control height.

Martijn Laan 1 年之前
父节点
当前提交
d7c70d64e9

+ 1 - 0
Projects/Compil32.dpr

@@ -32,6 +32,7 @@ uses
   BrowseFunc in '..\Components\BrowseFunc.pas',
   IDE.SignToolsForm in 'Src\IDE.SignToolsForm.pas' {SignToolsForm},
   IDE.InputQueryComboForm in 'Src\IDE.InputQueryComboForm.pas',
+  IDE.InputQueryMemoForm in 'Src\IDE.InputQueryMemoForm.pas',
   ScintInt in '..\Components\ScintInt.pas',
   ScintEdit in '..\Components\ScintEdit.pas',
   IDE.ScintStylerInnoSetup in 'Src\IDE.ScintStylerInnoSetup.pas',

+ 1 - 0
Projects/Compil32.dproj

@@ -106,6 +106,7 @@
             <Form>SignToolsForm</Form>
         </DCCReference>
         <DCCReference Include="Src\IDE.InputQueryComboForm.pas"/>
+        <DCCReference Include="Src\IDE.InputQueryMemoForm.pas"/>
         <DCCReference Include="..\Components\ScintInt.pas"/>
         <DCCReference Include="..\Components\ScintEdit.pas"/>
         <DCCReference Include="Src\IDE.ScintStylerInnoSetup.pas"/>

+ 3 - 6
Projects/Src/IDE.InputQueryComboForm.dfm

@@ -12,22 +12,19 @@ object InputQueryComboForm: TInputQueryComboForm
   Font.Height = -11
   Font.Name = 'MS Sans Serif'
   Font.Style = []
-  OldCreateOrder = True
   Position = poScreenCenter
   OnCreate = FormCreate
   DesignSize = (
     582
     73)
-  PixelsPerInch = 96
   TextHeight = 13
   object PromptLabel: TLabel
     Left = 8
     Top = 11
-    Width = 265
+    Width = 9
     Height = 13
-    AutoSize = False
     Caption = '...'
-    FocusControl = ValueComboBox
+    FocusControl = ValueControl
   end
   object OKButton: TButton
     Left = 421
@@ -51,7 +48,7 @@ object InputQueryComboForm: TInputQueryComboForm
     ModalResult = 2
     TabOrder = 2
   end
-  object ValueComboBox: TComboBox
+  object ValueControl: TComboBox
     Left = 279
     Top = 8
     Width = 295

+ 9 - 4
Projects/Src/IDE.InputQueryComboForm.pas

@@ -7,6 +7,8 @@ unit IDE.InputQueryComboForm;
   For conditions of distribution and use, see LICENSE.TXT.
 
   InputQuery with a TComboBox instead of a TEdit
+
+  Unlike InputQuery it doesn't limit the value to 255 characters
 }
 
 interface
@@ -19,7 +21,7 @@ type
     OKButton: TButton;
     CancelButton: TButton;
     PromptLabel: TLabel;
-    ValueComboBox: TComboBox;
+    ValueControl: TComboBox;
     procedure FormCreate(Sender: TObject);
   private
     function GetValue: String;
@@ -65,22 +67,25 @@ end;
 
 function TInputQueryComboForm.GetValue: String;
 begin
-  Result := ValueComboBox.Text;
+  Result := ValueControl.Text;
 end;
 
 procedure TInputQueryComboForm.SetPrompt(const APrompt: String);
 begin
   PromptLabel.Caption := APrompt;
+  var MoveX := PromptLabel.Left + PromptLabel.Width + CancelButton.Left - (OkButton.Left + OkButton.Width) - ValueControl.Left;
+  ValueControl.Left := ValueControl.Left + MoveX;
+  ValueControl.Width := ValueControl.Width - MoveX;
 end;
 
 procedure TInputQueryComboForm.SetValue(const AValue: String);
 begin
-  ValueComboBox.Text := AValue;
+  ValueControl.Text := AValue;
 end;
 
 procedure TInputQueryComboForm.SetValues(const AValues: TStringList);
 begin
-  ValueComboBox.Items := AValues;
+  ValueControl.Items := AValues;
 end;
 
 end.

+ 62 - 0
Projects/Src/IDE.InputQueryMemoForm.dfm

@@ -0,0 +1,62 @@
+object InputQueryMemoForm: TInputQueryMemoForm
+  Left = 330
+  Top = 188
+  BorderIcons = [biSystemMenu]
+  BorderStyle = bsDialog
+  Caption = '...'
+  ClientHeight = 141
+  ClientWidth = 582
+  Color = clBtnFace
+  Font.Charset = DEFAULT_CHARSET
+  Font.Color = clWindowText
+  Font.Height = -11
+  Font.Name = 'MS Sans Serif'
+  Font.Style = []
+  Position = poScreenCenter
+  OnCreate = FormCreate
+  DesignSize = (
+    582
+    141)
+  TextHeight = 13
+  object PromptLabel: TLabel
+    Left = 8
+    Top = 11
+    Width = 9
+    Height = 13
+    Caption = '...'
+    FocusControl = ValueControl
+  end
+  object OKButton: TButton
+    Left = 421
+    Top = 111
+    Width = 73
+    Height = 23
+    Anchors = [akRight, akBottom]
+    Caption = 'OK'
+    Default = True
+    ModalResult = 1
+    TabOrder = 1
+  end
+  object CancelButton: TButton
+    Left = 501
+    Top = 111
+    Width = 73
+    Height = 23
+    Anchors = [akRight, akBottom]
+    Cancel = True
+    Caption = 'Cancel'
+    ModalResult = 2
+    TabOrder = 2
+  end
+  object ValueControl: TMemo
+    Left = 279
+    Top = 8
+    Width = 295
+    Height = 89
+    Anchors = [akLeft, akTop, akRight]
+    TabOrder = 0
+    OnChange = ValueControlChange
+    OnKeyDown = ValueControlKeyDown
+    OnKeyPress = ValueControlKeyPress
+  end
+end

+ 120 - 0
Projects/Src/IDE.InputQueryMemoForm.pas

@@ -0,0 +1,120 @@
+unit IDE.InputQueryMemoForm;
+
+{
+  Inno Setup
+  Copyright (C) 1997-2020 Jordan Russell
+  Portions by Martijn Laan
+  For conditions of distribution and use, see LICENSE.TXT.
+
+  InputQuery with a TMemo instead of a TEdit
+
+  Unlike InputQuery it doesn't limit the value to 255 characters
+}
+
+interface
+
+uses
+  Classes, Controls, StdCtrls, UIStateForm;
+
+type
+  TInputQueryMemoForm = class(TUIStateForm)
+    OKButton: TButton;
+    CancelButton: TButton;
+    PromptLabel: TLabel;
+    ValueControl: TMemo;
+    procedure FormCreate(Sender: TObject);
+    procedure ValueControlKeyPress(Sender: TObject; var Key: Char);
+    procedure ValueControlChange(Sender: TObject);
+    procedure ValueControlKeyDown(Sender: TObject; var Key: Word;
+      Shift: TShiftState);
+  private
+    FSingleLine: Boolean;
+    function GetValue: String;
+    procedure SetPrompt(const APrompt: String);
+    procedure SetValue(const AValue: String);
+  public
+    property SingleLine: Boolean write FSingleLine;
+    property Prompt: String write SetPrompt;
+    property Value: String read GetValue write SetValue;
+  end;
+
+function InputQueryMemo(const ACaption, APrompt: String; var AValue: String;
+  const ASingleLine: Boolean = False): Boolean;
+
+implementation
+
+uses
+  Windows, Messages, IDE.HelperFunc, Forms;
+
+{$R *.DFM}
+
+function InputQueryMemo(const ACaption, APrompt: String; var AValue: String;
+  const ASingleLine: Boolean): Boolean;
+begin
+  with TInputQueryMemoForm.Create(Application) do try
+    Caption := ACaption;
+    Prompt := APrompt;
+    Value := AValue;
+    SingleLine := ASingleLine;
+    if ShowModal = mrOk then begin
+      AValue := Value;
+      Result := True;
+    end else
+      Result := False;
+  finally
+    Free;
+  end;
+end;
+
+procedure TInputQueryMemoForm.FormCreate(Sender: TObject);
+begin
+  InitFormFont(Self);
+end;
+
+function TInputQueryMemoForm.GetValue: String;
+begin
+  Result := ValueControl.Text;
+end;
+
+procedure TInputQueryMemoForm.SetPrompt(const APrompt: String);
+begin
+  PromptLabel.Caption := APrompt;
+  var MoveX := PromptLabel.Left + PromptLabel.Width + CancelButton.Left - (OkButton.Left + OkButton.Width) - ValueControl.Left;
+  ValueControl.Left := ValueControl.Left + MoveX;
+  ValueControl.Width := ValueControl.Width - MoveX;
+end;
+
+procedure TInputQueryMemoForm.SetValue(const AValue: String);
+begin
+  ValueControl.Text := AValue;
+  ValueControl.SelectAll;
+end;
+
+procedure TInputQueryMemoForm.ValueControlChange(Sender: TObject);
+begin
+  { We don't allow Enter to be added but it could still be pasted so must check.
+    Checking with Lines.Count doesn't work, for example if one pastes 3 lines and
+    then removes two it still returns 3 for Lines.Count. }
+  if FSingleLine then begin
+    var Text := ValueControl.Text;
+    OKButton.Enabled := Pos(#10, Text) = 0;
+  end else
+    OKButton.Enabled := True;
+end;
+
+procedure TInputQueryMemoForm.ValueControlKeyDown(Sender: TObject;
+  var Key: Word; Shift: TShiftState);
+begin
+   if Key = VK_ESCAPE then
+    CancelButton.Click;
+end;
+
+procedure TInputQueryMemoForm.ValueControlKeyPress(Sender: TObject;
+  var Key: Char);
+begin
+  { #10 = Ctrl+Enter, #13 = Enter or Shift+Enter }
+  if FSingleLine and ((Key = #10) or (Key = #13)) then
+    Key := #0;
+end;
+
+end.

+ 0 - 2
Projects/Src/IDE.SignToolsForm.dfm

@@ -11,14 +11,12 @@ object SignToolsForm: TSignToolsForm
   Font.Height = -11
   Font.Name = 'MS Sans Serif'
   Font.Style = []
-  OldCreateOrder = True
   Position = poScreenCenter
   OnCreate = FormCreate
   OnDestroy = FormDestroy
   DesignSize = (
     577
     247)
-  PixelsPerInch = 96
   TextHeight = 13
   object GroupBox1: TGroupBox
     Left = 8

+ 3 - 2
Projects/Src/IDE.SignToolsForm.pas

@@ -46,7 +46,8 @@ type
 implementation
 
 uses
-  Windows, Messages, IDE.HelperFunc, Shared.CommonFunc.Vcl, Dialogs, SysUtils;
+  Windows, Messages, SysUtils, Dialogs,
+  Shared.CommonFunc.Vcl, IDE.InputQueryMemoForm, IDE.HelperFunc;
 
 {$R *.DFM}
 
@@ -117,7 +118,7 @@ begin
       end;
     end;
 
-    if InputQuery(Caption, 'Command of the Sign Tool:', SignToolCommand) then begin
+    if InputQueryMemo(Caption, 'Command of the Sign Tool:', SignToolCommand, True) then begin
       if SignToolCommand = '' then begin
         AppMessageBox(PChar('Invalid command.'), PChar(Caption), MB_OK or MB_ICONSTOP);
         Exit;

+ 1 - 0
whatsnew.htm

@@ -77,6 +77,7 @@ For conditions of distribution and use, see <a href="files/is/license.txt">LICEN
   <li>Moved the list of recently opened files into a new <i>Open Recent</i> submenu of the <i>Files</i> menu.</li>
   <li>Added shortcuts to select a tab (Ctrl+1 through Ctrl+9).</li>
   <li>Added shortcut to the <i>Options</i> menu item in the <i>Tools</i> menu (Ctrl+,).</li>
+  <li>Removed the length limitation when entering a Sign Tool command and increased control height.</li>
 </ul>
 <p><span class="head2">Other changes</span></p>
 <ul>