Board index » delphi » Enter-key working as the tab-key ?

Enter-key working as the tab-key ?

Probably a trivial question, but how do you make the enter-key work
like the tab key - for example in an edit-box, where I would like
the focus brought from one edit-component to another component after
pressing the enter-key. I=B4ve tried using =B4focus=B4 but it seems
as if the enter command is passed on to the next component, and that
is not always what I intend to do.

Nordlyng

 

Re:Enter-key working as the tab-key ?


In article <32490FC0....@kemi.aau.dk>,
   Soren Nordlyng <nordl...@kemi.aau.dk> wrote:
]-Probably a trivial question, but how do you make the enter-key work
]-like the tab key - for example in an edit-box, where I would like
]-the focus brought from one edit-component to another component after
]-pressing the enter-key. Ive tried using focus but it seems
]-as if the enter command is passed on to the next component, and that
]-is not always what I intend to do.
]-
]-Nordlyng

set the form's KeyPreview property to TRUE and use this
code for the OnKeyPress event...

  procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
    begin
      if Key = #13 then
        begin
          Key := #0;
          PostMessage(Handle, WM_NEXTDLGCTL, 0, 0);
        end;
    end;

Mark Vaughan

Other Threads