Microsoft KB Archive/251321

= BUG: ScrollBar Controls Exhibit Paint Problems When Code Is Executed in Change Event =

Article ID: 251321

Article Last Modified on 6/24/2004

-

APPLIES TO


 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition

-



This article was previously published under Q251321



SYMPTOMS
In Microsoft Visual Basic, the intrinsic HScrollBar and VScrollBar controls experience painting problems if the mouse is moved off the control prior to the completion of code execution in the Change event.



RESOLUTION
To work around this behavior, the scrollbar control can be disabled at the start of the Change event. Once the code execution is complete, the control can then be enabled again. Private Sub HScroll1_Change HScroll1.Enabled = False

' place your code here

HScroll1.Enabled = True End Sub



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Start a new Visual Basic Standard EXE project. Form1 is created by default. Add an HScrollBar control to Form1.  Add the following code to the General Declarations section of Form1: Private Sub HScroll1_Change t = Timer While Timer < (t + 2) ' to give you time to move the mouse DoEvents Wend End Sub  Press the F5 key to run the program. Click on the RIGHT ARROW of the HScrollBar control. Note that the RIGHT ARROW appears in a depressed state. Before the RIGHT ARROW of the HScrollBar returns to the raised state, move the mouse off the HScrollBar control and position the mouse over any portion of the client area of Form1.</li> When the RIGHT ARROW of the HScrollBar returns to the raised state, click once on the HScrollBar thumb. Note that the thumb receives focus and begins flashing.</li> Drag the HScrollBar thumb to the the right side of the control. Note that both the RIGHT and LEFT ARROWs of the HScrollBar control are now selected and in a depressed state.</li></ol>

Keywords: kbbug kbnofix kbscrollbar kbctrl KB251321

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.