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
