Attribute VB_Name = "Win32APIJunk"
Option Explicit

Private Type Win32RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type
Private Type Win32POINT
        x As Long
        y As Long
End Type
Public Type POINTAPI
        x As Long
        y As Long
End Type

Private Declare Function Win32GetCursorPos Lib "user32.dll" Alias "GetCursorPos" (lpPoint As Win32POINT) As Long
Private Declare Function Win32GetWindowRect Lib "user32.dll" Alias "GetWindowRect" (ByVal hwnd As Long, lpRect As Win32RECT) As Long
Public Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Public Function MouseInWindow(ByVal hwnd As Long) As Boolean
    Dim pt As Win32POINT
    Win32GetCursorPos pt
    Dim rc As Win32RECT
    Win32GetWindowRect hwnd, rc
    MouseInWindow = (rc.Left <= pt.x) And (rc.Right >= pt.x) And (rc.Top <= pt.y) And (rc.Bottom >= pt.y)
End Function
