What I want to do here is moving the text cursor back to the TDBEdit that caused this exception, after the error message is displayed.
There is no way to know which control raised the exception. But if the
TDBEdit was already focused when the exception is raised, I would expect it to regain the focus when the error dialog is closed.
I have tried the following code:
The
Sender of the
OnException event is not the control that raised the exception. It is usually the object that
caught the exception and called
TApplication.HandleException() to trigger the
OnException event.
HandleException() has a
Sender parameter that is passed to
OnException. That is *usually* the
TForm.
So, I find it a little odd that the
Sender is
nil instead. That means whichever object is calling
HandleException() is not identifying itself. What does the call stack look like when the exception is raised?