Determine Active Window Position

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am searching for a method or means to determine the active window's pos
coordinates. If any one knows this answer I would greatly appreciate it.
Thank you in advance.
 
Devlin

Here is some code you can adapt to your needs. Put this code in its own
code module and call it from anywhere.

Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, _
lpRect As RECT) As Long

Public Sub PrintActiveWindowCoords()
Dim FrmRect As RECT, lngRet As Long

lngRet = GetWindowRect(Screen.ActiveForm.hwnd, FrmRect)
Debug.Print FrmRect.Top, FrmRect.Left, FrmRect.Bottom, FrmRect.Right
End Sub

Ron W
 
Back
Top