Ian Branch 127 Posted May 2 Hi Team, I have the following procedure. procedure TLogInForm.edtUserIDExit(Sender: TObject); begin // if Trim(edtUserID.Text) = '' then begin TaskMessageDlg('User ID Error!', 'A User ID is required to be entered.', mtError, [mbOK], 0); edtUserID.SetFocus; end; // end; The procedure is in a home brew Log in Dialog. It works fine, with one exception, If I click Cancel on the form and edtUserID is empty, of course the event fires. How do I bypass/negate the event if btnCancel is clicked when edtUserID is empty? Regards & TIA, Ian Share this post Link to post
DelphiUdIT 176 Posted May 2 My uses are to do all controls at the exit of the dialogs. In that point I can control all (for example incompatibility between choose selection or settings, set value, etc ...) and report to user what he should do. I really don't know how to resolve your issue. Share this post Link to post
Anders Melander 1783 Posted May 2 You really shouldn't prevent the user from moving the focus; It's one of the most annoying ways to do validation. Instead do your validation in the OK handler. If you use TActionList you can also do the validation in the OnUpdate event handler and only enable the OK button when all validations pass. If you want to be really nice to your users do the validation while they are entering data but instead of blocking them just indicate errors with color or a symbol. 2 Share this post Link to post
Ian Branch 127 Posted May 2 Hi Guys, Thank you for your inputs. I have moved the handling to the OK button. All good now. Regards, Ian Share this post Link to post