|

楼主 |
发表于 2009-5-21 09:17:02
|
显示全部楼层
先定义private
{private declarations}
TempProc: TExceptionEvent;
Procedure MyExProc(Sender: Business.System.TObject; E: Business.System.Exception);
窗体运行时
procedure TJSDLRCK.BizFormCreate(Sender: TObject);
begin
TempProc:= Forms.Application.OnException ; //记录下原来的异常处理程序
Forms.Application.OnException:= MyExProc; //将异常处理程序改为自己的。
end;
在查询按钮事件底下,转换日期business.System.SysUtils.StrToDateTime(ComboBox1.Text);
再就是截获事件
procedure TJSDLRCK.MyExProc(Sender: Business.System.TObject; E: Business.System.Exception);
begin
if Business.System.StrUtils.AnsiContainsText(e.Message,'is not a valid date and time') then
begin
jsdialogs.ShowMsg('您输入的日期有误!','提示');
//在这里处理你需要处理的异常。Xxx为你要截获的异常的信息。
Edit1.Focused;
exit;
end;
Raise E; //对于不需要截获的异常照常抛出。
end; |
|