Solved

How to make this login thingie working?

Posted on 2008-10-29
6
144 Views
Last Modified: 2010-08-05
Hi Folks!

I have an editbox which I want to use as password box.

1. when the text = 'Geef wachtwoord in'  It should be cleared when the user clicks in it
2. It should show * instead of the password characters
3. When the user clicks somewhere else ie changed his mind and does soemthing else, it should show 'Geef wachtwoord in'
4. It should validate the input, password will be 1234 thus 4 numbers

If you need more info (or more points :)) please ask,

Regards,

Peter

0
Comment
Question by:PeterdeB
  • 3
  • 3
6 Comments
 
LVL 28

Accepted Solution

by:
2266180 earned 500 total points
ID: 22831045
try this, let me know how it works
unit Unit1;
 

interface
 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls;
 

type

  TForm1 = class(TForm)

    Edit1: TEdit;

    Button1: TButton;

    procedure Edit1Enter(Sender: TObject);

    procedure Edit1KeyPress(Sender: TObject; var Key: Char);

    procedure Edit1Exit(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;
 

var

  Form1: TForm1;
 

implementation
 

{$R *.dfm}
 

procedure TForm1.Edit1Enter(Sender: TObject);

begin

  with (sender as TEdit) do

  begin

    text:='';

    passwordchar:='*';

  end;

end;
 

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);

begin

  if not (key in ['0'..'9']) then

    key:=#0

  else

    if length((sender as TEdit).Text)=4 then

      key:=#0;

end;
 

procedure TForm1.Edit1Exit(Sender: TObject);

begin

  with (sender as TEdit) do

    if length(text)<>4 then

    begin

      text:='Geef wachtwoord in';

      passwordchar:=#0;

    end;

end;
 

end.
 
 

----------dfm

object Form1: TForm1

  Left = 192

  Top = 114

  Width = 870

  Height = 640

  ActiveControl = Button1

  Caption = 'Form1'

  Color = clBtnFace

  Font.Charset = DEFAULT_CHARSET

  Font.Color = clWindowText

  Font.Height = -11

  Font.Name = 'MS Sans Serif'

  Font.Style = []

  OldCreateOrder = False

  PixelsPerInch = 96

  TextHeight = 13

  object Edit1: TEdit

    Left = 120

    Top = 80

    Width = 121

    Height = 21

    TabOrder = 0

    Text = 'Geef wachtwoord in'

    OnEnter = Edit1Enter

    OnExit = Edit1Exit

    OnKeyPress = Edit1KeyPress

  end

  object Button1: TButton

    Left = 88

    Top = 152

    Width = 75

    Height = 25

    Caption = 'Button1'

    TabOrder = 1

  end

end

Open in new window

0
 

Author Comment

by:PeterdeB
ID: 22834549
Hi Ciuly,

It doesnt work, I cannot type into the edit box

Regards,

Peter
0
 
LVL 28

Expert Comment

by:2266180
ID: 22835223
you said the password is all numbers. "4. It should validate the input, password will be 1234 thus 4 numbers"

are you typing that?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:PeterdeB
ID: 22836622
Hi ciuly,

I apologize, I was wrong it does work thanks! Validating the input by means of the button click, involves no rocket science right?

Regards,

Peter
0
 

Author Comment

by:PeterdeB
ID: 22836898
Got it already thanks Ciuly!

Peter
0
 
LVL 28

Expert Comment

by:2266180
ID: 22838960
>> Validating the input by means of the button click, involves no rocket science right?

right :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Virtuailstring tree compare node issue 14 105
Send message from delphi to whatsapp, is it possible? 3 1,185
Multiple image collision 13 69
FMX and jaudiotracker playing memory stream 29 66
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…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

896 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

16 Experts available now in Live!

Get 1:1 Help Now