January 1, 2005

WinTask - GetWindowRect

'
' GetWindowRect - get the bounding rectangle of a window
'
' Author: Joe Strazzere
'

' "user32" Alias "GetWindowRect" (ByVal hwnd As Long, lpRect As RECT) As Long
'
'Dim leftpoint as unsigned
'Dim toppoint as unsigned
'Dim rightpoint as unsigned
'Dim bottompoint as unsigned
Dim memptr as unsigned
Dim memptr1 as unsigned
Dim memptr2 as unsigned
Dim memptr3 as unsigned
Dim memptr4 as unsigned
memptr=allocate(16)
hwnd=GetWindowHandle(focus$(),1)
ret = External("user32","GetWindowRect", hwnd, memptr)
memptr1=memptr+0
leftpoint   =peekinteger(memptr1,4)
memptr2=memptr+4
toppoint    =peekinteger(memptr2,4)
memptr3=memptr+8
rightpoint  =peekinteger(memptr3,4)
memptr4=memptr+12
bottompoint =peekinteger(memptr4,4)
msgbox(Str$(leftpoint)+" "+Str$(toppoint)+" "+Str$(rightpoint)+" "+Str$(bottompoint),,"GetWindowRect")