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: Visual Basic
Expertise: Beginner
Aug 6, 1997

Create A Controlled DoEvents

I needed a way to issue a DoEvents to allow Windows time to redraw controls on a form, but wanted to prevent the user from clicking some other control within my application. I created a tiny form called F_DoEvents with the following properties:
 ControlBox = False 
MaxButton = False 
MinButton = False
BorderStyle = none
Sub Form_Load
	Left = Width * -1
	Top = Height * -1
End Sub
This makes the form essentially invisible. The only code in the form is:
 Sub Form_Activate
	DoEvents
	Me.Hide
End Sub
Now, whenever I want to issue a limited DoEvents, I code:
 F_DoEvents.Show 1
Because the form is displayed modally, the current code is suppressed while the F_DoEvents form is "displayed." This form issues the DoEvents and then hides itself, returning control to the "caller." I experienced no noticeable degradation in performance. Hiding the form is much faster than unloading it each time. One warning: be sure to terminate your application with an END statement or explicitly unload F_DoEvents when you have finished. Unloading the main form won't remove F_DoEvents and the application will appear to hang.
Robert W.
 
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