by Karthikeyan (187 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Tue 23rd January 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
'Get window position points using GetWindowRect API
API Declarations
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long
'http://www.geocities.com/marskarthik
'http://marskarthik.virtualave.net
'Email: [email protected]
Private Sub Form_Load()
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 1
End Sub
Private Sub Timer1_Timer()
Dim wnrect As RECT
GetWindowRect GetForegroundWindow(), wnrect
Label1.Caption = "Top = " & wnrect.Top & " " & "Left = " & wnrect.Left & _
Chr(13) & "Bottom = " & wnrect.Bottom & " " & "Right = " & wnrect.Right
End Sub