Public Sub SetListboxScrollbar(ByVal lst As ListBox)
Dim i As Integer
Dim new_len As Long
Dim max_len As Long
For i = 0 To lst.ListCount - 1
new_len = 10 + lst.Parent.ScaleX( _
lst.Parent.TextWidth(lst.List(i)), _
lst.Parent.ScaleMode, vbPixels)
If max_len < new_len Then max_len = new_len
Next i
SendMessage lst.hwnd, _
LB_SETHORIZONTALEXTENT, _
max_len, 0
End Sub
|