CSDN博客

img lang_csdn

ListBox中的字符串超长显示的解决方法

发表于2004/10/24 14:25:00  682人阅读

分类: VB6.0

Option Explicit
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
Private Const LB_ITEMFROMPOINT = &H1A9

Private Sub Form_Load()
    Dim i As Integer
    For i = 0 To 5
        List1.AddItem "ListItem字符串超长超长超长超长超长咯    " & i
    Next
End 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.TwipsPerPixelY) * 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

阅读全文
0 0

相关文章推荐

img
取 消
img