dcsimg
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

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Dec 17, 1998

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Avoid the Flickering

Developers often need to load forms with information, which is time-consuming. The form is often a list box filled from an outside source, and this causes the list-box contents to flash annoyingly as the information goes into it. Solve this by bringing in the declaration of the LockWindowUpdate API call:
 
#If Win16 Then
	Declare Function LockWindowUpdate Lib _
		"User" (ByVal hWndLock As Integer) As Integer
#Else
	Declare Function LockWindowUpdate Lib _
		"user32" (ByVal hWndLock As Long) As Long
#End If
The hWndLock variable refers to the hWnd property of the form where you don't want to have screen updates shown. When you reissue the LockWindowUpdate with a value of 0 for hwndLock, you'll free up the screen and all updates will be shown instantly:
 
Dim lErr as Long
Dim x as Integer

'No list box flicker, it will appear blank for 
'just a moment...
Screen.MousePointer = vbHourglass
lErr = LockWindowUpdate(Me.hWnd)

For x = 1 to 5000
	lstMyListbox.AddItem CStr(x)
Next

	Now all the information is there:

lErr = LockWindowUpdate(0)
Screen.MousePointer = vbDefault
Bruce Goldstein
 
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