by Anonymous (267 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Sat 23rd January 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Add a horizontal scroll bar to a list box
API Declarations
Const LB_SETHORIZONTALEXTENT = &H194
'horizontal scroll bar. This can be a problem when the item in a ListBox extends
'past the boundaries of the ListBox. To add a horizontal scroll bar to the control,
'you can call the Windows API SendMessage function with the
'LB_SETHORIZONTALEXTENT constant.
Dim s As String
Static x As Long
s = InputBox("Please enter any text", "List scroll", "this is a simple scrollbar sample for demonstration purposes")
List1.AddItem s
If x < TextWidth(s & " ") Then
x = TextWidth(s & " ")
End If
If ScaleMode = vbTwips Then
x = x / Screen.TwipsPerPixelX ' if twips change to pixels
SendMessageByNum List1.hwnd, LB_SETHORIZONTALEXTENT, x, 0
End If