有没有能获得鼠标滚轮事件的API或方法

解决方案 »

  1.   

    用子类拦截窗口WM_MOUSEWHEEL消息
    WM_MOUSEWHEEL
    The WM_MOUSEWHEEL message is sent to the focus window when the mouse wheel is rotated. The DefWindowProc function propagates the message to the window's parent. There should be no internal forwarding of the message, since DefWindowProc propagates it up the parent chain until it finds a window that processes it.WM_MOUSEWHEEL
    fwKeys = LOWORD(wParam);    // key flags
    zDelta = (short) HIWORD(wParam);    // wheel rotation
    xPos = (short) LOWORD(lParam);    // horizontal position of pointer
    yPos = (short) HIWORD(lParam);    // vertical position of pointer
     
    Parameters
    fwKeys 
    Value of the low-order word of wParam. Indicates whether various virtual keys are down. This parameter can be any combination of the following values: Value Description 
    MK_CONTROL Set if the ctrl key is down. 
    MK_LBUTTON Set if the left mouse button is down. 
    MK_MBUTTON Set if the middle mouse button is down. 
    MK_RBUTTON Set if the right mouse button is down. 
    MK_SHIFT Set if the shift key is down. 
    zDelta 
    The value of the high-order word of wParam. Indicates the distance that the wheel is rotated, expressed in multiples or divisions of WHEEL_DELTA, which is 120. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. 
    xPos 
    Value of the low-order word of lParam. Specifies the x-coordinate of the pointer, relative to the upper-left corner of the screen. 
    yPos 
    Value of the high-order word of lParam. Specifies the y-coordinate of the pointer, relative to the upper-left corner of the screen. 
    Res
    The zDelta parameter will be a multiple of WHEEL_DELTA, which is set at 120. This is the threshold for action to be taken, and one such action (for example, scrolling one increment) should occur for each delta.The delta was set to 120 to allow Microsoft or other vendors to build finer-resolution wheels in the future, including perhaps a freely-rotating wheel with no notches. The expectation is that such a device would send more messages per rotation, but with a smaller value in each message. To support this possibility, you should either add the incoming delta values until WHEEL_DELTA is reached (so for a given delta-rotation you get the same response), or scroll partial lines in response to the more frequent messages. You could also choose your scroll granularity and accumulate deltas until it is reached.QuickInfo
      Windows NT: Requires version 4.0 or later.
      Windows: Requires Windows 98.
      Windows CE: Unsupported.
      Header: Declared in winuser.h.
      

  2.   

    当拨动滚轮的时候,Windows系统会发送WM_MOUSEWHEEL给前台窗口
    由于VB没有将该消息应设成事件,所以得自己用子类技术拦截窗口消息可以在讲解API的书上看到子类技术的具体方法
    从头说起那太复杂了
      

  3.   

    Longhorn 里还支持新的 WM_MOUSEHWHEEL 消息。
      

  4.   

    去 http://www.eightbird.com/ 看一下 typhoonGraph.ocx 控件是否适合用。发表些意见,则会免费。
      

  5.   

    To baniao2002(八鸟)
    广告真恶心啊  每个帖子都有  卖东西怎么到这来卖了  什么垃圾免费 找钱给我我都不要
      

  6.   

    to baniao2002(八鸟) : GOD DAMN IT!
      

  7.   

    http://www.m5home.com/bbs/dispbbs.asp?boardID=2&ID=22&page=1这里有个例子,以前写的,就是用的子类.PS:这个不算广告吧?????
      

  8.   

    以下为非官方资料,本人自己调试所得,请谨慎使用!使用前先保存
    自行声明:SetWindowLong、CallWindowProc
    在form_load中加入:
    PrevWndProc = SetWindowLong(Hwnd, -4, AddressOf myProc)在模块中加入:
    public PrevWndProc
    Function myProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Select Case Msg
    Case 522 'Scrool
         if wParam>0 then
         '向上滚
         else
         '向下滚
         end if
    End Select
    myProc = CallWindowProc(PrevWndProc, hwnd, Msg, wParam, lParam)
    End Function
      

  9.   

    public PrevWndProc as long
    更正一下另实际使用可参考使用sgn(wParam)
    向上滚=1
    向下滚=-1
    避免判断语句