Reputation: 14845
I'm using a third part component to create masks in Delphi using regular expressions, the problem is if value entered does not match the mask when the user live the edit box the component raise an exception and I don't know how to catch it as the exception happens in an event inside the third part component.
How can I catch and handle this kind of exception? As I can't have a try block around it?
Upvotes: 0
Views: 611
Reputation: 12292
To change the behavior of a component, you should create a new component inheriting from the initial component. In the new component, you override the methods that needs to have another behavior.
However, this is not always possible, depending on how well the component has been written.
For example, there could be an EditExitHandler that handle what happens when the edit is leaved. In your inherited component, you would write something like:
procedure TMyComponent.EditExitHandler(Sender : TObject);
begin
try
inherited EditExeitHandler(Sender);
except
// Add code here to handle the exception which annoys you
end;
end;
Upvotes: 4
Reputation: 235
You can use TApplicationEvents.OnException event. It will be called whenever unhandled exception is raised while app is running.
Upvotes: 0