Determine Active Window Position

D

Devlin

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.
 
R

Ron Weiner

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top