davidb
Jun 22nd, 2000, 01:47 AM
Using VB 6 SP3 and the standard list box, how can I add a horizontal scroll bar to the box? I know it is an API call, I've done it before, but for the life of me cannot remember how to do it.
Can anyone help me out here?
Thanks,
Chris
Jun 22nd, 2000, 10:54 AM
I just come across this from MSDN Library.
'======== General Declarations for Form1 ==================
' For VB4 16-bit, add the keyword Private before each Declare,
' and enter the following Declare as one, single line:
Declare Function SendMessage& Lib "user" (ByVal hWnd%, ByVal wMsg%,
ByVal wParam%, ByVal lParam&)
Declare Function GetFocus Lib "User" () as Integer
'======== Form1 =======================
'NOTE: each command must appear on one, single line.
Sub Command1_Click ()
Const LB_SETHORIZONTALEXTENT = &H400 + 21
Const NUL = 0&
' wParam is in PIXEL(3).
ScaleMode = 3
' Get the handle.
List1.SetFocus
ListHwnd% = GetFocus()
' This string will show up initially.
ListString1$ = "Derek is a great "
' You can scroll to see this portion.
ListString2$ = "little boy "
' You cannot scroll to see this string.
ListString3$ = "but can be a problem sometimes"
ExtraPixels% = TextWidth(ListString2$)
BoxWidth% = TextWidth(ListString1$)
' Resize the text box.
List1.Move List1.Left, List1.Top, BoxWidth%
' Add the scroll bar.
X& = SendMessage(ListHwnd%, LB_SETHORIZONTALEXTENT,
BoxWidth% + ExtraPixels%, NUL)
' Add the example string to the list box.
List1.AddItem ListString1$ + ListString2$ + ListString3$
End Sub