InputBox – Não Quero que mostre no meio da tela

Delphi

27/06/2003

Gostaria de saber como faço para definir Coluna e Linha, que ira Mostrar o InputBox



Desde já Obrigado


Araguaia Sistemas Ltda. Wolney Miranda


Wolney Miranda

Wolney Miranda

Curtidas 0

Respostas

Vmotta

Vmotta

27/06/2003

Não tem como posicionar o inputbox, mas utilize essas funcões que são as mesmas do inputbox, porém com algumas adaptações.
Copie essas funções para seu sistema:

//# Funções para gerar o InputBox

function GetAveCharSize(Canvas: TCanvas): TPoint;
var
I: Integer;
Buffer: array[0..51] of Char;
begin
for I := 0 to 25 do Buffer[I] := Chr(I + Ord(´A´));
for I := 0 to 25 do Buffer[I + 26] := Chr(I + Ord(´a´));
GetTextExtentPoint(Canvas.Handle, Buffer, 52, TSize(Result));
Result.X := Result.X div 52;
end;

function vInputQuery(const ACaption, APrompt: string;
var Value: string; x,y:integer): Boolean;
var
Form: TForm;
Prompt: TLabel;
Edit: TEdit;
DialogUnits: TPoint;
ButtonTop, ButtonWidth, ButtonHeight: Integer;
begin
Result := False;
Form := TForm.Create(Application);
with Form do
try
FormStyle := fsStayOnTop;
Canvas.Font := Font;
DialogUnits := GetAveCharSize(Canvas);
BorderStyle := bsDialog;
Caption := ACaption;
ClientWidth := MulDiv(180, DialogUnits.X, 4);
Position := poDesigned;
Top := y;
Left := x;
Prompt := TLabel.Create(Form);
with Prompt do
begin
Parent := Form;
Caption := APrompt;
Left := MulDiv(8, DialogUnits.X, 4);
Top := MulDiv(8, DialogUnits.Y, 8);
Constraints.MaxWidth := MulDiv(164, DialogUnits.X, 4);
WordWrap := True;
end;
Edit := TEdit.Create(Form);
with Edit do
begin
Parent := Form;
Left := Prompt.Left;
Top := Prompt.Top + Prompt.Height + 5;
Width := MulDiv(164, DialogUnits.X, 4);
MaxLength := 255;
// PassWordChar := ´*´;
Text := Value;
SelectAll;
end;
ButtonTop := Edit.Top + Edit.Height + 15;
ButtonWidth := MulDiv(50, DialogUnits.X, 4);
ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
with TButton.Create(Form) do
begin
Parent := Form;
Caption := ´Ok´;
ModalResult := mrOk;
Default := True;
SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth,
ButtonHeight);
end;
with TButton.Create(Form) do
begin
Parent := Form;
Caption := ´Cancelar´;
ModalResult := mrCancel;
Cancel := True;
SetBounds(MulDiv(92, DialogUnits.X, 4), Edit.Top + Edit.Height + 15,
ButtonWidth, ButtonHeight);
Form.ClientHeight := Top + Height + 13;
end;
if ShowModal = mrOk then
begin
Value := Edit.Text;
Result := True;
end;
finally
Form.Free;
end;
end;

function vInputBox(const ACaption, APrompt, ADefault: string; x,y: integer): string;
begin
Result := ADefault;
vInputQuery(ACaption, APrompt, Result, x,y);
end;

// #

Agora Chame a função vInputBox da seginte maneira :

var
strNome : String;
begin
strNome := vInputBox(´Nome´, ´Digite seu Nome:´, ´´,200,100);
// funciona da mesma maneira que o InputBox, porém tem 2 parametros
// a mais que sao a posição x e y
end;

espero ter te ajudado !!
T+
Vitor <vmotta@eep.br>


GOSTEI 0
POSTAR