?
Solved

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

Posted on 1998-02-10
2
Medium Priority
?
170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 80 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month12 days, 19 hours left to enroll

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