SpeedDemon
Programmer
Hi, im pretty new to Delphi but am an experianced Pascal programmer.
Im having a problem with a new application that im making. It invloves
validating a user name and password and then logging a user into the system
appropriately
I've managed to gt the validation done, if a user is valid i get a variable
to 1. Within the same ButtonOnClick procedure I check to see if Loggedin =
1, if so I try to move into the main application by a simple Show command
(F_Mainform.show). This does work, however the password entry box remains,
so I altered to the original show command to...
F_Mainform.show;
F_Password.close; <--- password box form name
This wont work either How can I close the password box and move focus to
the mainform?
Thanks all.
My procedure is as follows:
procedure TF_Password.Button1Click(Sender: TObject);
var
i : integer;
begin
loggedin := 0;
{STEP1: Locate Filepos of last saved record}
AssignFile(passfile, passfileurl);
Reset(passfile);
f_passcounter := filesize(passfile)-1;
{STEP2: Find a matching result in usersfile}
for i := 0 to f_passcounter do
begin
seek(passfile,i);
read(passfile, passarray);
if lowercase(F_Password.username.Text) = passarray.username then
begin
if lowercase(F_Password.password.Text) = passarray.password
then
begin
loggedin := 1;
end;
end;
end;
if loggedin = 1 then
begin
{Successful Login}
F_Password.hide;
F_Mainform.Show;
end
else
begin
{UnSuccessful Login}
MessageDlg('Incorrect Login Details',mtError,[mbOK],0);
end;
end;
Im having a problem with a new application that im making. It invloves
validating a user name and password and then logging a user into the system
appropriately
I've managed to gt the validation done, if a user is valid i get a variable
to 1. Within the same ButtonOnClick procedure I check to see if Loggedin =
1, if so I try to move into the main application by a simple Show command
(F_Mainform.show). This does work, however the password entry box remains,
so I altered to the original show command to...
F_Mainform.show;
F_Password.close; <--- password box form name
This wont work either How can I close the password box and move focus to
the mainform?
Thanks all.
My procedure is as follows:
procedure TF_Password.Button1Click(Sender: TObject);
var
i : integer;
begin
loggedin := 0;
{STEP1: Locate Filepos of last saved record}
AssignFile(passfile, passfileurl);
Reset(passfile);
f_passcounter := filesize(passfile)-1;
{STEP2: Find a matching result in usersfile}
for i := 0 to f_passcounter do
begin
seek(passfile,i);
read(passfile, passarray);
if lowercase(F_Password.username.Text) = passarray.username then
begin
if lowercase(F_Password.password.Text) = passarray.password
then
begin
loggedin := 1;
end;
end;
end;
if loggedin = 1 then
begin
{Successful Login}
F_Password.hide;
F_Mainform.Show;
end
else
begin
{UnSuccessful Login}
MessageDlg('Incorrect Login Details',mtError,[mbOK],0);
end;
end;