Jump to content

InputQuery code sample


ttamturk
 Share

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...