Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1005
  • Last Modified:

Capture Enter Key in Editbox to close modal form

I have a form that prompts for a password using an editbox on a modal form. The OK and Cancel buttons work fine to close the form and either continue or abort. I want to capture the Enter and Esc keys in the edit box to simulate the OK click and the Cancel click. I have put code in the keypress event. It calls the click event for the buttons, but then just sits there.
0
SantaRosa
Asked:
SantaRosa
  • 2
2 Solutions
 
rfwoolfCommented:
Use the keyeevent to set the modal result of your form to something other than 0, e.g.
form2.ModalResult := 1;
0
 
rfwoolfCommented:
I have a feeling that what you were doing wrong was you were calling the button's onclick event, e.g.
button1.OnClick(self);
instead of
button1.click;

OR... the other way round.

But I could be wrong... :P
0
 
SantaRosaAuthor Commented:
I had submitted the question. Both solutions work easily. Turn around time was terrific. Thankyou.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now