Solved

Capture Enter Key in Editbox to close modal form

Posted on 2007-11-14
3
989 Views
Last Modified: 2012-06-27
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
Comment
Question by:SantaRosa
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
rfwoolf earned 500 total points
ID: 20279253
Use the keyeevent to set the modal result of your form to something other than 0, e.g.
form2.ModalResult := 1;
0
 
LVL 13

Assisted Solution

by:rfwoolf
rfwoolf earned 500 total points
ID: 20279267
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
 

Author Comment

by:SantaRosa
ID: 20279336
I had submitted the question. Both solutions work easily. Turn around time was terrific. Thankyou.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now