AJ: made InputQuery Interface Dependant

git-svn-id: trunk@1213 -
This commit is contained in:
lazarus 2002-02-09 01:48:06 +00:00
parent 2d793e93b1
commit 206d9e343a

View File

@ -926,6 +926,95 @@ begin
Result := false;
end;
Function TInterfaceBase.RequestInput(const InputCaption, InputPrompt : String;
MaskInput : Boolean; var Value : String) : Boolean;
Const
AVGBuffer : PChar = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890()|_ ';
var
Form : TForm;
Prompt : TLabel;
Edit : TEdit;
T : String;
ButtonTop, ButtonWidth, ButtonHeight : Integer;
Avg : TPoint;
begin
Result := False;
Form := TForm.CreateNew(nil, 0);
With Form do begin
BorderStyle := bsDialog;
Caption := InputCaption;
Prompt := TLabel.Create(Form);
With Prompt do begin
Parent := Form;
Caption := InputPrompt;
Visible := True;
end;
SelectObject(Canvas.Handle, GetStockObject(SYSTEM_FONT));
GetTextExtentPoint(Canvas.Handle,AVGBuffer,StrLen(AVGBuffer),TSize(AVG));
AVG.X := AVG.X div 52;
Position := poScreenCenter;
Prompt.Left := (7*AVG.X) div 4;
Prompt.Top := (8*AVG.Y) div 8;
Prompt.Width := AVG.X * Length(InputPrompt) + 1;
ClientWidth := (172*AVG.X) div 4;
ClientHeight := (58*AVG.Y) div 8;
ButtonTop := (39*AVG.Y) div 8;
ButtonWidth := (50*AVG.X) div 4;
ButtonHeight := (13*AVG.Y) div 8;
Edit := TEdit.Create(Form);
With Edit do begin
Parent := Form;
Left := Prompt.Left;
Top := (19*AVG.Y) div 8;
Width := (160*AVG.X) div 4;
Height := (7*AVG.Y) div 4;
Text := Value;
TabStop := True;
Visible := True;
If MaskInput then
EchoMode := emPassword
else
EchoMode := emNormal;
TabOrder := 0;
end;
With TBitBtn.Create(Form) do begin
Parent := Form;
Kind := bkOk;
Default := True;
ModalResult := mrOk;
Left := (37*AVG.X) div 4;
Top := ButtonTop;
Height := ButtonHeight;
Width := ButtonWidth;
TabStop := True;
Visible := True;
TabOrder := 1;
end;
With TBitBtn.Create(Form) do begin
Parent := Form;
Kind := bkCancel;
Cancel := True;
Left := (92*AVG.X) div 4;
Top := ButtonTop;
Height := ButtonHeight;
Width := ButtonWidth;
TabStop := True;
Visible := True;
TabOrder := 2;
end;
Show;
Edit.SetFocus;
Hide;
If ShowModal = mrOk then
begin
T := Edit.Text;
Result := True;
End;
Form.Close;
end;
Value := T;
end;
function TInterfaceBase.KillTimer (hWnd : HWND; uIDEvent : cardinal) : boolean;
begin
Result := false;
@ -1401,6 +1490,9 @@ end;
{ =============================================================================
$Log$
Revision 1.54 2002/10/11 16:00:39 lazarus
AJ: made InputQuery Interface Dependant
Revision 1.53 2002/10/10 13:29:08 lazarus
AJ: added LoadStockPixmap routine & minor fixes to/for GNOMEInt