我是一名从VB转DELPHI的新手,有一问题不知怎么解决,向在VB中处理异常问题一样,
我的代码如下:
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if opendialog1.Execute then begin
animate1.FileName:=opendialog1.FileName;
animate1.Active :=true;
end;
end;
用播放动画控件播一个动画,当正确选AVI文件是没问题,如果选一个非AVI文件是会出错不知怎么让程序能给出一个出错提示,像在VB中一样可以捕捉出错代码一样,
还有在其它DELPHI程序中怎么处理程序异常。
谢谢各位了我在线等待
我的代码如下:
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if opendialog1.Execute then begin
animate1.FileName:=opendialog1.FileName;
animate1.Active :=true;
end;
end;
用播放动画控件播一个动画,当正确选AVI文件是没问题,如果选一个非AVI文件是会出错不知怎么让程序能给出一个出错提示,像在VB中一样可以捕捉出错代码一样,
还有在其它DELPHI程序中怎么处理程序异常。
谢谢各位了我在线等待
begin
if opendialog1.Execute then begin
animate1.FileName:=opendialog1.FileName;
try
animate1.Active :=true;
except
on e:exception do//如果不打算写错误信息,on exception do 就可以了。
begin
错误处理代码
' end;
end;
end;
end;
这条语句为什么不正确?
用showmessage或messagedlg之类吧.
messagedlg(e.message,mtError,[mbOK],0)
在开发环境中,错误还是会出来的。delphi就是这样。
麻烦您了能不能再回复我
begin
if opendialog1.Execute then begin
animate1.FileName:=opendialog1.FileName;
try
animate1.Active :=true;
except
on e:exception do//如果不打算写错误信息,on exception do 就可以了。
begin
messagedlg(‘This is a error’,mtError,[mbOK],0);
exit;' end;
end;
end;
end;
if opendialog1.Execute then
begin
animate1.FileName:=opendialog1.FileName;
animate1.Active :=true;
end;
except
on e:exception do
showmessage('invalid kind');
end;
没有什么设置问题。
睡觉了。。
你哪个代码没问题。
问题解决了,也谢谢xie_lin_feng(大禹)