Recent

Author Topic: how to replace error "... press cancel to kill the program"  (Read 13281 times)

atasoft

  • New Member
  • *
  • Posts: 33
how to replace error "... press cancel to kill the program"
« on: August 05, 2011, 05:26:25 pm »
In Lazarus program if a user writes something wrong on a component e.g. characters instead of date then Lazarus gives error: "... press ok to ignore and risk data corruption. press cancel to kill the program."

I do not want the user to be able to press cancel and kill the program. Is there a way to replace the above lazarus message with my one?

Thanks in advanced.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2584
Re: how to replace error "... press cancel to kill the program"
« Reply #1 on: August 05, 2011, 05:28:38 pm »
In Lazarus program if a user writes something wrong on a component e.g. characters instead of date then Lazarus gives error: "... press ok to ignore and risk data corruption. press cancel to kill the program."

I do not want the user to be able to press cancel and kill the program. Is there a way to replace the above lazarus message with my one?

Thanks in advanced.

iirc you have a handler to  Application.OnError
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: how to replace error "... press cancel to kill the program"
« Reply #2 on: August 05, 2011, 05:29:13 pm »
Hint: have a look at the try..except construction:  you can catch errors and deal with them, including showing your own messages...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

atasoft

  • New Member
  • *
  • Posts: 33
Re: how to replace error "... press cancel to kill the program"
« Reply #3 on: August 05, 2011, 06:08:25 pm »
Thanks marc,

Application.OnError does not exist but I used Application.OnException and it works. But I put it in one form, can I put it once for the whole application and how?

atasoft

  • New Member
  • *
  • Posts: 33
[DONE] Re: how to replace error "... press cancel to kill the program"
« Reply #4 on: August 05, 2011, 09:23:16 pm »
I wrote the Application.OnException in OnCreate of Datamodule of my application and it works perfectly. The user will not get anymore the default lazarus message "... press cancel to kill the program". Now my application on any error (e.g. mask error or database error) just shows the error message with only OK button.

 

TinyPortal © 2005-2018