Jump to content
uniGUI Discussion Forums
sysjames

How to present error message in login screen

Recommended Posts

I have a login screen that serves two purposes: To login OR to create a new account.

 

The problem I have is in trying to present messages when the user enters incorrect information or tries to create an already existing account.

 

I've tried several methods of presenting the messages (and perhaps giving them a second chance) without success.  

 

How do you do this? 

 

A picture of my login screen is attached.

 

 

post-3438-0-30531800-1506038812_thumb.png

Share this post


Link to post
Share on other sites
This was my last attempt:

 

I had a panel called "MessageArea" with a label called "MessageText".  I was putting the message text into MessageText and making MessageArea visible (It was not visible at the start).  The trouble with this approach was that nothing stopped the loop (as a real dialog would).

 

I also tried MessageDlg and even UniSF's SweetAlert, None of which worked (they did not display).  (I am about to conclude that I should bypass the login screen altogether, main my own (Main) and use secondary created screens as to process the application.

 

My current code follows:

 

Procedure TUniLoginForm1.CancelBtnClick(Sender: TObject);

Begin

ModalResult := mrCancel;

Close

End;

 

Procedure TUniLoginForm1.CreateBtnClick(Sender: TObject);

Var

   CreateOK: Boolean;

Begin

CreateOK := False;

While Not CreateOK Do

   Begin

   If (Email.Text <> '') And (Password.Text <> '') And (FName.Text <> '') And (LName.Text <> '') Then

      Begin

      Try

         UniMainModule.Account := CreateAccount(Email.Text, Password.Text, FName.Text, LName.Text, 0);

         ModalResult := mrOK;

         Close;

      Except

         On E: PlErrAcctAExist Do

            Begin

            MessageText.Text := 'That account already exists';

            MessageArea.Visible := True;

            End;

      End;

      End;

   End;

End;

 

Procedure TUniLoginForm1.LoginBtnClick(Sender: TObject);

Var

   LoginOK: Boolean;

Begin

LoginOK := False;

While Not LoginOK Do

   Begin

   Try

      UniMainModule.Account := LoadAccount(EmailEntry.Text, PassEntry.Text);

      LoginOK := True;

   Except

      On E: PlErrAcctNF Do

         LoginOK := False;

      On E: PlErrBadPass Do

         LoginOK := False;

   End;

   If LoginOK Then

      Begin

      ModalResult := mrOK;

      Close;

      End

   Else

      Begin

      MessageText.Text := 'The account or the password is in error';

      MessageArea.Visible := True;

      End;

   End;

End;

 

Procedure TUniLoginForm1.MessageCancelBtnClick(Sender: TObject);

Begin

ModalResult := mrCancel;

Close;

End;

 

Procedure TUniLoginForm1.TryAgainBtnClick(Sender: TObject);

Begin

MessageArea.Visible := False

End;

Share this post


Link to post
Share on other sites

I think I could try something like this:

 

Procedure TUniLoginForm1.CreateBtnClick(Sender: TObject);
Begin
   ModalResult := mrNone;
   If (Email.Text <> '') And (Password.Text <> '') And (FName.Text <> '') And (LName.Text <> '') Then
   Begin
      Try
         UniMainModule.Account := CreateAccount(Email.Text, Password.Text, FName.Text, LName.Text, 0);
         ModalResult := mrOK;
         Close;
      Except
         messagedlg('That account already exists',mtWarning,[mbOK]);
      End;
   End else
    messagedlg('...',mtWarning,[mbOK]);
End;
 

 

Procedure TUniLoginForm1.LoginBtnClick(Sender: TObject);
Begin
     Try
        ModalResult := mrNone;
        UniMainModule.Account := LoadAccount(EmailEntry.Text, PassEntry.Text);
        ModalResult := mrOK;
        Close;
     Except
        messagedlg('The account or the password is in error',mtWarning,[mbOK]);
     End;
End;
 

Share this post


Link to post
Share on other sites

Thank you for your reply.  However, my problem remains. In the code shown below, I still get to the MessageDlg line and the main program is invoked (which causes a problem, since the account object is used in the creation of the main form), the message isn't presented until the main form is created.

 

Procedure TUniLoginForm1.LoginBtnClick(Sender: TObject);
Begin
ModalResult := mrNone;
If AccountExtant(EmailEntry.Text, PassEntry.Text) Then
   Begin
   UniMainModule.Account := LoadAccount(EmailEntry.Text, PassEntry.Text);
   ModalResult := mrOK;
   Close;
   End
Else
   messagedlg('The account or the password is in error', mtWarning, [mbOK]);
End;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×