InputBox - Como criar máscara
fiz esta função
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?
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
Curtidas 1
Melhor post
E_gama
13/03/2003
Uma forma alternativa seria essa: (nao esquecer de incluir a unit [b:7997bfa09c]Dblogdlg[/b:7997bfa09c])
[/b]
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.
GOSTEI 1
Mais Respostas
Aroldo Zanela
13/03/2003
fiz esta função
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,
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;
GOSTEI 0
Marco Salles
13/03/2003
Se me permite Aroldo , para que este tópico , fique livre de quaisquer desvio , que por ventura possa conduzir a uma má interpretação , por parte de [b:6b157f91a4]Futuros interresados[/b:6b157f91a4], Sugiro uma pequena correção no código original :idea:
Trecho do Código Original:
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:
[b:6b157f91a4]Chamando a Função InputQuery[/b:6b157f91a4]:
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;
GOSTEI 0
Aroldo Zanela
13/03/2003
Colega,
É este tópico mesmo? Não encontrei o texto abaixo em minha mensagem:
É este tópico mesmo? Não encontrei o texto abaixo em minha mensagem:
if ShowModal = mrOk then begin Value := Edit.Text; Result := True; end;
GOSTEI 0
Aroldo Zanela
13/03/2003
[quote:0ee15775d4=´Aroldo Zanela´]Colega,
É este tópico mesmo? Não encontrei o texto abaixo em minha mensagem:
[/quote:0ee15775d4]
Colega,
Desculpe, depois de postar eu encontrei. Obrigado!
É 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!
GOSTEI 0
Adolfo Lopes
13/03/2003
Uma forma alternativa seria essa: (nao esquecer de incluir a unit [b:7997bfa09c]Dblogdlg[/b:7997bfa09c])
[/b]
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.
Parabens, funcionou certinho, me ajudou muito. Obrigado
GOSTEI 0
Gladstone Matos
13/03/2003
Uma forma alternativa seria essa: (nao esquecer de incluir a unit Dblogdlg)
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.
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!!
GOSTEI 1
Hélio Devmedia
13/03/2003
Uma forma alternativa seria essa: (nao esquecer de incluir a unit Dblogdlg)
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.
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
GOSTEI 1
Gladstone Matos
13/03/2003
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
https://www.devmedia.com.br/forum/dica-mascara-de-password-no-inputbox/601446
obrigado Helio!! :D
GOSTEI 0