devxlogo

Determine Visible Part of a Window

Determine Visible Part of a Window

Programmers often need to know whether only a part of a window is visible. This can require a difficult calculation with coordinates. Use this routine to easily determine the visible part of your window or any control that has an hWnd property:

 Option ExplicitPublic Type RECT		' Declare API type	Left As Long	Top As Long	Right As Long	Bottom As LongEnd Type' Declare API functions:Private Declare Function InvalidateRect Lib _	"user32" (ByVal hWnd As Long, lpRect As _	RECT, ByVal bErase As Long) As LongPrivate Declare Function GetUpdateRect Lib _	"user32" (ByVal hWnd As Long, lpRect As _	RECT, ByVal bErase As Long) As LongPrivate Declare Function GetClientRect Lib _	"user32" (ByVal hWnd As Long, lpRect As _	RECT) As LongPublic Function GetVisibleRect(ByVal hWnd As _	Long, lpRect As RECT) As Boolean	Dim lpClientRect As RECT	Call GetClientRect(hWnd, lpClientRect)	Call InvalidateRect(hWnd, lpClientRect, False)	GetVisibleRect = GetUpdateRect(hWnd, lpRect, _		False)End Function

devx-admin

Share the Post: