DoEvents Gotcha! FYI 
Author Message
 DoEvents Gotcha! FYI

The experts can skip this one.  I hope it will save the newer folks a
bad day someplace down the line.

Let me tell a small story... I just made one little change...

This was VB3, but I have no reason to expect it would be different with
the later versions.

I had a function, called from a number of places that updated labels or
something equally trivial.  Sometimes it did not paint nicely so I added
a doevents.  Looking good.

In an unrelated section of the program I unload a mdichild, expecting to
save some resource, and drop back to the prior mdichild.  All of this
had been fine.

Uncovering the child fires resize followed by activate.  In the normal
course these events are always in this order, and you can do things like
control.setfocus in the activate event.

Well suddenly, form_activate was occuring before me.visible, and
crashing on the controls not being available to the setfocus.  And, in
addition, the form was losing it's windowstate, from 2 (max) to 0
(normal) with no code of mine involved.

All of this because that da** doevents was now in the code path of the
resize event.  This let activate start before resize had run to

This was a two hour lesson.  I hate to think how long it would have
taken if this had been in my first year of this stuff!!  Bummer.

And, as is often said.. "I only made one little change, and it can't
have anything to do with what you're seeing" Right!!

/Don Ames
GUU Software Inc.

Please visit our web site at...
http://www.*-*-*.com/ ~guu_sftw

Sat, 05 Feb 2000 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. email gotcha

2. Advisor magazine gotcha ...

3. Deployment Gotcha?

4. Infuriating Unicode gotcha

5. Yet another Internet Control FTP gotcha

6. User privilege "gotcha"

7. FYI - Decompile

8. FYI - Desktop Deployment Resource Center Available

9. FYI: OLE bug in Visio 2000 SR 1

10. FYI: Word 2000 Opening Invalid Links Problem

11. FYI: Different result with Multipage1.Value = Multipage1.Value + 1 or - 1



Powered by phpBB® Forum Software