We help IT Professionals succeed at work.

Trap Tab keypress in TEdit control

vterekh
vterekh asked
on
Hi

Is it possible to trap Tab keypress in the TEdit.

I tried to intercept wm_char or wm_keydown but it doesn't work.
Comment
Watch Question

Commented:
hi,
you can catch it like so:
Regards Barry

  private
    { Private declarations }
    procedure TabKey( Var msg: TCMDialogKey ); message CM_DIALOGKEY;

  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.TabKey(var msg: TCMDialogKey);
begin
  if msg.Charcode <> VK_TAB then
   inherited;
end;


procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 if Key = VK_TAB then
    showmessage('tab pressed in edit');
end;

Commented:
?

Author

Commented:
Thanks, Barry
There is a better way.  See how TInplaceEdit responds to WM_GETDLGCODE in Grids.pas Delphi5\source\vcl

Explore More ContentExplore courses, solutions, and other research materials related to this topic.