From 868daf94f29ce1ffdd799a68c07bb668cd373bcd Mon Sep 17 00:00:00 2001
From: HP\李良庭 <liliangting@lanpucloud.cn:1111>
Date: 星期二, 08 七月 2025 11:49:03 +0800
Subject: [PATCH] 提交分辨率自适应版本V3.1.0.1500

---
 src/uInput.pas |  133 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 133 insertions(+), 0 deletions(-)

diff --git a/src/uInput.pas b/src/uInput.pas
new file mode 100644
index 0000000..b0cd8ba
--- /dev/null
+++ b/src/uInput.pas
@@ -0,0 +1,133 @@
+unit uInput;
+
+interface
+
+uses
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, StdCtrls, Buttons, sBitBtn, sEdit, ShellAPI;
+
+type
+  TfrmInput = class(TForm)
+    edtInput: TsEdit;
+    edtReturn: TsBitBtn;
+    lbGrain: TLabel;
+    cbGrain: TComboBox;
+    procedure FormShow(Sender: TObject);
+    procedure FormClose(Sender: TObject; var Action: TCloseAction);
+    procedure edtReturnClick(Sender: TObject);
+    procedure cbGrainChange(Sender: TObject);
+  private
+    { Private declarations }
+  public
+    { Public declarations }
+    strParam : String;
+    thMode   : Integer;   //0-默认输入框,1-粮种大类选择框
+    procedure InsertStringAtCursor(EditControl: TsEdit; Str: string);
+    procedure DeleteCharsBeforeCursor(EditControl: TsEdit; Count: Integer=1);
+    procedure InitGrainRec();
+  end;
+
+var
+  frmInput: TfrmInput;
+
+implementation
+
+uses
+  uMain, global, uSaveData;
+
+{$R *.dfm}
+
+//------- 自定义功能函数 -------------------------------------------------------
+//从光标处插入字符
+procedure TfrmInput.InsertStringAtCursor(EditControl: TsEdit; Str: string);
+begin
+  // 保存当前光标位置
+  EditControl.SelStart := EditControl.SelStart;
+  EditControl.SelLength := 0; // 不选择任何文本,确保只插入而不替换
+  EditControl.SelText := Str; // 插入字符串
+end;
+
+//自定义函数:从光标处删除字符
+procedure TfrmInput.DeleteCharsBeforeCursor(EditControl: TsEdit; Count: Integer=1);
+var
+  CursorPos, NewStart: Integer;
+begin
+  CursorPos := EditControl.SelStart;
+  if CursorPos >= Count then
+  begin
+    NewStart := CursorPos - Count; // 计算新的选择起点
+    EditControl.SelStart := NewStart;
+    EditControl.SelLength := Count; // 选择Count个字符
+    EditControl.SelText := '';      // 删除选定的文本
+  end
+  else
+  begin
+    // 如果Count大于光标位置,则删除所有在光标之前的字符
+    EditControl.SelStart := 0;
+    EditControl.SelLength := CursorPos;
+    EditControl.SelText := '';
+  end;
+end;
+
+//------- 初始化 ---------------------------------------------------------------
+procedure TfrmInput.FormShow(Sender: TObject);
+begin
+  //设定输入框模式,0-默认输入框,1-粮种大类选择框
+  if thMode=0 then begin
+    self.Width := 510;
+    self.Height:= 120;
+    lbGrain.Visible := false;
+    cbGrain.Visible := false;
+  end
+  else begin
+    self.Width := 510;
+    self.Height:= 200;
+    lbGrain.Visible := true;
+    cbGrain.Visible := true;
+  end;
+  //传入字符串
+  edtInput.Text := strParam;
+  //初始化粮种大类下拉框
+  queryGrainTypeSql(t_Grain, 1, cbGrain);
+  cbGrain.Style := csDropDownList;
+  cbGrain.ItemIndex := Grain.Code-1;
+end;
+
+procedure TfrmInput.FormClose(Sender: TObject; var Action: TCloseAction);
+begin
+  Action := caFree;
+  frmInput := nil;
+end;
+
+//自定义函数:初始化粮种rec
+procedure TfrmInput.InitGrainRec();
+begin
+  GrainType_rec.Code := 0;
+  GrainType_rec.No   := '';
+  GrainType_rec.Name := '';
+  GrainType_rec.Coef[0] := '';
+  GrainType_rec.Coef[1] := '';
+  GrainType_rec.Coef[2] := '';
+  GrainType_rec.Coef[3] := '';
+  GrainType_rec.Coef[4] := '';
+end;
+
+procedure TfrmInput.edtReturnClick(Sender: TObject);
+begin
+  //根据粮种大类nam查大类信息
+  GrainType_rec := queryGrainSql(t_grain, cbGrain.Items[cbGrain.ItemIndex]);
+  //将结果更新到全局变量
+  glInput := edtInput.Text;
+  //打开触控板
+  ShellExecute(0, nil, 'OpenTabTip.exe', 'close', nil, SW_SHOWNORMAL);
+  //退出
+  Close();
+end;
+
+procedure TfrmInput.cbGrainChange(Sender: TObject);
+begin
+  if cbGrain.ItemIndex <> -1 then
+    edtInput.SetFocus;
+end;
+
+end.

--
Gitblit v1.9.3