SPECIALIST
asked on
Horizontal Scroll for listbox
Anyone have the code for horizontal scroll in listbox? I think there is an API to determine this.
Specialist
Specialist
ASKER
Thanks I just have one error Getfocus says "sub or function not defined"
Just need that sub!
Specialist
Just need that sub!
Specialist
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long,
ByRef lParam As Long) As Long
const LB_SETHORIZONTALEXTENT = 404
dim s as long
s = SendMessage(ListBox1.hWnd, LB_SETHORIZONTALEXTENT, 500, 0)
//Can you do like this in VB???->>> ListBox1.hWnd
Regards,
Viktor Ivanov
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long,
ByRef lParam As Long) As Long
const LB_SETHORIZONTALEXTENT = 404
dim s as long
s = SendMessage(ListBox1.hWnd,
//Can you do like this in VB???->>> ListBox1.hWnd
Regards,
Viktor Ivanov
Sorry about that, forgot the one declaration. I would have posted it but someone beat me to it...
ASKER
tward,
sorry I know you answered first, but I asked for clarification, after a few hours I had to re-post due to time limitations.
Sorry!
Specialist
sorry I know you answered first, but I asked for clarification, after a few hours I had to re-post due to time limitations.
Sorry!
Specialist
ASKER
One other thing, what is the 3rd argument? fullstring as string?
should be ok after that!
Thanks
should be ok after that!
Thanks
The function I did gets called after anything is added to the Listbox so I pass the string that was added and try to calculate the size of the Scroll bar based on the Text that was added.
ASKER
Thanks!
Can somebody provide an example of calling this API function? Thanks.
--Vingamel
--Vingamel
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Long) As Long
Public Sub AddHScrollToListBox(ByVal FormWithControl As Form, ByVal ListBox As Control, ByVal FullString As String)
Dim ListHwnd As Long
Static GreatestWidth As Long
' Get Focus of the ListBox to Make A Horizontal Scroll Bar For '
ListBox.SetFocus
ListHwnd = GetFocus()
If FormWithControl.TextWidth(
' Add/Change Size of Horizontal Scroll Bar '
Call SendMessage(ListHwnd, LB_SETHORIZONTALEXTENT, FormWithControl.TextWidth(
GreatestWidth = FormWithControl.TextWidth(
DoEvents
End If
End Sub