'模块中:
Option Explicit
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private 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
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_MOUSEWHEEL As Long = &H20A
Private Const GWL_WNDPROC = (-4)
Private PrevWndProc As Long
Public Function SubWndProc(ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case msg '在这里进行过滤.如果知道其他的消息,也可以在这里过滤.
Case WM_MOUSEWHEEL
SubWndProc = 1 '屏蔽掉bai
Exit Function
End Select
SubWndProc = CallWindowProc(PrevWndProc, hwnd, msg, wParam, lParam) '其它消息不管
End Function
Public Sub CallHook(ByVal hwnd As Long)
PrevWndProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf SubWndProc)
End Sub
Public Sub CallUnhook(ByVal hwnd As Long)
Dim lngReturnValue As Long
lngReturnValue = SetWindowLong(hwnd, GWL_WNDPROC, PrevWndProc)
End Sub
'窗体中:
Private Sub Form_Load()
Dim i As Integer
CallHook Combo1.hwnd
For i = 1 To 10
Combo1.AddItem i
Next
相关文章
- 10-19winform屏蔽鼠标右键
- 10-19QT--控件屏蔽鼠标点击事件
- 10-19winform Chart控件 获取鼠标处坐标值方法
- 10-19duilib combo控件,当鼠标滚动时下拉列表自动关闭的bug的修复
- 10-19qt控件(checkbox为例)鼠标悬停显示文字
- 10-19NX二次开发-UFUN不用UI控件,鼠标选中对象获得tag UF_UI_ask_global_sel_object_list
- 10-19WPF 获取鼠标屏幕位置、窗口位置、控件位置
- 10-19QT对Label控件实现鼠标的单击和右击事件处理
- 10-19鼠标进入与离开的消息(使用CM_MOUSEENTER来判断是否进入控件)
- 10-19Js控制网页鼠标滚动时,顶部导航条,由透明变成有背景色