I have a Delphi VCL form with many frames containing components. I want to detect an arrow key click in a the form so that I can move between frames that are graphically arranged in a matrix. Both Keypress and Keydown event handlers fail to respond to an arrow key press. I have created case elements for virtual keys in both methods but the event is not triggered by the arrow keys. How is this accomplished in Delphi?
Asked
Active
Viewed 608 times
1 Answers
4
Arrow keys are reserved by the OS for navigation purposes. UI controls do not receive window messages for arrow key presses unless they explicitly request it. You need to either:
handle the Win32
WM_GETDLGCODE
message and include theDLGC_WANTARROWS
flag in its return value.handle the VCL's custom
CM_DIALOGKEY
message.use a keyboard hook via the Win32
SetWindowsHookEx()
function.

Remy Lebeau
- 555,201
- 31
- 458
- 770