If I have an onKeyPress event, so I can call it with

var theKey : Char;
....
theKey := #13;  // ENTER key
FormKeyPress(Sender,theKey);

How to call the same way if I have an onKeyDown event ?

有帮助吗?

解决方案

It's totally wrong for you to want to do this, because keyboard events are designed to handle user input from the keyboard. You should be executing the code you want directly; you can also use that code from within your key events in response to user input, which clearly separates the user interface from the program logic.

With that being said, you can call the event the same way. For instance, to send Enter:

Key := 13;
FormKeyDown(Sender, Key, []);

To send CtrlK:

Key := Ord('K');
FormKeyDown(Sender, Key, [ssCtrl]);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top