dionel1969 Posted August 2, 2011 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
Administrators Farshad Mohajeri Posted August 3, 2011 Administrators Posted August 3, 2011 Not possible yet. Logged #1111 Quote
thecrgrt Posted August 3, 2011 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
Administrators Farshad Mohajeri Posted August 3, 2011 Administrators 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
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.