Solved

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

Posted on 2011-02-23
2
656 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now