Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. retrieve the group header and descriptions(top and bottom)

retrieve the group header and descriptions(top and bottom)

Scheduled Pinned Locked Moved Visual Basic
questionannouncementworkspace
9 Posts 2 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JR212
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • J JR212

      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

      J Offline
      J Offline
      JR212
      wrote on last edited by
      #2

      Where are the programmers geniusses from before?

      L 1 Reply Last reply
      0
      • J JR212

        Where are the programmers geniusses from before?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        JR212 wrote:

        Where are the programmers geniusses from before?

        Same place they always are. What is your problem?

        J 1 Reply Last reply
        0
        • L Lost User

          JR212 wrote:

          Where are the programmers geniusses from before?

          Same place they always are. What is your problem?

          J Offline
          J Offline
          JR212
          wrote on last edited by
          #4

          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

          L 1 Reply Last reply
          0
          • J JR212

            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

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            See ListView_GetFooterInfo macro (commctrl.h) - Win32 apps | Microsoft Docs[^]. But why not use the ListViewGroup Class (System.Windows.Forms) | Microsoft Docs[^]?

            J 1 Reply Last reply
            0
            • L Lost User

              See ListView_GetFooterInfo macro (commctrl.h) - Win32 apps | Microsoft Docs[^]. But why not use the ListViewGroup Class (System.Windows.Forms) | Microsoft Docs[^]?

              J Offline
              J Offline
              JR212
              wrote on last edited by
              #6

              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

              L 1 Reply Last reply
              0
              • J JR212

                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

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                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[^].

                J 1 Reply Last reply
                0
                • L Lost User

                  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[^].

                  J Offline
                  J Offline
                  JR212
                  wrote on last edited by
                  #8

                  your absolutly 100% right. But I can't get it to work

                  L 1 Reply Last reply
                  0
                  • J JR212

                    your absolutly 100% right. But I can't get it to work

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    JR212 wrote:

                    But I can get it to work

                    Well I am afraid that no one here has any chance of guessing what that means.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups