использование колесика на мышке
Прислал: smalig
Дата: 18.12.2000 18:53:20
Визитов: 235
Оценили: 4 [...]
Описание:
Пример использования мышки IntelliMouse в VB-приложениях
Текст:
'Global Declarations
Public Type POINTAPI
X As Long
Y As Long
End Type
Public Type MSG
hwnd As Long
message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type
Public Declare Function CallNextHookEx& Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Integer, lParam As Any)
Public Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Public Declare Function RegisterWindowMessage& Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String)
Public Declare Function SetWindowsHookEx& Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long)
Public Declare Function UnhookWindowsHookEx& Lib "user32" (ByVal hHook As Long)
Public Const WH_GETMESSAGE = 3
Public Const MSH_MOUSEWHEEL = "MSWHEEL_ROLLMSG"
Public IMWHEEL_MSG As Long
Public HWND_HOOK As Long
'Код
Public Function IMWheel(ByVal nCode As Long, ByVal wParam As Long, lParam As MSG) As Long
If lParam.message = IMWHEEL_MSG Then
Form1.WheelMoved lParam.wParam, lParam.pt.X, lParam.pt.Y
End If
IMWheel = CallNextHookEx(HWND_HOOK, nCode, wParam,
lParam)
End Function
Public Function IMWheel_Hook() As Long
IMWHEEL_MSG =
RegisterWindowMessage(MSH_MOUSEWHEEL)
HWND_HOOK = SetWindowsHookEx(WH_GETMESSAGE, _
AddressOf IMWheel, 0, GetCurrentThreadId)
End Function
Public Sub IMWheel_Unhook()
UnhookWindowsHookEx HWND_HOOK
End Sub
put this code In a form:
Option Explicit
Private Sub Form_Load()
IMWheel_Hook
End Sub
Public Sub WheelMoved(ByVal delta As Long, _
X As Long, Y As Long)
Debug.Print delta, X, Y
End Sub
Private Sub Form_Unload(Cancel As Integer)
IMWheel_Unhook
End Sub
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 21