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
See also  Redefining Energy Management: Advanced Solutions for Modern Buildings
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist