Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onkeypress and onkeydown

Status
Not open for further replies.

hayate

Programmer
May 17, 2003
7
JP
Hi,
Sorry for asking a stupid question.But I'm really confused.

In OnkeyPress, this code works properly.
if Key = #13 then Key := #0;

But these code in OnKeyDown don't work. Why?
if Key = Ord('a') then Key := 0;
if Key = VK_ENTER then Key := 0;

Of course KeyPreview = True.

Thanks in advance.


 
These events are in response to the windows messages WM_KEYDOWN and WM_CHAR. Stopping the KeyDown will not stop the KeyPress.

The choice of which one to stop comes down to what behavior you are trying to stop. In other words, the code you are trying to avoid is on some control's KeyDown or KeyPress; you just have to ':= #0' on the correct one.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top