AddressOf Type mismatch

AddressOf Type mismatch

Anonymous
Not applicable
1,804 Views
1 Reply
Message 1 of 2

AddressOf Type mismatch

Anonymous
Not applicable

Hi there,

 

Have anybody tried to work with Windows functions in VBA7.1?

 

Here is a bit of code that used to work on 32bit PC

I have tried different types, like LongLong and LongPtr, but always get Error "Type mismatch" on AddressOf WindowProc

 

 

 Public Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String,ByVal _
lpWindowName As String) As Long
Private Declare PtrSafe Function CallWindowProc Lib "user32.dll" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, _
ByVal hWnd As LongPtr, yVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long


Private Function WindowProc(ByVal lWnd As Long, ByVal lMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongLong
  If lMsg = WM_MOUSEWHEEL Then
Screen.ActiveForm.MouseWheelRolled
End If

If lMsg <> WM_MOUSEWHEEL Then
WindowProc = CallWindowProc(lPrevWndProc, lWnd, lMsg, wParam, lParam)
End If End Function


Public Sub Hook(ByVal hControl As Long)
lPrevWndProc = SetWindowLong(hControl, GWL_WNDPROC, AddressOf WindowProc)
End Sub

'On a Form
Hook (FindWindow(vbNullString, Me.Caption))


 

 Any idea how else to catch the mouse wheel event?

 

 

 

0 Likes
1,805 Views
1 Reply
Reply (1)
Message 2 of 2

NickBrege
Enthusiast
Enthusiast

...

0 Likes