Solved

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

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 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