?
Solved

How to catch tab key press

Posted on 1997-04-23
4
Medium Priority
?
235 Views
Last Modified: 2010-04-04
I'd like to know when the user presses the tab key in my form.  It would a nice bonus to know which control the user was in when the tab key was pressed
0
Comment
Question by:bperry
[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
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
sperling earned 400 total points
ID: 1335687
Declare this procedure in your forms "private" section:

procedure AppMessage (var msg : TMessage; var Handled : BOOLEAN);

procedure TForm1.AppMessage (var msg : TMsg; var Handled : BOOLEAN);
begin
  if (msg.message=WM_KEYDOWN) and (msg.wParam=VK_TAB) then begin
    // TAB was pressed in some form.
    if Screen.Forms[0] = Self then begin
      // TAB was pressed in this form
      if ActiveControl<>nil then begin
        // ActiveControl.Name = Name of control that has focus
      end;
    end;
  end;
end;


in the form OnCreate event:
  Application.OnMessage := AppMessage;


Regards,

Erik.
0
 

Author Comment

by:bperry
ID: 1335688
The line above should be

 procedure AppMessage (var msg : TMsg;  ...

not

procedure AppMessage (var msg : TMessage

But otherwise it's perfect.
0
 

Author Comment

by:bperry
ID: 1335689
The line above should be

procedure AppMessage (var msg : TMsg;  ...

not

procedure AppMessage (var msg : TMessage

But otherwise it's perfect.
0
 
LVL 3

Expert Comment

by:sperling
ID: 1335690
Oops...

That's what happens when I modify the code after pasting it into Netscape ;)

Erik.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
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 Month10 days, 21 hours left to enroll

770 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