Jump to content

The best way to exit from app...


dionel1969
 Share

Recommended Posts

Hello !!!

 

In some applications that I made the user need a validation from app, then if the validation is Ok the user can work with the main form and it's options, if the validation return error (not enough permissions, invalid user or password, etc...), the application must be closed, but I show before an Error Message. In the case of web mode it does not appear caused by thread management. I need to present the error message in the last page the application show. I tried to use an exception way, but after that the application does not terminate and the main form still shown.

 


procedure TStandardMainForm.CloseApplicationWithError(aErrorMsg: String);
begin
 Raise TException.Create(aErrorMsg);
 Close; // It does not close MainForm
 UniApplication.Terminate; // I use it before than close, anyway
end;

 

Then my questions are: how can I do that??? Which is the best way to do that???

 

Thank you for your time.

Link to comment
Share on other sites

Then my questions are: how can I do that??? Which is the best way to do that???

 

Thank you for your time.

You can workaround by creating custom html code and dynamically add it into UniServerModule.ServerMessages.TerminateTemplate.

 

Example:

 if ((WebMode) and (UserID = '')) then
 begin
   UniServerModule.ServerMessages.TerminateTemplate.Text :=
     '<html> ' +
     '<body bgcolor="#E6E6FA"> ' +
     '<p style="text-align:center;color:#0000A0">Authentication was needed for this application,</p> ' +
     '<p style="text-align:center;color:#0000A0">please sign-on using main application.</p> <br>' +
     '</body> ' +
     '</html>';
   UniApplication.Terminate();
   Exit;
 end;

PS. The Close() method of Form is no longer needed when UniApplication.Terminate() was called.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...