Jump to content

InputQuery code sample


ttamturk

Recommended Posts

Hi,

I can see a different style InputQuery parameters in code completion.

 

function InputQuery(const ACaption: string; const APromts: array of string; var AValues: array of string;CloseQueryFunc: TInputCloseQueryFunc = nil): Boolean;

 

When I use this It opens Windows Form InputQuery box..

I need InputQuery in Web.

 

Like MessageDlg web version..

 

procedure TMainForm._ExitConfirm(AResult:Integer);

begin

case AResult of

mrYes : MainForm.Close;

mrNo : ShowMessage('Application continue.');

end;

end;

 

procedure TMainForm.Cikis1Click(Sender: TObject);

begin

MessageDlg('Exit?',mtConfirmation, mbYesNo,_ExitConfirm);

end;

Link to comment
Share on other sites

  • 2 weeks later...

Hi Farshad,

 

I wrote a dirty version of InputQuery.

 

procedure InputQuery(ACaption, APrompt, AValue : String; _OnOkClick, _OnCancelClick : TNotifyEvent);
var F : TUniForm;
 Prompt: TUniLabel;
 Edit : TUniEdit; 
 DialogUnits: TPoint; B1,B2 : TUniButton;
 ButtonTop, ButtonWidth, ButtonHeight: Integer;
const
 SMsgDlgOK = 'Ok';
 SMsgDlgCancel = 'Cancel';
begin
 F := TUniForm.Create(UniApplication);
 with F do begin
	F.Caption := ACaption;
	F.BorderStyle := bsDialog;
	DialogUnits := Point(8,8);
	//F.ClientWidth := MulDiv(180, DialogUnits.X,4);   //Not Working
	//F.ClientHeight := MulDiv(60, DialogUnits.Y,4);   //Not Working
	F.SetBounds(0,0,MulDiv(164, DialogUnits.X,4), MulDiv(70, DialogUnits.Y,4)); //Working
	Prompt := TUniLabel.Create(F);
	with Prompt do begin
       Parent := F;
       Caption := APrompt;
       Left := MulDiv(8, DialogUnits.X, 4);
       Top := MulDiv(8, DialogUnits.Y, 8);
       Constraints.MaxWidth := MulDiv(164, DialogUnits.X, 4);
	end;
     Edit := TUniEdit.Create(F);
     with Edit do
     begin
       Parent := F;
       Name := 'ueEdit';
       Left := Prompt.Left;
       Top := Prompt.Top + Prompt.Height + 5;
       Width := MulDiv(140, DialogUnits.X, 4);
       Text := AValue;
     end;
     ButtonTop := Edit.Top + Edit.Height + 15;
     ButtonWidth := MulDiv(50, DialogUnits.X, 4);
     ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
     with TUniButton.Create(F) do
     begin
       Parent := F;
       Caption := SMsgDlgOK;
       ModalResult := mrOk;
       Default := True;
       SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth,ButtonHeight);
       OnClick := _OnOkClick;
     end;
     B2 := TUniButton.Create(F);
     with B2 do
     begin
       Parent := F;
       Caption := SMsgDlgCancel;
       ModalResult := mrCancel;
       Cancel := True;
       SetBounds(MulDiv(92, DialogUnits.X, 4), Edit.Top + Edit.Height + 15, ButtonWidth, ButtonHeight);
       OnClick := _OnCancelClick;
       //F.Height := B2.Top + B2.Height + 13 + 20;  //Not Working
     end;
     F.ShowModal;
 end;
end;


procedure TMainForm._OkClick(Sender : TObject);
var F : TUniForm; E : TUniEdit;
begin
 F := TUniForm(TUniButton(Sender).Owner);
 E := TUniEdit(F.FindChildControl('ueEdit'));

 ShowMessage('Value : '+E.Text);
end;

 

Question 1: ClientWidht, ClientHeight is not working?

Question 2: What is the best way to release F (TUniForm)? Or Is it cleared automaticaly?

Link to comment
Share on other sites

  • Administrators

 

Question 1: ClientWidht, ClientHeight is not working?

Question 2: What is the best way to release F (TUniForm)? Or Is it cleared automaticaly?

 

1) ClientWidht, ClientHeightcan only be set at design time. At runtime use Width and Height

2) Form is freed automatically. FreeOnClose is true by default.

Link to comment
Share on other sites

  • 10 years later...

Hello,

3 hours ago, FRANCISCO CASTRO SOTO said:
Hello, how would the inputquery procedure be used?, 

 

On 5/6/2012 at 2:21 PM, Farshad Mohajeri said:

What do you specifically mean by Input Query?

 

3 hours ago, FRANCISCO CASTRO SOTO said:
I'm trying to use it and I get memory access errors

In what way do you use?

 

See the demos:

\FMSoft\Framework\uniGUI\Demos\Desktop\Prompt
\FMSoft\Framework\uniGUI\Demos\Desktop\Prompt Anonymous Callback

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...