Add horizontal scrool bar to a list box


‘declaration
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

‘form code

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

One response to “Add horizontal scrool bar to a list box

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s