提个问题
鼠标滚轮的滚动方向可以用VB或其他语言获取,VLISP怎么用"user32.dll"获取呢?
搜索了网页:大致获得下列信息
JavaScript(原文网址:http://www.fengfly.com/plus/view-67848-1.html)
- <html>
- <head>
- <title>JavaScript判断鼠标滚轮滚动方向- www.fengfly.com </title>
- <script type="text/javascript">
- function handle(delta) {
- var s = delta + ": ";
- if (delta <0)
- s += "您在向下滚……";
- else
- s += "您在向上滚……";
- document.getElementById('delta').innerHTML = s;
- }//from www.fengfly.com
- function wheel(event){
- var delta = 0;
- if (!event) event = window.event;
- if (event.wheelDelta) {
- delta = event.wheelDelta/120;
- if (window.opera) delta = -delta;
- } else if (event.detail) {
- delta = -event.detail/3;
- }
- if (delta)
- handle(delta);
- }
- /* www.fengfly.com */
- if (window.addEventListener)
- window.addEventListener('DOMMouseScroll', wheel, false);
- window.onmousewheel = document.onmousewheel = wheel;
- </script>
- </head>
- <body>
- <div id="delta">滚动中轮试试~请选按着中轮滚动,激活后可以不按,直接滚动。</div>
- </body>
- </html>
复制代码
MSDN帮助
- 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
- ...
- //Zdelta为负向前滚动,为正向后滚动
复制代码
VB6.0写法

- Private Type MSLLHOOKSTRUCT '鼠标HOOK时lParam指针指向的结构
- pt As POINTAPI
- dwMouseData As Long
- dwFlags As Long
- dwTime As Long
- dwExtraInfo As Long
- End Type
- Private Const WM_MOUSEWHEEL As Long = &H20A
- Private Sub objHookLL_MouseHook(ByVal Code As Long, ByVal wParam As Long, ByVal lParam As Long, lRet As Long)
- '鼠标HOOK事件.
- '要吃了当前消息,把lRet = -1即可.
- If Code = HC_ACTION And wParam = WM_MOUSEWHEEL Then
- Dim stMLL As MSLLHOOKSTRUCT
- Call CopyMemory(ByVal VarPtr(stMLL), ByVal lParam, Len(stMLL))
- With stMLL
- Debug.Print .dwMouseData / 65536 '输出滚轮状态
- '在这里可以得到鼠标坐标以及其它信息
- End With
- End If
- txtMCode.Text = Code
- txtMwParam.Text = wParam
- txtMlParam.Text = lParam
- Debug.Print " M = " & Code, wParam, lParam
- End Sub
|