如题

解决方案 »

  1.   

    可以用热键:unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Edit1: TEdit;
        Edit2: TEdit;
        procedure FormCreate(Sender: TObject);
        procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
      private
        { Private declarations }
        procedure HotKeyPressed(var Msg:TMessage); message WM_HOTKEY;
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementationvar
      HotKeyID: Word;{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
    begin
      HotKeyID := GlobalAddAtom(PChar(Application.Title + 'TAB'));
      if RegisterHotKey(Handle, HotKeyID, 0, VK_TAB ) = False then
        ShowMessage('注册热键TAB失败!');end;procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
      UnregisterHotKey(Handle, HotKeyID);
      DeleteAtom(HotKeyID);
    end;procedure TForm1.HotKeyPressed(var Msg: TMessage);
    var
      M: tagMsg;
    begin
      case Msg.LParamHi of
        VK_TAB: { TAB }
          begin
            ShowMessage('Tab pressed on ' + ActiveControl.Name);
          end;
      end;
    end;end.
      

  2.   

    edit you code in keypress event
      

  3.   

    to :whbo(王红波)  keypress事件中无法获得
    to :DDGG(叮叮当当) 
    你那样是可以捕获窗体的
    我要的是窗体上所有的EDIT的按下TAB键的事件
    谢谢
      

  4.   

    在窗体的keypress 编辑 判断是否按下TAB键
    然后将窗体的keypreview 属性设为true
      

  5.   

    TO: Aioros() 
    你可以试试运行我上面的那段代码,能够识别TAB键来自哪个控件的。TO: sally612
    OnKeyPress事件不能捕捉TAB键。
      

  6.   

    to: DDGG(叮叮当当) 
    你的代码可以
    谢谢  等等结帐不过我想能不能只捕获
    Edit的
      

  7.   

    memo有个wanttab属性,就是决定memo中是否可以输入tab键。memo是从CustomEdit继承的,你看一下源代码,应该有参考价值
      

  8.   

    在onkeypress里if key=(tab的ascii码) then
     begin
     ....
     end;
      

  9.   

    楼上的在onkeypress事件里得不到TAB事件