The standard VB listboxes don`t support horizontal Scrollbars, only vertical ones. Here's an API work-around to get you one!
' In General Declarations
Private Declare Function SendMessageByNum Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, ByVal _
wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const LB_SETHORIZONTALEXTENT = &H194
To display the horizontal scroll bar, you then just call
SendMessageByNum List1.hwnd, LB_SETHORIZONTALEXTENT, 250, 0
List1.hwnd is replaced with the name of your list box, and 250 is replaced with the width you want the scroll bar to be. If you give a width of 0, then the scrollbar will be disappear. This sub routine will automatically workout the greatest width needed.
Sub lstAddHScroll(lst as ListBox)
' depends on the scalewidth
' if scalemode is Twips then Divide M by 15 to get Pixels
For a=0 to lst.listcount-1
if me.textwidth(lst.list(a))>m
then m=me.textwidth(lst.list(a))
Next
SendMessageByNum lst.hwnd, LB_SETHORIZONTALEXTENT,
m/15, 0
End Sub
Comments