função para gerar um InputQuery, porém, ao invés de usar um TEdit, é usado um TMemo
function InputMemo(ACaption, ATexto: String; var AResult: String): Boolean;
var Form: TForm;
Memo: TMemo;
Label1: TLabel;
ButtonOK, ButtonCancel: TButton;
iWidth: Integer;
begin
iWidth := 350;
Form := TForm.Create(nil);
Form.Height := 200;
Form.Width := iWidth;
Form.Position := poScreenCenter;
Form.Caption := ACaption;
Label1 := TLabel.Create(Form);
Label1.Parent := Form;
Label1.Top := 5;
Label1.Left := 5;
Label1.Width := Form.Width - 10;
Label1.Caption := ATexto;
Memo := TMemo.Create(Form);
Memo.Parent := Form;
Memo.Top := Label1.Top + Label1.Height + 5;
Memo.Left := 5;
Memo.width := Form.Width - 10;
Memo.Height := Form.Height - Memo.Top - 45;
iWidth := iWidth + 95;
Form.Width := iWidth;
ButtonOK := TButton.Create(Form);
ButtonOK.Parent := Form;
ButtonOK.Top := 5;
ButtonOK.Left := iWidth - 20 - ButtonOK.Width;
ButtonOK.Caption := 'OK';
ButtonOK.ModalResult := mrOK;
ButtonCancel := TButton.Create(Form);
ButtonCancel.Parent := Form;
ButtonCancel.Top := ButtonOK.Top + ButtonOK.Height + 5;
ButtonCancel.Left := ButtonOK.Left;
ButtonCancel.Caption := 'Cancelar';
ButtonCancel.ModalResult := mrCancel;
Result := Form.ShowModal = mrOK;
if Result then
AResult := Memo.Text;
FreeAndNil(Memo);
FreeAndNil(Label1);
FreeAndNil(Form);
end;
exemplo de uso
procedure ...
var sTexto: String;
begin
sTexto := '';
InputMemo('Teste de Memo','Digite o texto', sTexto);
ShowMessage('Texto digitado: '+ sTexto);
end;
function InputMemo(ACaption, ATexto: String; var AResult: String): Boolean;
var Form: TForm;
Memo: TMemo;
Label1: TLabel;
ButtonOK, ButtonCancel: TButton;
iWidth: Integer;
begin
iWidth := 350;
Form := TForm.Create(nil);
Form.Height := 200;
Form.Width := iWidth;
Form.Position := poScreenCenter;
Form.Caption := ACaption;
Label1 := TLabel.Create(Form);
Label1.Parent := Form;
Label1.Top := 5;
Label1.Left := 5;
Label1.Width := Form.Width - 10;
Label1.Caption := ATexto;
Memo := TMemo.Create(Form);
Memo.Parent := Form;
Memo.Top := Label1.Top + Label1.Height + 5;
Memo.Left := 5;
Memo.width := Form.Width - 10;
Memo.Height := Form.Height - Memo.Top - 45;
iWidth := iWidth + 95;
Form.Width := iWidth;
ButtonOK := TButton.Create(Form);
ButtonOK.Parent := Form;
ButtonOK.Top := 5;
ButtonOK.Left := iWidth - 20 - ButtonOK.Width;
ButtonOK.Caption := 'OK';
ButtonOK.ModalResult := mrOK;
ButtonCancel := TButton.Create(Form);
ButtonCancel.Parent := Form;
ButtonCancel.Top := ButtonOK.Top + ButtonOK.Height + 5;
ButtonCancel.Left := ButtonOK.Left;
ButtonCancel.Caption := 'Cancelar';
ButtonCancel.ModalResult := mrCancel;
Result := Form.ShowModal = mrOK;
if Result then
AResult := Memo.Text;
FreeAndNil(Memo);
FreeAndNil(Label1);
FreeAndNil(Form);
end;
exemplo de uso
procedure ...
var sTexto: String;
begin
sTexto := '';
InputMemo('Teste de Memo','Digite o texto', sTexto);
ShowMessage('Texto digitado: '+ sTexto);
end;
Parabéns. Ficou Top!!
ResponderExcluir