Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7896199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:49:54+00:00 2026-06-03T07:49:54+00:00

I need to intercept the TAB keyboard stroke on TEdits and suppress them programmatically.

  • 0

I need to intercept the TAB keyboard stroke on TEdits and suppress them programmatically.
In certain cases I don’t want the focus to change to the next control.

I tried to handle KeyPress, KeyDown both on TEdit level and on TForm with KeyPreview=true.
I’ve peeked advices from:

  • Intercept TAB key in RichEdit
  • How do I make the TAB key close a TComboBox without losing the current position?

But it didn’t work.
The events are fired for, let’s say, the Enter key BUT not for the TAB key.

I’m using Delphi 7.
Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:49:55+00:00Added an answer on June 3, 2026 at 7:49 am

    If you want to intercept the TAB key behavior, you should catch the CM_DIALOGKEY message. In this example, if you set the YouWantToInterceptTab boolean value to True, the TAB key will be eaten:

    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    
    type
      TForm1 = class(TForm)
      private
        YouWantToInterceptTab: Boolean;
        procedure CMDialogKey(var AMessage: TCMDialogKey); message CM_DIALOGKEY;
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.CMDialogKey(var AMessage: TCMDialogKey);
    begin
      if AMessage.CharCode = VK_TAB then
      begin
        ShowMessage('TAB key has been pressed in ' + ActiveControl.Name);
    
        if YouWantToInterceptTab then
        begin
          ShowMessage('TAB key will be eaten');
          AMessage.Result := 1;
        end
        else
          inherited;        
      end
      else
        inherited;
    end;
    
    end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to intercept the calls to all the method calls to an Interface.
Where can I intercept reads and updates for scaffolded tables? I need to make
I need to change the firefox window title like I would do for internet
I already have the popup opening in a new tab. I need to know
I am using the Unity IoC container, and I need to intercept any calls
I have a web page with some links, and I need to intercept the
To implement a tab-based environment in WPF we need to convert our forms to
Is there an equivalent of EndpointInterceptorAdapter for the client? Because i need to intercept
I an developing a WCF service where I need to intercept incoming messages for
I am building a fairly simple CMS. I need to intercept requests for the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.