procedure Tform1.myExceptHandle(Sender : TObject; E : Exception);
begin//自定义的错误对话框
if Pos('valid date', E.Message) > 0 then
Application.MessageBox(' 不是合法或者无效的日期格式!', PChar(Application.Title), MB_ICONWarning + MB_OK)
else if Pos('Value out of bounds', E.Message) > 0 then
Application.MessageBox(' 数据超出范围!', PChar(Application.Title), MB_ICONWarning + MB_OK)
else if Pos('Cannot open file', E.Message) > 0 then
Application.MessageBox(' 不能打开文件!', PChar(Application.Title), MB_ICONWarning + MB_OK)
else
Application.ShowException(E);
end;
在formcreate时
Application.OnException :=Form1.MyExceptHandle;