#If VBA7 Then
Private Function WinEventFunc(ByVal HookHandle As Long, ByVal LEvent As Long, _
ByVal hWnd As LongPtr, ByVal idObject As Long, ByVal idChild As Long, _
ByVal idEventThread As Long, ByVal dwmsEventTime As Long) As Long
#Else
Private Function WinEventFunc(ByVal HookHandle As Long, ByVal LEvent As Long, _
ByVal hWnd As Long, ByVal idObject As Long, ByVal idChild As Long, _
ByVal idEventThread As Long, ByVal dwmsEventTime As Long) As Long
#End If
Dim thePID As Long
Static Running As Boolean
If Running Then Exit Function
'This function is a callback passed to the win32 api
'We CANNOT throw an error or break. Bad things will happen.
On Error Resume Next
Running = True
If LEvent = EVENT_SYSTEM_MOVESIZESTART Then
'Debug.Print hWnd
GetWindowThreadProcessId Application.hWnd, thePID
If thePID = GetCurrentProcessId Then
'Application.OnTime Now, "Event_MoveStart"
Call Event_MoveStart
End If
ElseIf LEvent = EVENT_SYSTEM_MOVESIZEEND Then
GetWindowThreadProcessId Application.hWnd, thePID
If thePID = GetCurrentProcessId Then
'Application.OnTime Now, "Event_MoveEnd"
Call Event_MoveEnd
End If
End If
Running = False
On Error GoTo 0
End Function