BUG: TreeView Scroll Bar Does Not Disappear When You Set Scroll Property to False at Run Time
Article ID: 201577
Article Last Modified on 12/17/2004
APPLIES TO
- Microsoft Visual Basic 6.0 Enterprise Edition, when used with:
- Microsoft Windows 98 Standard Edition
- Microsoft Windows Millennium Edition
- Microsoft Visual Basic 6.0 Professional Edition, when used with:
- Microsoft Windows 98 Standard Edition
- Microsoft Windows Millennium Edition
- Microsoft Visual Basic 6.0 Learning Edition, when used with:
- Microsoft Windows 98 Standard Edition
- Microsoft Windows Millennium Edition
This article was previously published under Q201577
SYMPTOMS
If you set the Scroll property of the TreeView control from Microsoft Windows Common Controls (Mscomctl.ocx) to False at run time, the scroll bar does not disappear as expected.
RESOLUTION
To work around this problem, call the
ShowScrollBar function instead of using the
Scroll property. The following example demonstrates how to use the
ShowScrollBar function:
- Open a new Standard EXE project in Visual Basic. Form1 is created by default.
- On the Project menu, click Components, select the Microsoft Windows Common Controls 6.0 check box, and then click OK.
- Add a TreeView control (TreeView1) and a CheckBox control (Check1) to Form1.
- Add the following code to the General Declarations section of Form1:
Option Explicit
Private Const SB_VERT = 1
Private Declare Function ShowScrollBar Lib "user32" _
(ByVal hWnd As Long, ByVal wBar As Long, ByVal bShow As Long) As Long
Private Sub Check1_Click()
' The reference to CBool is not required but is used to enhance clarity.
Call ShowScrollBar(TreeView1.hWnd, SB_VERT, CBool(Check1.Value))
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 20
TreeView1.Nodes.Add , , , "Item " & i
Next i
Check1.Caption = "Show Scroll Bar"
Check1.Value = vbChecked
End Sub
- Run the code, and notice that a vertical scroll bar appears on the TreeView control.
- Click Show Scroll Bar, and notice that the scroll bar disappears. Click Show Scroll Bar again, and notice that the scroll bar re-appears.
STATUS
Microsoft has confirmed this to be a problem in the TreeView control from Microsoft Windows Common Controls (Mscomctl.ocx) under Windows 95, Windows 98, and Windows Millennium Edition.
NOTE: This problem does not occur under Windows NT 4.0 and Windows 2000.
REFERENCES
For additional information, click the article number below
to view the article in the Microsoft Knowledge Base:
189249 HOWTO: Determine Which 32-Bit Windows Version Is Being Used
Keywords: kbbug kbnofix kbapi kbtreeview kbcmnctrls kbctrl KB201577