我是一名从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程序中怎么处理程序异常。
谢谢各位了我在线等待

解决方案 »

  1.   

    procedure TForm1.BitBtn1Click(Sender: TObject);
    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;
      

  2.   

    on E: Exception do ErrorDialog(E.Message, E.HelpContext)
    这条语句为什么不正确?
      

  3.   

    ErrorDialog 不是delphi 的函数吧?
    用showmessage或messagedlg之类吧.
      

  4.   


    messagedlg(e.message,mtError,[mbOK],0)
      

  5.   

    为什么我用了SHOWMESSAGE('NO')不能显示我的信息确只显示系统的错误信息
      

  6.   

    你用exe运行即可。
    在开发环境中,错误还是会出来的。delphi就是这样。
      

  7.   

    是的我用EXE执行了,还是不能显示我自定义的错误信息,
    麻烦您了能不能再回复我
      

  8.   

    运行EXE,在DELPHI的调试那是看不到这种效果是,系统先弹出错误提示的
      

  9.   

    procedure TForm1.BitBtn1Click(Sender: TObject);
    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;
      

  10.   

    try
        if opendialog1.Execute then
          begin
          animate1.FileName:=opendialog1.FileName;
            animate1.Active :=true;
          end;
       except
         on e:exception do
           showmessage('invalid kind');
       end;
      

  11.   

    用exe执行啊!!!
    没有什么设置问题。
    睡觉了。。
    你哪个代码没问题。
      

  12.   

    谢谢 yhq2002(yhq) 是对的
    问题解决了,也谢谢xie_lin_feng(大禹)