异常处理(20分)

  • 主题发起人 主题发起人 sundayyoung
  • 开始时间 开始时间
S

sundayyoung

Unregistered / Unconfirmed
GUEST, unregistred user!
如何使用ApplicationEvents来捕获异常,最好能给一个简单的示例,谢谢!
 
1.

Declare your custom exception handler:
eklariere den eigenen globalen Exception Handler:
}


{ Public declarations }
procedure MyExceptionHandler(Sender : TObject; E : Exception );


{2.

Define your exception handler in the "implementation" section:
In den Implementations-Abschnitt kommt dieser Code:
}

procedure TForm1.MyExceptionHandler(Sender : TObject; E : Exception );
begin
MessageDlg('ERROR: ' + E.Message);
end;


{3.

Assign the created exception handler to your application's OnException event.
Weise dem OnException Ereignis den eigenen Exception Handler zu.
}

procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnException := MyExceptionHandler;
end;
 
后退
顶部