Mega Code Archive

 
Categories / Delphi / Examples
 

Jump to the next control on enter

Title: Jump to the next control on enter Question: I would like to tranform the RETURN key into a TAB key. When the user is pressing RETURN the cursor should jump to the next control. The default button should not be executed. Answer: This code works when there is no default button and Form.KeyPreview is set to true. RETURN jumps to the next control and SHIFT+RETURN to the prior one: procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin Key := #0; {schaltet den lstigen Beep ab} if GetKeyState(VK_Shift) and $8000 0 then PostMessage(Form1.Handle, WM_NEXTDLGCTL, 1, 0) else PostMessage(Form1.Handle, WM_NEXTDLGCTL, 0, 0); end; end;