Login | Register   
RSS Feed
Download our iPhone app
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
Aug 6, 1997



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

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
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.



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