可以通过修改Tapplication的OnException事件来实现,具体做法如下:
1?在Form1的类中声明一个过程Myexception,该过程与Tapplication的OnException
事件有相同的参数:
public
{ Public declarations }
procedure MyException(Sender:TObject;E:Exception);
2.编写该过程代码:
procedure TForm1.MyException(Sender:TObject;E:Exception);
begin
if E is EDBEditError then
showmessage(′输入不符合规则′)
else
Application.ShowException(E); {调用缺省的异常处理}
end;
3.在Form1的OnCreate事件中为Tapplication的OnException事件赋值:
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnException :=MyException;
end;