Message 1 of 2
AddressOf Type mismatch

Not applicable
11-08-2017
04:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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?