Try this:
Code:Option Explicit 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 Private Sub Form_Load() List1.AddItem "this is a test. this is only a test." SendMessageByNum List1.hwnd, LB_SETHORIZONTALEXTENT, 250, 0 End Sub Sub lstAddHScroll(lst As ListBox) Dim a%, m% ' 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




If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!
Reply With Quote