This function does not have a overload
to make this available, the way is to make a.
I have several ready in my system for various formats, be it String, Extended, Integer, Dates etc...
Following example:
function TFormTeste.InputValor(const aCaption: String; var aValor: String): Boolean;
var
vForm : TForm;
vLabel : TLabel;
vBtnOk : TBitBtn;
vValor : TEdit;
begin
Result := False;
vForm := TForm.Create(Application);
vLabel := TLabel.Create(vForm);
vBtnOk := TBitBtn.Create(vForm);
vValor := TEdit.Create(vForm);
with vForm do
begin
Name := 'FormValor';
Position := poScreenCenter;
BorderIcons := [biSystemMenu];
BorderStyle := bsSingle;
Caption := aCaption;
ClientHeight := 70;
ClientWidth := 180;
Color := clBtnFace;
OldCreateOrder := False;
PixelsPerInch := 96;
end;
with vLabel do
begin
Name := 'vLabel';
Parent := vForm;
Left := 8;
Top := 16;
Width := 31;
Height := 13;
Caption := 'Valor: ';
end;
with vValor do
begin
Name := 'vValorEdit';
Parent := vForm;
Left := 52;
Top := 11;
Width := 120;
Height := 21;
TabOrder := 0;
end;
with vBtnOk do
begin
Name := 'vBtnOk';
Parent := vForm;
Caption := 'Ok';
Left := vValor.Left;
Top := vValor.Top + vValor.Height + 5;
Width := vValor.Width;
Height := 21;
ModalResult := mrOk;
end;
vForm.ShowModal;
if(vForm.ModalResult = mrOk) and
(vValor.Text <> '') then
begin
Result := True;
aValor := vValor.Text;
end;
FreeAndNil(vForm);
end;
Use in the same way as the Official:
var
vTeste : String;
begin
if (InputValor('Informe um texto', vTeste) = True) then
ShowMessage(vTeste);
Oops! That’s good... I’ll test...
– Edu Mendonça
It’s getting good so I can get the size I want. Thank you!
– Edu Mendonça
Solving the problem, mark the answer as correct, this helps future researchers.
– Junior Moreira
If you put another button ex: Cancel as you do to click cancel all?
– Edu Mendonça
Create a button = done with OK, and on
ModalResult := mrCancel
, ai you test at the time of assigning the variable if the Modalresult was an Ok– Junior Moreira
I did it only that it’s working like OK
– Edu Mendonça
I think it’s on account of
if (vValor.Text <> '') then
 begin
 Result := True;
 aValor := vValor.Text;
 end;
– Edu Mendonça
before the
if (vValor.Text <> '')
place:if ModalResult = MrOk then...
– Junior Moreira
won’t, Modalresult always stays = 0
– Edu Mendonça
I edited the answer, is that you were not pointing to the
Form
, ai Result is always 0.– Junior Moreira
Thanks! It was really good
– Edu Mendonça