我正在尝试使用SysListView32
从LVM_GETITEMTEXT
获取数据,但我只是得到一个空字符串。它给出了字符数,但没有显示实际文本。有人可以帮忙吗?代码如下
Private Const LVM_FIRST As Long = &H1000
Private Const LVM_GETITEMTEXT As Long = (LVM_FIRST + 45)
Private Type LV_ITEM
mask As Long
iItem As Long
iSubItem As Long
state As Long
stateMask As Long
pszText As String
cchTextMax As Long
iImage As Long
lParam As Long
iIndent As Long
End Type
Dim lvi As LV_ITEM
Dim r as long
lvi.cchTextMax = MAX_PATH
lvi.pszText = Space$(MAX_PATH)
r = SendMessage(Handle, LVM_GETITEMTEXT, 0, lvi)
data = Left(lvi.pszText, r)
If Trim(data) <> "" Then MsgBox (data)
答案 0 :(得分:0)
您need to set the LVIF_TEXT
flag声明pszText
指向有效的缓冲区。
Private Const LVIF_TEXT As Long = &H1
lvi.mask = LVIF_TEXT
lvi.cchTextMax = MAX_PATH
lvi.pszText = Space$(MAX_PATH)