LoginForm

<< Click to Display Table of Contents >>

Navigation:  Technology Overview > Forms and Modules >

LoginForm

 LoginForm is another special Form type which is solely used for login purpose. If your application contains a LoginForm it will the first form displayed when a web session starts. A LoginForm can be created from uniGUI Wizard by following this path: File->New->Other->Delphi Projects->uniGUI for Delphi->Form.

 

uniGUI Wizard

uniGUI Wizard

   

Create a Login Form

Create a Login Form

 

 

This action will create a blank LoginForm which looks identical to a regular form:

A blank LoginForm

A blank LoginForm

 

Sample LoginForm design

Sample LoginForm design

 

 A LoginForm is a descendant of a built-in class named TUniLoginForm. Each application can only has one LoginForm. After adding LoginForm your application will show this form as default form when a new session starts. You need to add controls, event handlers and etc. to  implement required functionality. Login behavior is controlled using Form's ModalResult. If LognForm returns mrOK it means a successful login which will proceed to MainForm. When ModalResult returns mrCancel it will terminate application. So what you need to do is to validate user input and once there is a valid combination of user name and password you must return mrOK as ModalResult.

 

 

procedure TUniLoginForm1.UniButton1Click(Sender: TObject);
begin
  ModalResult := mrOK;  // Login is valid so proceed to MainForm
end;
 
procedure TUniLoginForm1.UniButton2Click(Sender: TObject);
begin
  ModalResult := mrCancel; // Invalid Login exit from app
end;

 

Once user is logged in and MainForm is displayed, there are two ways to terminate the session. You can terminate the session and return to LoginForm by returning mrOK as ModalResult or terminate the session by returning mrCancel. For security reasons existing session is always terminated before displaying the LoginForm. i.e. each new login.starts a new session by default.