我需要寫在VB.NET代碼示例來捕獲鼠標滾輪滾動事件形式使用具有user32.dll中和WM_MOUSEWHEEL低電平鉤外像通過漢斯帕桑特所述回答我的其他問題:Record mouse Middle button and wheel scrollSetWindowsHookEx函數爲WM_MOUSEWHEEL
這是什麼,我需要做的僞例如:
Dim mousewheel_up as boolean
Dim mousewheel_down as boolean
Sub that Overides the windows messages to set the mousewheel booleans
If mousewheel_up then msgbox("MouseWheel up")
If mousewheel_down then msgbox("MouseWheel down")
End sub
UPDATE
試過,但它只能在表單內,也不知如何獲得增量值:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Application.AddMessageFilter(New MouseWheelMessageFilter())
End Sub
Public Class MouseWheelMessageFilter : Implements IMessageFilter
Public Function PreFilterMessage1(ByRef m As Message) As Boolean Implements IMessageFilter.PreFilterMessage
' Filter out WM_MOUSEWHEEL messages, which raise the MouseWheel event,
' whenever the Ctrl key is pressed. Otherwise, let them through.
Const WM_MOUSEWHEEL As Integer = &H20A
'If m.Msg = WM_MOUSEWHEEL & My.Computer.Keyboard.CtrlKeyDown Then
If m.Msg = WM_MOUSEWHEEL Then
' Process the message here.
If Form.ActiveForm IsNot Nothing Then
MsgBox("Mouse scrolled!")
' TODO: Insert your code here to adjust the size of the active form.
' As shown above in the If statement, you can retrieve the form that
' is currently active using the static Form.ActiveForm property.
' ...
End If
Return True ' swallow this particular message
End If
Return False ' but let all other messages through
End Function
End Class
這裏有一個[主題](HTTP://社會。 msdn.microsoft.com/Forums/en-US/vblanguage/thread/5f9a962e-8bb8-455f-8f21-9841c962721b)的帖子中有代碼,應該做你想做的。 – tinstaafl