Results 1 to 3 of 3

Thread: *resolved* Show full name of a list item which's name exceeds the listbox's width?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2004
    Posts
    28

    *resolved* Show full name of a list item which's name exceeds the listbox's width?

    I have a list that displays full filenames with paths and all. These names usually get pretty long, and exceed the listbox's width. How can I display their full names without using another label or textbox which will display it when they are selected? Something more like the ControlTipText. Please help.
    10x
    Last edited by odedyer; Sep 21st, 2004 at 11:13 AM.

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    See if this is close to what you are looking for.
    VB Code:
    1. Option Explicit
    2. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long '
    3. Private Const LB_ITEMFROMPOINT = &H1A9
    4.  
    5. Private Sub Form_Load()
    6.     'Just add some data to the listbox
    7.     FillListBox "C:\WINNT", List1
    8. End Sub
    9.  
    10. Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    11. Dim lngPos As Long
    12. Dim XX As Long
    13. Dim YY As Long
    14. Dim i As Integer
    15.  
    16.     XX = CLng(X / Screen.TwipsPerPixelX)
    17.     YY = CLng(Y / Screen.TwipsPerPixelY)
    18.     lngPos = SendMessage(List1.hWnd, LB_ITEMFROMPOINT, 0, ByVal ((YY * 65536) + XX))
    19.      
    20.     If lngPos < List1.ListCount And lngPos > -1 Then
    21.         List1.ListIndex = lngPos
    22.         List1.ToolTipText = List1.List(lngPos)
    23.     End If
    24. End Sub
    25.  
    26. Private Sub FillListBox(ByVal InitDir As String, lstBox As ListBox)
    27. Dim strFile As String
    28.  
    29.     If Right(InitDir, 1) <> "\" Then
    30.         InitDir = InitDir & "\"
    31.     End If
    32.    
    33.     strFile = Dir(InitDir)
    34.    
    35.     Do While strFile <> ""
    36.        If strFile <> "." And strFile <> ".." Then
    37.           lstBox.AddItem " " & InitDir & strFile & " "
    38.        End If
    39.        strFile = Dir
    40.     Loop
    41. End Sub

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2004
    Posts
    28

    10x

    Actually, it's exactly what I meant!!!!! 10x!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width