Solved

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

Posted on 1998-02-10
2
160 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now