Solved

****** and not characters into password TEdit

Posted on 2011-02-23
2
658 Views
Last Modified: 2012-05-11
I have two code from.  Pleas put them together so when i will type character into password TEdit
"**********" will come out?
// *******************  pasword
procedure TForm2.InputBoxSetPasswordChar(var Msg: TMessage);
var
  hInputForm, hEdit, hButton: HWND;
 begin
  hInputForm := Screen.Forms[0].Handle;
  if (hInputForm <> 0) then
  begin
    hEdit := FindWindowEx(hInputForm, 0, 'TEdit', nil);
               // Change button text:
      hButton := FindWindowEx(hInputForm, 0, 'TButton', nil);
      SendMessage(hButton, WM_SETTEXT, 0, Integer(PChar('Cancel')));
      SendMessage(hEdit, EM_SETPASSWORDCHAR, Ord('*'), 0);
  end;
end;

Open in new window

unit password;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm3 = class(TForm)
    Login: TEdit;
    password: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    OKBtn: TButton;
    CancelBtn: TButton;
    procedure CancelBtnClick(Sender: TObject);
    procedure OKBtnClick(Sender: TObject);
       function CheckPassword: Boolean;
    procedure FormCreate(Sender: TObject);

  private
    { Private declarations }
  public


    { Public declarations }
  end;

var
  Form3: TForm3;
  passwordtext:string;
  i:integer=1;
implementation

uses machine, mirna10;


{$R *.dfm}

type
  TUserID = record
    Login: string;
    Password: string;
  end;

const
  CUserID: array[0..4] of TUserID = (
    (Login: 'i'; Password: '1'),
    (Login: 'iv'; Password: '2'),
    (Login: 'iva'; Password: '3'),
    (Login: 'ivan'; Password: '4'),
    (Login: 'ivang'; Password: '5')
  );

function TForm3.CheckPassword: Boolean;
var
  PasswordDlg: Tform3;
begin
  PasswordDlg := Tform3.Create(Application);
  try
    Result := PasswordDlg.ShowModal = mrOk;
  finally
    FreeAndNil(PasswordDlg);
  end;
end;




procedure TForm3.FormCreate(Sender: TObject);
begin

end;

procedure Tform3.OKBtnClick(Sender: TObject);
var
  I: Integer;
  ID: TUserID;
begin
  ModalResult := mrNone;
  for I := 0 to Length(CUserID) - 1 do
  begin
    if (UpperCase(Login.Text) = UpperCase(CUserID[I].Login)) and
       (Password.Text = CUserID[I].Password) then
    begin
    Form1.Timer1.Enabled:=true;
           ModalResult := mrOk;
        //passwordtext:=login.Text;
           loginmy:=  login.Text;
           okpassword:=true;
           form1.timer1.Enabled:=true;
            Str := DateTimeToStr(Now)+'  '+ loginmy;  // aloud writing procedure
    end;
  end;
  if ModalResult <> mrOk then
    MessageBox(Handle, 'Invalid user name or password!', 'Login', MB_OK);
end;


procedure Tform3.CancelBtnClick(Sender: TObject);
begin
  ModalResult := mrCancel;
end;

end.

Open in new window

0
Comment
Question by:pr2501
2 Comments
 
LVL 32

Accepted Solution

by:
ewangoya earned 500 total points
ID: 34963697
You dont need to do it from code, set it from the TEdit properties
Password-Character.PNG
0
 

Author Comment

by:pr2501
ID: 34964216
thank you
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
delphi exception 7 64
Communication Between RC4 Delphi <-> PHP 3 113
Firemonkey webbrowser scrollbars ? 1 38
DBCtrlGrid, Delphi, Scroll 8 9
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question