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. C / C++ / MFC
  4. How I get the Header HDC of listview in custom draw?

How I get the Header HDC of listview in custom draw?

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 3 Posters 0 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
    JoneLe86
    wrote on last edited by
    #1

    I want to customize the header of a listview, so in NM_CUSTOMDARW i have

    Test = (LPNMLVCCUSTOMDARW)Lp <nmcd.hdc)

    which for the listview without the header, i tried using

    Test = (LPNMCUSTOMDARW)Lp <
    and then

    Test->hdr.hwndFrom

    so

    if(Test->hdr.hwndFrom == listview_getheader(LIST))

    but it does not work, the listview_getheader(LIST) gives the right hwnd, but how about Test->hdr.hwndFrom, it seems i missed something...

    L J 2 Replies Last reply
    0
    • J JoneLe86

      I want to customize the header of a listview, so in NM_CUSTOMDARW i have

      Test = (LPNMLVCCUSTOMDARW)Lp <nmcd.hdc)

      which for the listview without the header, i tried using

      Test = (LPNMCUSTOMDARW)Lp <
      and then

      Test->hdr.hwndFrom

      so

      if(Test->hdr.hwndFrom == listview_getheader(LIST))

      but it does not work, the listview_getheader(LIST) gives the right hwnd, but how about Test->hdr.hwndFrom, it seems i missed something...

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

      JoneLe86 wrote:

      Test = (LPNMCUSTOMDARW)Lp <<lparam

      What is Test and what is its value, and that of lp, after this statement?

      Use the best guess

      J 1 Reply Last reply
      0
      • J JoneLe86

        I want to customize the header of a listview, so in NM_CUSTOMDARW i have

        Test = (LPNMLVCCUSTOMDARW)Lp <nmcd.hdc)

        which for the listview without the header, i tried using

        Test = (LPNMCUSTOMDARW)Lp <
        and then

        Test->hdr.hwndFrom

        so

        if(Test->hdr.hwndFrom == listview_getheader(LIST))

        but it does not work, the listview_getheader(LIST) gives the right hwnd, but how about Test->hdr.hwndFrom, it seems i missed something...

        J Offline
        J Offline
        Jochen Arndt
        wrote on last edited by
        #3

        The header control is a child window of a list. If you want to customize the header, you must use owner drawing for the header itself. When using MFC, derive a CHeaderCtrl class and implement the virtual DrawItem() handler. To connect this header control class to your list, use subclassing. To enable owner drawing of header items, set the HDF_OWNERDRAW flag for the header items. See Deriving a Custom CHeaderCtrl in the Using the Header Control[^] article. This example contains complete implementation code including the DrawItem() function: http://www.codeguru.com/cpp/controls/listview/sorting/article.php/c977/Indicating-sort-order-in-header-control.htm[^].

        J 1 Reply Last reply
        0
        • J Jochen Arndt

          The header control is a child window of a list. If you want to customize the header, you must use owner drawing for the header itself. When using MFC, derive a CHeaderCtrl class and implement the virtual DrawItem() handler. To connect this header control class to your list, use subclassing. To enable owner drawing of header items, set the HDF_OWNERDRAW flag for the header items. See Deriving a Custom CHeaderCtrl in the Using the Header Control[^] article. This example contains complete implementation code including the DrawItem() function: http://www.codeguru.com/cpp/controls/listview/sorting/article.php/c977/Indicating-sort-order-in-header-control.htm[^].

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

          hmm I wonder why Everything need to be subclassed, thanks for this information it did help....

          1 Reply Last reply
          0
          • L Lost User

            JoneLe86 wrote:

            Test = (LPNMCUSTOMDARW)Lp <<lparam

            What is Test and what is its value, and that of lp, after this statement?

            Use the best guess

            J Offline
            J Offline
            JoneLe86
            wrote on last edited by
            #5

            LPNMCUSTOMDARW Test = (LPNMCUSTOMDARW)lp I was in the wrong way, Jochen Arndt explained that I should subclass the header first... Thanks

            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