如何重载TAB 处理事件!  TAB 默任处理的事件是焦点的却换,而我需要处理自己的事件,如何解决.谢谢!

解决方案 »

  1.   

    你在窗体上放一个ApplicationEventsprocedure TformMain.ApplicationEvents1Message(var Msg: tagMSG;
      var Handled: Boolean);
    begin
      if Msg.wParam= VK_Tab then Begin
          'do something you want;
         Handled:=True;
      end;
    end;
      

  2.   

    可是为什么会处理两遍呢?
    procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
      var Handled: Boolean);
    begin
        if msg.wParam=vk_tab then Form1.Caption:=Form1.Caption+'a';
    end;
      

  3.   

    procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
      var Handled: Boolean);
    begin
        if msg.wParam=vk_tab then Form1.Caption:=Form1.Caption+'a';
        handled:=true;
    end;同样还是处理了两遍,而且在有多个空间的窗体上移动老鼠,还处理这个事件!
      

  4.   

    改成这样就可以了
     if (msg.wParam=vk_tab) and (msg.message=256) then
      

  5.   

    下面两种都可以
    if (msg.wParam=vk_tab) and (msg.message=WM_KeyDown) then
    if (msg.wParam=9) and (msg.message=256) then
      

  6.   

    //灵活一点兄弟, 这样改
    procedure TForm1.apevt1Message(var Msg: tagMSG; var Handled: Boolean);
    begin
      //msg.lParam:=983041 或 (Msg.lParam and (1 shl 30)<>0 )
      if (msg.wParam=vk_tab) and (Msg.lParam and (1 shl 30)<>0 )  then begin
        Form1.Caption:=Form1.Caption+'a';
        handled:=true;
      end;
    end;