一个修改过简化版的InputQuery

主要是觉得在单输入的情况下, 原来InputQuery输入框左边的文本太难看了......

  function _InputQuery(const ACaption: string; const APrompt: string; var AValue: string): Boolean;
var
nForm: TForm;
nEdit: TEdit;
nTop: Integer;
nTextMetric: TTextMetric;
begin
Result := False;
nForm := TForm.CreateNew(Application);
with nForm do
try
Canvas.Font := Font;
BorderStyle := bsDialog;
Caption := ACaption;
ClientWidth := ;
PopupMode := pmAuto;
Position := poScreenCenter;
nEdit := nil; GetTextMetrics(Canvas.Handle, nTextMetric); nTop := nTextMetric.tmAscent + ; nEdit := TEdit.Create(nForm);
with nEdit do
begin
Parent := nForm;
Left := ;
Top := nTop;
Width := nForm.ClientWidth - ;
MaxLength := ;
Text := AValue;
SelectAll;
Inc(nTop, Height + );
end; if APrompt <> '' then
begin
with TLabel.Create(nForm) do
begin
Parent := nForm;
AutoSize := False;
Caption := APrompt;
Font.Color := clGrayText;
Left := ;
Top := nTop;
Width := nForm.ClientWidth - ;
WordWrap := False;
Inc(nTop, Height + );
end;
end; with TButton.Create(nForm) do
begin
Parent := nForm;
Caption := '确定';
ModalResult := mrOk;
Default := True;
SetBounds(nForm.ClientWidth - Width * - - , nTop, Width, Height);
end;
with TButton.Create(nForm) do
begin
Parent := nForm;
Caption := '取消';
ModalResult := mrCancel;
Cancel := True;
SetBounds(nForm.ClientWidth - Width - , nTop, Width, Height);
nForm.ClientHeight := Top + Height + nTextMetric.tmAscent;
end;
if ShowModal = mrOk then
begin
AValue := nEdit.Text;
Result := True;
end;
finally
nForm.Free;
end;
end;
上一篇:贾天昊 - Nick


下一篇:Python退火算法在高次方程的应用