Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language:
Expertise: Intermediate
Oct 26, 1999

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 Explicit

Public Type RECT		' Declare API type
	Left As Long
	Top As Long
	Right As Long
	Bottom As Long
End Type

' Declare API functions:
Private Declare Function InvalidateRect Lib _
	"user32" (ByVal hWnd As Long, lpRect As _
	RECT, ByVal bErase As Long) As Long
Private Declare Function GetUpdateRect Lib _
	"user32" (ByVal hWnd As Long, lpRect As _
	RECT, ByVal bErase As Long) As Long
Private Declare Function GetClientRect Lib _
	"user32" (ByVal hWnd As Long, lpRect As _
	RECT) As Long

Public 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
Meszaros Akos
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date