vb6鼠标滚轮事件在win10下运行问题,高手进! 100

下面代码,在xp系统下,只要text1或text2控件获得焦点,鼠标在任何位置滚动滚轮都正常执行代码。但是,在win10系统下运行,当text1或text2获得焦点后,鼠... 下面代码,在xp系统下,只要text1或text2控件获得焦点,鼠标在任何位置滚动滚轮都正常执行代码。但是,在win10系统下运行,当text1或text2获得焦点后,鼠标必须在获得焦点的控件范围内,才能执行滚轮代码,离开后则不执行。求高手帮忙解决!谢谢!!!

'模块
Option Explicit

Public Const GWL_WNDPROC = (-4)

Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public prevWndProc As Long
Dim t As Boolean

Function WndProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = 522 Then
If wParam > 0 Then
If Form1.Label1.Caption = "1" Then
Form1.Text1.Text = Form1.Text1.Text + 1
Else
Form1.Text2.Text = Form1.Text2.Text + 1
End If
Else
If Form1.Label1.Caption = "1" Then
If Form1.Text1.Text > 0 Then Form1.Text1.Text = Form1.Text1.Text - 1
Else
If Form1.Text2.Text > 0 Then Form1.Text2.Text = Form1.Text2.Text - 1
End If
End If
End If
WndProc = CallWindowProc(prevWndProc, hWnd, Msg, wParam, lParam)

End Function
'窗体
Option Explicit

Private Sub Text1_GotFocus()
Label1.Caption = 1
Text1.Text = "0"
prevWndProc = GetWindowLong(Text1.hWnd, GWL_WNDPROC)
SetWindowLong Text1.hWnd, GWL_WNDPROC, AddressOf WndProc
End Sub

Private Sub Text1_LostFocus()
SetWindowLong Text1.hWnd, GWL_WNDPROC, prevWndProc
End Sub

Private Sub Text2_GotFocus()
Label1.Caption = 2
Text2.Text = "0"
prevWndProc = GetWindowLong(Text2.hWnd, GWL_WNDPROC)
SetWindowLong Text2.hWnd, GWL_WNDPROC, AddressOf WndProc
End Sub

Private Sub Text2_LostFocus()
SetWindowLong Text2.hWnd, GWL_WNDPROC, prevWndProc
End Sub
展开
 我来答
dyjs1968
2020-04-16 · TA获得超过365个赞
知道小有建树答主
回答量:959
采纳率:83%
帮助的人:63.7万
展开全部
xp下可以运行,Windows10下不可以。这个应是系统的问题,新系统运行时,需要用户控制那一项,用管理员运行一下,关闭用户账户控制也许会可以的。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式