Title: A practical way to do the (famous) 'Enter as Tab' substitution, for the whole app
Question: Users always ask for this functionality: Enter key functioning as Tab key (ie: jump to next input field); there's a number of ways to accomplish this, but I think this is the most practical (and centralized) one
Answer:
First, declare the following private proc. in your main form:
{--snip--}
procedure TMainForm.DoEnterAsTab(var Msg: TMsg; var Handled: Boolean);
begin
if Msg.Message = WM_KEYDOWN then
begin
if Msg.wParam = VK_RETURN then
Keybd_event(VK_TAB, 0, 0, 0);
end; //if
end;
{--snip--}
Now, all you have to do is: for the OnCreate event of the main form, code this assignment:
{--snip--}
Application.OnMessage := DoEnterAsTab;
{--snip--}
And there it is! every time the app receives the WM_KEYDOWN message, if the key is VK_RETURN (#13), we simulate a keyboard event, sending VK_TAB as parameter. It will work for the whole app, and you'll have no code repetition at all.