formsdelphidelphi-7

OnKeyPress for Escape closes form by default


How to have every newly created form in my application have implemented an OnKeyPress procedure and KeyPreview set to True?

I wish not to constantly add the procedure to the OnKeyPress event and set the KeyPreview to True manually.


Solution

  • The best way I found is to create a template of a form and add it to the repository. Afterwards, set it as a "New form" in the repository.

    In this case whenever you create a new form it will be that very template. All you have to do is change the name and caption.

    This helped me in Delphi 7.