FIX: Problems Calling DoEvents from a Scroll Bar Change Event (95498)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition for Windows 2.0
This article was previously published under Q95498 SYMPTOMS
There are two parts to this bug, a paint problem and a stack problem. These
two problems can occur when DoEvents is called from the Change event of a
scroll bar. - Clicking either the up or down directional arrows of a scroll bar causes
the change event to fire repeatedly and generate an "Out of Stack Space"
error.
- Moving the scroll bar's thumb after clicking either of the directional
arrows leads to painting problems with the scroll bar.
WORKAROUND
To work around the problem, move code containing DoEvents calls from the
change event to a timer event. Then from the scroll bar change event,
enable the timer. For example, add the following steps to those listed in
the "More Information" section to implement this workaround: - Add a Timer control (Timer1) to Form1.
- Place the following code in the Timer1_Timer event procedure:
Sub Timer1_Timer ()
s! = Timer
Do
x% = DoEvents ()
Loop While Timer - s! <= .25
timer1.Enabled = 0
End Sub
- Place the following code in the HScroll1 Change event procedure to
replace the code added in step 3.
Sub HScroll1_Change ()
Print "We are in the Change Event"
timer1.Interval = 2000
timer1.Enabled = -1
End Sub
- From the Run menu, choose Start (ALT, R, S) or press the F5 key to run
the program.
Now you should be able to click the directional arrows of the scroll bar
and move the scroll thumb without encountering either of the two problems.
STATUS
Microsoft has confirmed this to be a bug in Microsoft Visual Basic version
2.0. The stack problem was corrected in Microsoft Visual Basic version 3.0.
However, the paint problem still exists.
Modification Type: | Minor | Last Reviewed: | 1/8/2003 |
---|
Keywords: | kbbug KB95498 |
---|
|