Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help... Form Switching?

Status
Not open for further replies.

SpeedDemon

Programmer
Jan 1, 2001
70
GB
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;
 
Hi there,

I'm not sure how to post a sample attachment to this forum so if you have not worked this one out yet, email me and I will send you some sample code. s-) Its a bit long to explain in text.

Just put this email address together again (SPAM protection)
tim@
snlcomputing
.com.au

Tim Dover
SNL Computing
 
Try This


procedure TPasswordDlg.OKBtnClick(Sender: TObject);
begin
If Edit1.Text='VALIDUSER' Then CheckPwd Else Close;
// You can look this up in a databse if you wish!
end;

procedure TPasswordDlg.CheckPwd;
Begin
If edtPwd.Text='VALIDPASSWORD' Then
// You can look this up in a databse if you wish!

Begin
frmCreateUnlock.ShowModal; // Show next Form
PasswordDlg.Close // Close Password Form
end
else Close; // I close if the password is wrong, you could put a count loop here?

End;

procedure TPasswordDlg.CancelBtnClick(Sender: TObject);
begin
Close
end;

procedure TPasswordDlg.FormCreate(Sender: TObject);
begin
Edit1.Text:=''; // Just set the edit boxes to clear
EdtPwd.Text:=''; // You never know!!!
end; Kind Regards, Paul Benn

**** Never Giveup, keep trying, the answer is out there!!! ****
 
dear SpeedDemon
by adding this line ModelResult := mrOK in your code will resolve your problem. Check code belo for help

if loggedin = 1 then
begin
{Successful Login}
//F_Password.hide;//Commented by Saif
ModelResult := mrOK ; //Added by Saif
F_Mainform.Show;


end
 
Cheers Saif, I had to resolve the problem by making the login scrren appear manually, however i wil try what you've said.

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top