retrieve the group header and descriptions(top and bottom)
-
Hi, I can find the headertext with
Dim lvg As New LVGROUP()
lvg.cbSize = CUInt(Marshal.SizeOf(lvg))
lvg.mask = LVGF_STATE Or LVGF_GROUPID Or LVGF_HEADER Or LVGF_FOOTER
Dim nRetHeader2 As Integer = SendMessage(m.HWnd, LVM_GETGROUPINFO, nItem, lvg)
Dim sHeadText As String = Marshal.PtrToStringUni(lvg.pszHeader)
Dim sFootTxt As String = Marshal.PtrToStringUni(lvg.pszFooter)however the foottext is always empty. same for pszDescriptionTop and pszDescriptionBottom I set the footer with some code I found on the net
Private Shared Sub SetGrpFooter(ByVal lstvwgrp As ListViewGroup, ByVal footer As String)
If Environment.OSVersion.Version.Major < 6 Then Return
If lstvwgrp Is Nothing OrElse lstvwgrp.ListView Is Nothing Then Return
If lstvwgrp.ListView.InvokeRequired Then
lstvwgrp.ListView.Invoke(New CallbackSetGroupString(AddressOf SetGrpFooter), lstvwgrp, footer)
Else
Dim GrpId As System.Nullable(Of Integer) = GetGroupID(lstvwgrp)
Dim group As New LVGROUP
group.CbSize = Marshal.SizeOf(group)
If (footer = String.Empty) Then
group.PszFooter = Nothing
Else
group.PszFooter = footer
End If
'lstvwgrp.HeaderAlignment = HorizontalAlignment.Center
'group.pszDescriptionBottom = "bottom" & Chr(0)
'group.pszDescriptionTop = "top"group.mask = ListViewGroupMask.Footer + ListViewGroupMask.DescriptionBottom + ListViewGroupMask.DescriptionTop Dim ip As IntPtr = Marshal.AllocHGlobal(group.cbSize) Marshal.StructureToPtr(group, ip, False) If GrpId IsNot Nothing Then group.IGroupId = GrpId.Value SendMessage(lstvwgrp.ListView.Handle, LVM\_SETGROUPINFO, GrpId.Value, ip) Else group.iGroupId = GrpId SendMessage(lstvwgrp.ListView.Handle, LVM\_SETGROUPINFO, GrpId.Value, ip) End If End If End Sub
I also can't find the rectangles of where I have to draw the texts What do I do wrong? Jan
-
Hi, I can find the headertext with
Dim lvg As New LVGROUP()
lvg.cbSize = CUInt(Marshal.SizeOf(lvg))
lvg.mask = LVGF_STATE Or LVGF_GROUPID Or LVGF_HEADER Or LVGF_FOOTER
Dim nRetHeader2 As Integer = SendMessage(m.HWnd, LVM_GETGROUPINFO, nItem, lvg)
Dim sHeadText As String = Marshal.PtrToStringUni(lvg.pszHeader)
Dim sFootTxt As String = Marshal.PtrToStringUni(lvg.pszFooter)however the foottext is always empty. same for pszDescriptionTop and pszDescriptionBottom I set the footer with some code I found on the net
Private Shared Sub SetGrpFooter(ByVal lstvwgrp As ListViewGroup, ByVal footer As String)
If Environment.OSVersion.Version.Major < 6 Then Return
If lstvwgrp Is Nothing OrElse lstvwgrp.ListView Is Nothing Then Return
If lstvwgrp.ListView.InvokeRequired Then
lstvwgrp.ListView.Invoke(New CallbackSetGroupString(AddressOf SetGrpFooter), lstvwgrp, footer)
Else
Dim GrpId As System.Nullable(Of Integer) = GetGroupID(lstvwgrp)
Dim group As New LVGROUP
group.CbSize = Marshal.SizeOf(group)
If (footer = String.Empty) Then
group.PszFooter = Nothing
Else
group.PszFooter = footer
End If
'lstvwgrp.HeaderAlignment = HorizontalAlignment.Center
'group.pszDescriptionBottom = "bottom" & Chr(0)
'group.pszDescriptionTop = "top"group.mask = ListViewGroupMask.Footer + ListViewGroupMask.DescriptionBottom + ListViewGroupMask.DescriptionTop Dim ip As IntPtr = Marshal.AllocHGlobal(group.cbSize) Marshal.StructureToPtr(group, ip, False) If GrpId IsNot Nothing Then group.IGroupId = GrpId.Value SendMessage(lstvwgrp.ListView.Handle, LVM\_SETGROUPINFO, GrpId.Value, ip) Else group.iGroupId = GrpId SendMessage(lstvwgrp.ListView.Handle, LVM\_SETGROUPINFO, GrpId.Value, ip) End If End If End Sub
I also can't find the rectangles of where I have to draw the texts What do I do wrong? Jan
-
JR212 wrote:
Where are the programmers geniusses from before?
Same place they always are. What is your problem?
-
Still the same as described in this topic. I need to find out what the footertext is in a listviewgroup in a .dotnet4 program throu user32.dll sendmessage. Header is no problem but footer alway return 'nothing' Jan
-
Hi Sorry but your first link is for the listviewfooter and not listviewGROUPfouter. I gues I need [ListView_GetGroupInfo macro (commctrl.h) - Win32 apps | Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-listview\_getgroupinfo) but I cant get that to work. Your question why not use the default control. I do (partely)! I need to work with ownerdraw and the Listview control in dotnet doesn't have support for the groupfooter or the description(top nor bottom). If using dot core 5.0 I can but I need to work with 4.7 or less. I'm been looking for weeks and can't find a working example for the groupfooter. I can if it is normaldraw so I have a code to set the footer but not to get/retrieve it. Jan
-
Hi Sorry but your first link is for the listviewfooter and not listviewGROUPfouter. I gues I need [ListView_GetGroupInfo macro (commctrl.h) - Win32 apps | Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-listview\_getgroupinfo) but I cant get that to work. Your question why not use the default control. I do (partely)! I need to work with ownerdraw and the Listview control in dotnet doesn't have support for the groupfooter or the description(top nor bottom). If using dot core 5.0 I can but I need to work with 4.7 or less. I'm been looking for weeks and can't find a working example for the groupfooter. I can if it is normaldraw so I have a code to set the footer but not to get/retrieve it. Jan
-
Sorry, it's a while since I have done much with a Listview. But most of the LVM_SET??? messages have a corresponding LVM_GET???; in your case you need the LVM_GETGROUPINFO message (Commctrl.h) - Win32 apps | Microsoft Docs[^].