Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 83
Virtuailstring tree compare node issue 14 105
Send message from delphi to whatsapp, is it possible? 3 1,187
Downloading email attachments 2 67
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

861 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

25 Experts available now in Live!

Get 1:1 Help Now