hi guys.. I fixed the Public Property Get GroupHeaderText(ByVal GroupID As Long) As String
(previously crashed on Windows XP)
Declares
'ADDED BY CHIP!
Private Declare Function lstrcpyA Lib "Kernel32.dll" ( _
ByVal lpString1 As String, ByVal lpString2 As Long) As Long
Private Declare Function lstrlenA Lib "Kernel32.dll" (ByVal lpString As Long) As Long
Private Declare Function lstrcpyW Lib "Kernel32.dll" ( _
ByVal lpString1 As Long, ByVal lpString2 As Long) As Long
Private Declare Function lstrlenW Lib "Kernel32.dll" (ByVal lpString As Long) As Long
Private Type LVGROUP_lp
cbSize As Long
mask As Long
pszHeader As Long
cchHeader As Long
pszFooter As Long
cchFooter As Long
iGroupId As Long
stateMask As Long
State As Long
uAlign As Long
' IF >= WinVista
pszSubtitle As Long
cchSubtitle As Long
pszTask As Long
cchTask As Long
pszDescriptionTop As Long
cchDescriptionTop As Long
pszDescriptionBottom As Long
cchDescriptionBottom As Long
iTitleImage As Long
iExtendedImage As Long
iFirstItem As Long ' Read only
cItems As Long ' Read only
pszSubsetTitle As Long ' NULL if group is not subset
cchSubsetTitle As Long
End Type
Public Property Get GroupHeaderText(ByVal GroupID As Long) As String
'EDITED BY CHIP! - FIXED GET TEXT POINTERS - ADDED LVGROUP_LP DATA TYPE
If m_hListView Then
Dim tLVG As LVGROUP_lp
Dim sBuffer As String
sBuffer = Space$(260)
With tLVG
.cbSize = Len(tLVG)
.mask = LVGF_HEADER
.cchHeader = 260
.pszHeader = StrPtr(sBuffer)
End With
If SendMessage(m_hListView, LVM_GETGROUPINFO, GroupID, tLVG) <> -1 Then GroupHeaderText = CopyString(ByVal tLVG.pszHeader, True)
End If
End Property
Private Function CopyString(ByVal inPtr As Long, _
Optional ByVal inAsWide As Boolean = False) As String
Dim BufLen As Long
If (inAsWide) Then
BufLen = lstrlenW(inPtr)
If (BufLen > 0) Then
CopyString = Space$(BufLen)
Call lstrcpyW(ByVal StrPtr(CopyString), inPtr)
End If
Else
BufLen = lstrlenA(inPtr)
If (BufLen > 0) Then
CopyString = Space$(BufLen)
Call lstrcpyA(CopyString, inPtr)
End If
End If
End Function
Note, you do not need the CopyString function, but I have included it for reference. If you do not wish to include the function, then you can copy the Pointer to the String using: lstrcpyW (in cases that are not Unicode, then you would use lstrcpyA).
Here is a slightly optimized Let GroupHeaderText( that uses StrPtr() instead of the StrConv().
Public Property Let GroupHeaderText(ByVal GroupID As Long, newText As String)
If m_hListView Then
Dim group As LVGROUP_lp
With group
.cbSize = Len(group)
.mask = LVGF_HEADER
.pszHeader = StrPtr(newText)
.cchHeader = Len(.pszHeader)
End With
Call SendMessage(m_hListView, LVM_SETGROUPINFO, GroupID, group)
End If
End Property
Finally, I will have an updated version of my FilterItems() that includes support for filtering WHILE they groups are displayed (very cool), both Windows Vista/7 & Windows XP.
Thanks guys!