I don't know if there is an easier way to do this in XP, but a guy from my office passed this code on to me:
This is added to a Module:
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 SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function RegisterWindowMessage& Lib "user32" Alias "RegisterWindowMessageA" _
(ByVal lpString As String)
Public Const GWL_WNDPROC = -4
Public IsHooked As Boolean
Public lpPrevWndProc As Long
Public gHW As Long
Public Sub Hook()
If IsHooked Then
'MsgBox "Don't hook it twice without " & _
' "unhooking, or you will be unable to unhook it."
IsHooked = True
Else
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, _
AddressOf WindowProc)
IsHooked = True
End If
End Sub
Public Sub Unhook()
Dim temp As Long
temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
IsHooked = False
End Sub
Function WindowProc(ByVal hw As Long, ByVal uMsg As _
Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If uMsg = GetMouseWheelMsg Then
' Debug.Print "Message: "; hw, uMsg, wParam, lParam
WindowProc = 0
Else
WindowProc = CallWindowProc(lpPrevWndProc, hw, _
uMsg, wParam, lParam)
End If
End Function
Public Function GetMouseWheelMsg() As Long
GetMouseWheelMsg = 522 'this works for Win98/2000, otherwise use
'RegisterWindowMessage("MSWHEEL_ROLLMSG")
End Function
This is added to each Form:
Sub Form_Load()
'Store handle to this form's window
gHW = Me.hwnd
If IsHooked Then
Call Unhook
End If
'Call procedure to begin capturing messages for this window
Call Hook
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Call procedure to stop intercepting the messages for this window
Call Unhook
End Sub
Hope it helps