Jump to content


Photo

How to present error message in login screen

login

  • Please log in to reply
8 replies to this topic

#1 sysjames

sysjames

    Member

  • uniGUI Subscriber
  • PipPip
  • 14 posts
  • LocationTexas

Posted 22 September 2017 - 12:06 AM

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.

 

 

Attached Files


  • 0

#2 herculanojs

herculanojs

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 342 posts
  • LocationCuiabá-Brasil

Posted 22 September 2017 - 01:42 AM

Can you post the code or part of the code that is trying to do this?

 

Have already taken a look at the examples, specifically Dialogs


  • 0

#3 sysjames

sysjames

    Member

  • uniGUI Subscriber
  • PipPip
  • 14 posts
  • LocationTexas

Posted 22 September 2017 - 03:08 AM

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;

  • 0

#4 herculanojs

herculanojs

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 342 posts
  • LocationCuiabá-Brasil

Posted 22 September 2017 - 03:22 AM

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;
 

  • 0

#5 sysjames

sysjames

    Member

  • uniGUI Subscriber
  • PipPip
  • 14 posts
  • LocationTexas

Posted 22 September 2017 - 03:28 PM

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;

  • 0

#6 herculanojs

herculanojs

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 342 posts
  • LocationCuiabá-Brasil

Posted 22 September 2017 - 03:34 PM

Ok, I'll prepare an example here and already put it for you


  • 0

#7 herculanojs

herculanojs

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 342 posts
  • LocationCuiabá-Brasil

Posted 22 September 2017 - 04:28 PM

Follow example

Attached Files


  • 1

#8 sysjames

sysjames

    Member

  • uniGUI Subscriber
  • PipPip
  • 14 posts
  • LocationTexas

Posted 23 September 2017 - 04:57 PM

Thank you so much!  The sample has really been helpful.

 

Thanks again!


  • 0

#9 herculanojs

herculanojs

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 342 posts
  • LocationCuiabá-Brasil

Posted 23 September 2017 - 04:59 PM

cool


  • 0





Also tagged with one or more of these keywords: login

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users