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 展开
'模块
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 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询