将Edit控件本身放在MessageDlg的对话框中:
function ShowInput(const asCaption: string): string;
var
edtInput: TEdit;
frmDlg: TForm;
begin
frmDlg := CreateMessageDialog(asCaption, mtInformation, [mbOK, mbCancel]);
with frmDlg do
try
Caption := Application.Title;
Width := 250;
Height := 123;
edtInput := TEdit.Create(frmDlg);
with edtInput do
begin
Parent := frmDlg;
Left := 56;
Top := 32;
Width := 160;
Height := 23;
TabOrder := 1;
end;
with TButton(Components[2]) do
begin
Caption := '确定';
Width := 80;
Left := 55;
Top := 65;
TabOrder := 2;
end;
with TButton(Components[3]) do
begin
Caption := '取消';
Width := 80;
Top := 65;
Left := 138;
TabOrder := 2;
end;
if ShowModal = IDOk then
Result := edtInput.Text
else
Result := '';
finally
Free;
end;
end;