CodePudding user response:
Tip more than 80 characters, what is this tip? Directly see the helpDon't use own ToolTip, simulating a himself
CodePudding user response:
Is also encountered this problem before.But then after analysis, found that there is no need to write so bothersome.
Have to refine description and vocabulary.
In this thank my old teacher of Chinese.
CodePudding user response:
Should write their own tooltip, almost can use theOption 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 Declare Function ScreenToClient Lib "user32" (ByVal HWND, As Long As lpPoint POINTAPI) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal HWND, As Long As lpPoint POINTAPI) As Long
Private Declare Function GetClientRect Lib "user32" (ByVal HWND As Long, lpRect As the RECT) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Const LVM_FIRST=& amp; H1000
Private Const LVM_SUBITEMHITTEST=(LVM_FIRST + 57)
Private Const LVM_GETSUBITEMRECT=(LVM_FIRST + 56)
Private Const LVM_GETITEMRECT=(LVM_FIRST + 14)
Private Const LVIR_BOUNDS=0
Private Const LVM_GETSTRINGWIDTHA=(LVM_FIRST + 17)
Private Const LVM_GETSELECTEDCOUNT=(LVM_FIRST + 50)
Private Const LVM_DELETEALLITEMS=(LVM_FIRST + 9)
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Type LVHITTESTINFO
Pt As POINTAPI
Flags As Long
IItem As Long
ISubItem As Long
End Type
Private Type the RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private lblTT As TextBox
Private lblToolText As Label
Private xPos As Long
Private yPos As Long
Private lvHti As LVHITTESTINFO
Get the subitem index
The Public Function GetLvwIndex (LvwList As ListView, ptIndex As POINTAPI)
The GetCursorPos lvHti. Pt
ScreenToClient LvwList HWND, lvHti. Pt
Call SendMessage (LvwList HWND LVM_SUBITEMHITTEST, 0, lvHti. Pt)
PtIndex. X=lvHti. ISubItem
PtIndex. Y=lvHti. IItem
End the Function
'the tooltip
Public Sub ShowToolTip (Lvw As ListView)
On the Error Resume Next
Dim LvwItem As ListItem
Dim As Long, I iSub As Long
Dim lpPt As POINTAPI, lpPt2 As POINTAPI
Dim lpRect As the RECT
Dim lWidth As Long
Dim lHeight As Long
Dim MaxWidth As Long
Dim CltWidth As Long
Dim LvwRect As the RECT
Dim TTLeft As Long
The Static TTTop As Long
Dim ptOffsetX As Long
Dim ptOffsetY As Long
Dim TTPt As POINTAPI
The Static bFlag As Boolean
The Static oldPT As POINTAPI
Call GetLvwIndex (Lvw lpPt)
If lpPt. X & lt; 0 Or lpPt. Y & lt; 0 Then the Exit Sub
'* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
The Set lblTT=Lvw. Parent. Controls. The Add (" VB. The TextBox ", "lblTT")
The Set lblToolText=Lvw. Parent. Controls. The Add (" VB. The Label ", "lblToolText")
LblTT. Locked=True
LblTT. BackColor=vbInfoBackground
LblTT. Appearance=0
LblTT. TabStop=False
LblToolText. BackColor=vbInfoBackground
LblToolText. AutoSize=True
LblToolText. BorderStyle=0
'* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
PtOffsetX=240
PtOffsetY=360
MaxWidth=Lvw. Parent. ScaleWidth - 120
With Lvw.. the Parent
The GetCursorPos lpPt2
If lpPt2. X & lt;> OldPT. X Or lpPt2. Y & lt;> OldPT. Y Then
If xPos & lt;> LpPt. X Or yPos & lt;> LpPt. Y Then
'the Debug. Print "tooltiptext
"The Set LvwItem=Lvw.. ListItems (lpPt. Y + 1)
LpRect. Left=LVIR_BOUNDS
LpRect. Top=lpPt. X
BFlag=False
If lpPt. X & gt; 0 Then
Call SendMessage (Lvw HWND LVM_GETSUBITEMRECT, lpPt. J y, lpRect) rectangular
'LWidth=SendMessage (Lvw.. HWND LVM_GETSTRINGWIDTHA, 0, ByVal LvwItem. SubItems (lpPt. X))
'display need widthThe Else
Call SendMessage (Lvw HWND LVM_GETITEMRECT, lpPt. J y, lpRect) rectangular
'LpRect. Right=Lvw. ColumnHeaders (1) the Width/15
LWidth=SendMessage (Lvw.. HWND LVM_GETSTRINGWIDTHA, 0, ByVal LvwItem. Text) 'display need width
End the If
If lpRect. Left & lt; 0 Then
BFlag=True
The Else
GetClientRect Lvw HWND, LvwRect
CltWidth=LvwRect. Right
If lpRect. Left + lWidth & gt; CltWidth Then
BFlag=True
ElseIf lpRect. Right - lpRect. Left - 12 & lt; LWidth Then
BFlag=True
End the If
End the If
If bFlag Then
LblToolText. The Font. The Name=Lvw. The Font. The Name
LblToolText, Font Size=Lvw. The Font. The Size
If lpPt. X & gt; 0 Then
LblToolText. Caption=LvwItem. SubItems (lpPt. X)
The Else
LblToolText. Caption=LvwItem. Text
End the If
LblTT. The Font. The Name=lblToolText. The Font. The Name
LblTT, Font Size=lblToolText. The Font. The Size
LblTT. The Font. Bold=False
LblTT. The Font. Italic=False
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull