Monitor Key Press
Monitor Key Press
(OP)
More a general question:
I have a form with an TEdit attached. I want to determine the Text value of the TEdit when an <Enter> key is pressed. The value returned will either be an integer or 'T' or 'F'. I don't have the code for this... it's in a prelim stage. I want to access the information from a procedure or function that may or may not reside in the form unit.
The generated procedure is of the form:
procedure TMain_ScreenF.AnswerEKeyPress(Sender: TObject; var Key: Char);
and I'll be testing it for (27 = ord(key)) and if (13 = ord(key)) as well as T/F; the number is generally an integer.
Is there a better way to do this? I'd like to have the coding in a separate procedure or function that could access the keys pressed.
Any suggestions?
Dik
I have a form with an TEdit attached. I want to determine the Text value of the TEdit when an <Enter> key is pressed. The value returned will either be an integer or 'T' or 'F'. I don't have the code for this... it's in a prelim stage. I want to access the information from a procedure or function that may or may not reside in the form unit.
The generated procedure is of the form:
procedure TMain_ScreenF.AnswerEKeyPress(Sender: TObject; var Key: Char);
and I'll be testing it for (27 = ord(key)) and if (13 = ord(key)) as well as T/F; the number is generally an integer.
Is there a better way to do this? I'd like to have the coding in a separate procedure or function that could access the keys pressed.
Any suggestions?
Dik
RE: Monitor Key Press
RE: Monitor Key Press
Also found the GetKeyState funcion using it with VK_Return and am trying that approach.
Dik
RE: Monitor Key Press
CODE -->
The above does not seem to recognise the <Enter> key
Dik
RE: Monitor Key Press
RE: Monitor Key Press
Dik
CODE -->
Is it possible to write a function that accesses the information from the Edit.Text control from a procedure or function, monitoring the keys from the keypress action? I need the Edit box to only accept 0-9 and f, F, t, and T.
Dik
RE: Monitor Key Press
Yes, all this is possible, I'll try to put together something for you later, but first, which version of Delphi are you using?
RE: Monitor Key Press
Dik
RE: Monitor Key Press
Form1 talks to Form2 via a windows message, and form2 calls a PUBLIC function defined in Form1 to get the contents of the Edit Control
CODE
CODE
RE: Monitor Key Press
Dik
RE: Monitor Key Press
the content ( string ) of an Edit field was checked by specific routines, so to verify if the content verifies a mask
this could occur :
... on EditExit
... on general request, like when verifing each input field of a record, before adding the entity to the record
... on Enter
so build masks : i have some that detects if a content ( string ) is number, real number, number in range, alpanumeric chars, etc
after that, call those routines as you like
kindly !
RE: Monitor Key Press
Yup... just a matter of becoming more familiar with the program again... Something like:
if (Key in [8, 13, 27, 48..57, 96..105, 70, 84]) then
begin
thanks again, Dik
RE: Monitor Key Press
I'm having a bit of a problem; it's intermittent. Sometimes it transfers the text to form2 and sometimes not. Can you take a peek at this. The exe file has been removed... my computer is pretty secure.
Dik
RE: Monitor Key Press
if you want it to send the message ANY TIME the enter key is pressed, then you don't want to use Edit1's OnKeypress, you would use the FORM's OnKeyPress but then you would need to set the FORM's KeyPreview to True.
CODE
Now anytime the ENTER key is clicked, it'll send the message.
RE: Monitor Key Press
Dik
RE: Monitor Key Press
RE: Monitor Key Press
Dik