📄 frmeapubinputunt.pas
字号:
unit frmEAPubInputUnt;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, FormDlgEscUnt, StdCtrls, EAEdit;
type
TEAPubInputType = (epitString, epitDate, epitNumber);
TEAPubInputParam = record
Caption: string;
Title: string;
EditValue: string;
EditType: TEAPubInputType;
MaxLength: Integer;
AllowNull: Boolean;
end;
TfrmEAPubInput = class(TFormDlgEsc)
gbTitle: TGroupBox;
edtEditValue: TEAEdit;
btnOk: TButton;
btnCancel: TButton;
procedure btnOkClick(Sender: TObject);
private
FParam: TEAPubInputParam;
procedure InitData;
procedure SetData(AParam: TEAPubInputParam);
procedure GetData(var AParam: TEAPubInputParam);
public
{ Public declarations }
end;
function ShowEAPubInputDlg(var AParam: TEAPubInputParam): Boolean; overload;
function ShowEAPubInputDlg(const ACaption, ATitle: string; var AEditValue: string;
AEditType: TEAPubInputType = epitString; AMaxLength: Integer = 0;
AllowNull: Boolean = False): Boolean; overload;
function ShowEAPubInputDlg(var AEditValue: string): Boolean; overload;
var
frmEAPubInput: TfrmEAPubInput;
implementation
uses
EASysUtils;
{$R *.dfm}
function ShowEAPubInputDlg(var AParam: TEAPubInputParam): Boolean;
begin
Result := False;
frmEAPubInput := TfrmEAPubInput.Create(Application);
with frmEAPubInput do
try
SetData(AParam);
InitData;
if ShowModal = IDOK then
begin
GetData(AParam);
Result := True;
end;
finally
Free;
end;
frmEAPubInput := nil;
end;
function ShowEAPubInputDlg(const ACaption, ATitle: string; var AEditValue: string;
AEditType: TEAPubInputType; AMaxLength: Integer; AllowNull: Boolean): Boolean; overload;
var
P: TEAPubInputParam;
begin
P.Caption := ACaption;
P.Title := ATitle;
P.EditValue := AEditValue;
P.EditType := AEditType;
P.MaxLength := AMaxLength;
P.AllowNull := AllowNull;
Result := ShowEAPubInputDlg(P);
if Result then
AEditValue := P.EditValue;
end;
function ShowEAPubInputDlg(var AEditValue: string): Boolean; overload;
var
P: TEAPubInputParam;
begin
P.Caption := '';
P.Title := '录入';
P.EditValue := AEditValue;
P.EditType := epitString;
P.MaxLength := 0;
P.AllowNull := False;
Result := ShowEAPubInputDlg(P);
if Result then
AEditValue := P.EditValue;
end;
{ TfrmEAPubInput }
procedure TfrmEAPubInput.GetData(var AParam: TEAPubInputParam);
begin
AParam.EditValue := edtEditValue.Text;
end;
procedure TfrmEAPubInput.InitData;
begin
edtEditValue.DataType := TEAEditDataType(FParam.EditType);
edtEditValue.Text := FParam.EditValue;
edtEditValue.MaxLength := FParam.MaxLength;
Caption := FParam.Caption;
gbTitle.Caption := FParam.Title;
end;
procedure TfrmEAPubInput.SetData(AParam: TEAPubInputParam);
begin
FParam := AParam;
end;
procedure TfrmEAPubInput.btnOkClick(Sender: TObject);
function CheckIt: Boolean;
begin
if not FParam.AllowNull and (Trim(edtEditValue.Text) = '') then
begin
Result := False;
ea.Dlg.MsgInfo('录入值不能为空。');
edtEditValue.SetFocus;
end
else
Result := True;
end;
begin
if CheckIt then
ModalResult := IDOK;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -