dionel1969 Posted August 2, 2011 Share Posted August 2, 2011 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. Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted August 3, 2011 Administrators Share Posted August 3, 2011 Not possible yet. Logged #1111 Quote Link to comment Share on other sites More sharing options...
thecrgrt Posted August 3, 2011 Share Posted August 3, 2011 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. Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted August 3, 2011 Administrators Share Posted August 3, 2011 Yes, you can modify templates before you exit but this will affect all other sessions too since they all share same template. My solution will be: UniApplication.Terminate('Message'); Quote Link to comment Share on other sites More sharing options...
dionel1969 Posted August 3, 2011 Author Share Posted August 3, 2011 Ok, thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.