Using Tooltip to solve the display of long text is a good solution, the code is given below.
Option ExplicitPrivate Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Const LB_ITEMFROMPOINT = & H1A9
Private Sub Form_Load () DIM I as Integer for i = 0 to 5 List1.addItem "ListItem string super long super long super long super long" & i nextend Sub
Private Sub List1_Mousemove (Button As Integer, Shift As Integer, X as Single, Y AS Single) DIM LPARAM AS Long Dim Lresult As Long LPARAM = (CINT (Y / Screen.twipsPixely) * 2 ^ 16) CINT (X / Screen .TwipsPerPixelX) lResult = SendMessage (List1.hwnd, LB_ITEMFROMPOINT, 0, ByVal lParam) If lResult <0 Or lResult> 32767 Then List1.ToolTipText = "" Exit Sub End If Dim nIndex As Integer nIndex = CInt (lResult) List1.ToolTipText = List1.list (nindex) End Sub
Turn through Win2000 VB6