delphi - Why Application.OnException never runs? -


problem summary: method assigned application.onexception never runs when unhandled exception occurs.

i create blank project unit , place single button on unit.dfm (this based on official example) :

// unit1.pas // *********  type tform1 = class(tform)     button1: tbutton;     procedure formcreate(sender: tobject);     procedure appexception(sender: tobject; e: exception);     procedure button1click(sender: tobject); end;  var form1: tform1;  implementation  {$r *.dfm}  procedure tform1.formcreate(sender: tobject); begin     application.onexception := appexception; end;  procedure tform1.appexception(sender: tobject; e: exception); begin     application.terminate; end;  procedure tform1.button1click(sender: tobject); begin     raise exception.create('incorrect password entered'); end; 

then set breakpoint inside tform1.appexception(). run program, click button, error dialog shown saying "incorrect password entered" if continue execution breakpoint never breaks; program doesn't terminate asked too. program continues running , can press button again.

i tried same code (adapted) in delphi 7 same result encountered.

the rational explanation formcreate not executing. need assign form's oncreate event handler. use object inspector so.


Comments

Popular posts from this blog

java - BeanIO write annotated class to fixedlength -

Using Java 8 lambdas/transformations to combine and flatten two Maps -

How to connect android app to App engine -