用Form的Wheel事件无法区分左右轮,还是上下轮,请问如何实现?

解决方案 »

  1.   

    好象是这样的:
    TMouseButton = (mbLeft, mbRight, mbMiddle);在控件的OnMouseDown、OnMouseUp、OnMouseMove 中用
      if Button in [mbLeft] then  //按下左键
      begin
        ...
      end;
      

  2.   

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/BestPracticesforSupportingMicrosoftMouseandKeyboardDevices.asp上面就是水平滚轮的使用,我大致看了一下,内容是这样的:Windows Longhorn直接支持水平滚轮Windows 2000 & XP 不直接支持水平滚轮, 但可以安装相应的IntelliType Pro或IntelliPoint 鼠标驱动程序来支持水平滚轮要捕捉的消息是WM_MOUSEHWHEEL //多一个H
    参数意义和WM_MOUSEWHEEL一样
      

  3.   

    谢谢大家的发言,可是好象没有解决我的问题。请大家继续讨论这个话题。因为在Word等大型软件中都能识别两轮鼠标上下,左右的滚动,方便大气!所以必须在软件中实现对滚轮的支持。还因为我们都习惯了用滚轮来操作。
      

  4.   

    嗬嗬,我这里没有所谓的4D鼠标,不能帮你测试。
    不过Word可以使用两个滚轮是在装驱动的前提下吗?
      

  5.   

    private
      Procedure OnMouseWheel(Var Msg :TMsg;var Handled:Boolean);
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    Procedure TForm1.OnMouseWheel(Var Msg :TMsg;var Handled:Boolean);
    begin
      if Msg.message = WM_MouseWheel then
      begin
        if Msg.wParam > 0 then
         begin
          showmessage('逆时针滚动');
         end
        else
         begin
           showmessage('顺时针滚动');
         end;
        Handled:= True;
      end;
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Application.OnMessage:=OnMouseWheel; // 截获鼠标滚动事件
    end;end.