Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to move from a login screen to the main form. i need my login to come up first before the main form , and there after a succesful username and password logon the login form must disappear.currrently i am using
Delphi
form2.show;
and
Delphi
form1.hide;
i know this wrong , but i dont know what is the correct way to move from a login screen to a mainform. please see below my code from login screen. please dont mind my components naming

C#
IBQuery1.SQL.clear;
        IBQuery1.SQL.add('Select * from USER_ACCESS where USERID = '+ edit1.Text+'') ;
        IBQuery1.Active := true;
        UserId := IBQuery1.FieldByname('USERID').AsInteger;
        pasword:= IBQuery1.Fieldbyname('PASWORD').AsString;
        name1 := IBQuery1.fieldbyname('NAME').AsString;
        privilege := IBQuery1.fieldbyname('USERTYPE').AsString;

                if((UserId = StrToInt(edit1.Text)) And (pasword = edit2.Text))
         THEN

          begin
        ShowMessage('login Successful ' + name1);
    form2.Show;
   Form1.Hide;
        end

        else

        ShowMessage('Wrong Password');


end;
Posted

1 solution

One of the simplest ways would be: show your fist form (login) as modal via ShowModal:
http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Forms_TCustomForm_ShowModal.html[^].

And you second (main) form should be shown later, when the first form is closed.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900