Solved

changing the effect of the <Enter> key ...

Posted on 1998-02-10
2
162 Views
Last Modified: 2010-04-04
hi

in a form, how do i make the <enter> key have the same effect as the <tab> key, ie to move the focus from the current field/control to the next field/control? is there an environment setting i can configure?

Cheers
Keith
0
Comment
Question by:keithcsl
2 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 20 total points
ID: 1358921
This code is from LLoyd's help file:

Enter as Tab

Q:  How do I make it so that when the user hits <enter>, it goes to the next object as though he had hit the tab key?

A:  You need to trap the keystroke and set up your own response to it.  Try this:

procedure TMainForm.FormCreate(Sender: TObject);
begin
  keyPreview := true; {To turn the event "ON".}
end;

procedure TMainForm.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    Key := #0;
    PostMessage(Handle, WM_NEXTDLGCTL, 0, 0);{next control}
    {PostMessage(Handle, WM_NextDLGCTL, 1, 0);} {previous control}

  end;
end;

{ This code came from Lloyd's help file! }
0
 
LVL 1

Author Comment

by:keithcsl
ID: 1358922
TA! just what I needed

But it's kinda troublesome if u want the effect on many forms, have to enter the same code again and again. pity there isn't an environment setting for it, like in Access97...

Cheers
Keith
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Path  to current project in Delphi. 2 80
Delphi cmd execution 6 60
indy Tmemory stream non latin charcter issue 2 111
SUM 2 INTEGER ARRAYS INTO 1 10 100
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question