InputBox - Como criar máscara
13/03/2003
0
function TfrmVenda.ValidaSenha: Boolean;
var
p: string;
begin
p:=inputbox(´Password´, ´Entre com a senha´, ´´);
if p = Dm.UsuarioSenha.String then ValidaSenha := true
else
ValidaSenha := False;
end;
ela funciona, porem o edit do inputbox, não vem mascarado. Como fazer para mascaá-lo, para somente aparecer, * ou ¬ ou $ ou # e etc?
Paulo
Post mais votado
13/03/2003
unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Dblogdlg; type TForm1 = class(TForm) Button1: TButton; Label1: TLabel; Label2: TLabel; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); var Usuario, Senha: string; begin LoginDialog(´´, Usuario, Senha); Label1.Caption := Usuario; Label2.Caption := Senha; end; end.
E_gama
Mais Posts
13/03/2003
Aroldo Zanela
Paulo,
Use a inputquery e faça as alterações conforme abaixo:
function TForm1.InputQuery(const ACaption, APrompt: string; var Value: string): 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 Canvas.Font := Font; DialogUnits := GetAveCharSize(Canvas); BorderStyle := bsDialog; Caption := ACaption; ClientWidth := MulDiv(180, DialogUnits.X, 4); ClientHeight := MulDiv(63, DialogUnits.Y, 8); Position := poScreenCenter; Prompt := TLabel.Create(Form); with Prompt do begin Parent := Form; AutoSize := True; Left := MulDiv(8, DialogUnits.X, 4); Top := MulDiv(8, DialogUnits.Y, 8); Caption := APrompt; end; Edit := TEdit.Create(Form); with Edit do begin Parent := Form; PasswordChar := ´*´; // AZ Left := Prompt.Left; Top := MulDiv(19, DialogUnits.Y, 8); Width := MulDiv(164, DialogUnits.X, 4); MaxLength := 255; Text := Value; SelectAll; end; ButtonTop := MulDiv(41, DialogUnits.Y, 8); ButtonWidth := MulDiv(50, DialogUnits.X, 4); ButtonHeight := MulDiv(14, DialogUnits.Y, 8); with TButton.Create(Form) do begin Parent := Form; Caption := ´Ok´; // AZ ModalResult := mrOk; Default := True; SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth, ButtonHeight); end; with TButton.Create(Form) do begin Parent := Form; Caption := ´Cancelar´; // AZ ModalResult := mrCancel; Cancel := True; SetBounds(MulDiv(92, DialogUnits.X, 4), ButtonTop, ButtonWidth, ButtonHeight); end; if ShowModal = mrOk then begin Value := Edit.Text; Result := True; end; finally Form.Free; end; end; function TForm1.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;
10/04/2005
Marco Salles
Trecho do Código Original:
......... if ShowModal = mrOk then begin Value := Edit.Text; Result := True; end; ..........
Como se pode notar , sempre que o usuário , clicar no botao ok da caixa de mensagem, o reult é true :cry: :cry: :cry:
Adaptação:
........ if ShowModal = mrOk then begin if Value = Edit.Text then Result := True; end else // no caso do botao cancelar se pressionado Value:=´Cancelar´ .........
[b:6b157f91a4]Chamando a Função InputQuery[/b:6b157f91a4]:
procedure TFormColocarMascaraNoImputBox.Button2Click(Sender: TObject); var p:Boolean; senha:String; begin senha:=´1234´; p:=InputQuery(´teste´,´ususario´,senha); if p then Showmessage(´Senha correta´) else if senha <> ´Cancelou´ then Showmessage(´Senha errada´); end;
10/04/2005
Aroldo Zanela
É este tópico mesmo? Não encontrei o texto abaixo em minha mensagem:
if ShowModal = mrOk then begin Value := Edit.Text; Result := True; end;
10/04/2005
Aroldo Zanela
É este tópico mesmo? Não encontrei o texto abaixo em minha mensagem:
if ShowModal = mrOk then begin Value := Edit.Text; Result := True; end;
Colega,
Desculpe, depois de postar eu encontrei. Obrigado!
07/06/2011
Adolfo Lopes
[code:1:7997bfa09c]unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Dblogdlg;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var Usuario, Senha: string;
begin
LoginDialog(´´, Usuario, Senha);
Label1.Caption := Usuario;
Label2.Caption := Senha;
end;
end.
[/code:1:7997bfa09c][/b]
Parabens, funcionou certinho, me ajudou muito. Obrigado
26/03/2019
Gladstone Matos
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Dblogdlg;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var Usuario, Senha: string;
begin
LoginDialog(´´, Usuario, Senha);
Label1.Caption := Usuario;
Label2.Caption := Senha;
end;
end.
excelente!!
26/03/2019
Hélio Devmedia
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Dblogdlg;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var Usuario, Senha: string;
begin
LoginDialog(´´, Usuario, Senha);
Label1.Caption := Usuario;
Label2.Caption := Senha;
end;
end.
excelente!!
Existe uma forma bem mais simples de fazer isto, e postei essa dica no fórum:
https://www.devmedia.com.br/forum/dica-mascara-de-password-no-inputbox/601446
26/03/2019
Gladstone Matos
https://www.devmedia.com.br/forum/dica-mascara-de-password-no-inputbox/601446
obrigado Helio!! :D
Clique aqui para fazer login e interagir na Comunidade :)