Hi

I'm trying to make a listbox display a vertical scrollbar all the time. I've found the LBS_DISABLENOSCROLL listbox style constant and it sounds like the one I'm looking for, but I can't get it to work when I do the following:


Option Explicit
Private Const LBS_DISABLENOSCROLL = &H1000&
Private Const GWL_STYLE = (-16)

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Private Sub Command1_Click

Dim lngStyle As Long

' Get the current List Box window style
lngStyle = GetWindowLong(List1.hWnd, GWL_STYLE)

' Add the Disable No Scroll list box to the
' current list box styles
Call SetWindowLong(List1.hWnd, GWL_STYLE, _
lngStyle Or LBS_DISABLENOSCROLL)

End Sub


How do I make a listbox show a vertical scrollbar all the time?