Solved

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

Posted on 2011-02-23
2
660 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 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