Nicolai1605,
Das Control mit dem Fokus (in deinem Fall TButton) verarbeitet keine Peiltasten Ereignisse.
"The key preview feature is a direct "echo" of the key events the active control sees
and controls will get only the key events they ask for."
Die Pfeiltasten kannst du über einen CM_DIALOGKEY handler abfangen.
// private Section
Delphi-Quellcode:
Procedure CMDialogKey(Var Msg: TWMKey); message CM_DIALOGKEY;
Procedure TForm1.CMDialogKey(Var Msg: TWMKEY);
Var
handled: Boolean;
Begin
handled := true;
Case msg.charcode of
VK_UP: Image1.Top := Image1.Top - 5;
VK_DOWN: Image1.Top := Image1.Top + 5;
VK_LEFT: Image1.Left := Image1.Left - 5;
VK_RIGHT: Image1.Left := Image1.Left + 5;
Else
handled := False
End;
If handled Then
msg.result := 1
Else
inherited;
End;