'模块中:
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