Как узнать текущую позицию "scroll"-а, и в какую сторону она крутится? - VB
Формулировка задачи:
я хочу написать программу в котором исползовалось Scroll (средняя кнопка мыши). помогите люди добрые !!!!!!!!!!
Решение задачи: «Как узнать текущую позицию "scroll"-а, и в какую сторону она крутится?»
textual
Листинг программы
'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
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д