Ok, here is my problem. I got a form with an activeX control on it that I made (and can modify, if needed). I am using the scroll wheel code posted below. It works good if the form has focus or if any other control on the form has focus besides my ActiveX control. When my ActiveX control gets focus the code no longer works. Please help.

I have also noted that my app uses 2 threads. Do all activeX controls use their own thread??

VB Code:
  1. Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
  2. Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
  3. 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
  4. Const GWL_WNDPROC = (-4)
  5. Const WM_MOUSEWHEEL = &H20A
  6.  
  7. Global WndProcOld As Long
  8.  
  9. Private Function HiWord(ByVal LongVal As Long) As Integer
  10.     If LongVal = 0 Then
  11.         HiWord = 0
  12.         Exit Function
  13.     End If
  14.     HiWord = LongVal \ &H10000 And &HFFFF&
  15. End Function
  16.  
  17. Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  18.     On Error Resume Next
  19.     If wMsg = WM_MOUSEWHEEL Then
  20.         If HiWord(wParam) < 0 Then
  21.             'event 1
  22.         Else
  23.             'event 2
  24.         End If
  25.     End If
  26.  
  27.     WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, wParam&, lParam&)
  28.    
  29. End Function
  30.  
  31. Sub SubClassWnd(hwnd As Long)
  32.     WndProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindProc)
  33. End Sub
  34.  
  35. Sub UnSubclassWnd(hwnd As Long)
  36.     SetWindowLong hwnd, GWL_WNDPROC, WndProcOld&
  37.     WndProcOld& = 0
  38. End Sub