Ver Mensaje Individual
  #6  
Antiguo 09-04-2015
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola oscjae.

Una forma de evitar que programas como ShowPassword muestren tu contraseña es derivar una clase de TEdit, es decir hacer algo como esto:
Código Delphi [-]
unit uPwdEdit;

interface

uses SysUtils, Controls, Messages, StdCtrls;

type
  TEditPwd = class(TEdit)
  private
    FKeyEvent: TKeyPressEvent;
    FRealText: string;
  protected
    procedure KeyPress(var Key: Char); reintroduce; override;
  public
    property RealText: string read FRealText write FRealText;
  end;

implementation

procedure TEditPwd.KeyPress(var Key: Char);
begin
  inherited KeyPress(Key);

  if Key = #8 then
    SetLength(FRealText, Length(FRealText)-1)
  else
  begin
    FRealText:= FRealText + Key;
    Key:= PasswordChar;
  end
end;

end.

Para usarlo:
Código Delphi [-]
implementation

uses uPwdEdit;

var
  PwdEdit: TEditPwd;

procedure TForm1.FormCreate(Sender: TObject);
begin
  PwdEdit:= TEditPwd.Create(Self);
  with PwdEdit do
  begin
    Left        := 10;
    Top         := 40;
    Width       := 150;
    PasswordChar:= '-';
    Parent      := Self;
  end;
  ...
end;

...

procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption := PwdEdit.RealText;
end;

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 10-04-2015 a las 02:07:32.
Responder Con Cita