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. CListCtrl::OnCustomdrawCListCtrl(NMHDR* pNMHDR, LRESULT* pResult)

CListCtrl::OnCustomdrawCListCtrl(NMHDR* pNMHDR, LRESULT* pResult)

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 4 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hello Comunity, i use this funktion to show items in an CListCtrl with diferent colors, and i need to know which item number is to be drawn. I try to cast pNMHDR to LPNMLVCUSTOMDRAW pLVCD = (LPNMLVCUSTOMDRAW)pNMHDR; but i need to know the itemnumber who is to drawn... any one have some sugestions for me? thaks break;

    V C M 3 Replies Last reply
    0
    • L Lost User

      Hello Comunity, i use this funktion to show items in an CListCtrl with diferent colors, and i need to know which item number is to be drawn. I try to cast pNMHDR to LPNMLVCUSTOMDRAW pLVCD = (LPNMLVCUSTOMDRAW)pNMHDR; but i need to know the itemnumber who is to drawn... any one have some sugestions for me? thaks break;

      V Offline
      V Offline
      Viorel
      wrote on last edited by
      #2

      If no other solution, I think you can store the item number as a private data:

      lvItem.mask = ... | LVIF_PARAM;
      . . .
      lvItem.lParam = (LPARAM)i;
      pMatrixListResults->InsertItem(&lvItem);
      

      Later obtain this number from the NMCUSTOMDRAW structure:

      LPNMLVCUSTOMDRAW pLVCD = (LPNMLVCUSTOMDRAW)pNMHDR;
      int number = (int)pLVCD->nmcd.lItemlParam;
      

      I hope this works.

      L 1 Reply Last reply
      0
      • L Lost User

        Hello Comunity, i use this funktion to show items in an CListCtrl with diferent colors, and i need to know which item number is to be drawn. I try to cast pNMHDR to LPNMLVCUSTOMDRAW pLVCD = (LPNMLVCUSTOMDRAW)pNMHDR; but i need to know the itemnumber who is to drawn... any one have some sugestions for me? thaks break;

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #3

        Why don't you use OnDrawItem?

        L 1 Reply Last reply
        0
        • V Viorel

          If no other solution, I think you can store the item number as a private data:

          lvItem.mask = ... | LVIF_PARAM;
          . . .
          lvItem.lParam = (LPARAM)i;
          pMatrixListResults->InsertItem(&lvItem);
          

          Later obtain this number from the NMCUSTOMDRAW structure:

          LPNMLVCUSTOMDRAW pLVCD = (LPNMLVCUSTOMDRAW)pNMHDR;
          int number = (int)pLVCD->nmcd.lItemlParam;
          

          I hope this works.

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

          Hello, yes, your idea works perfect, this is what i use now! Thank you! break;

          1 Reply Last reply
          0
          • C CPallini

            Why don't you use OnDrawItem?

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

            Hello Capallini, i never use this method, maybe i should try this.. :confused: regards break;

            1 Reply Last reply
            0
            • L Lost User

              Hello Comunity, i use this funktion to show items in an CListCtrl with diferent colors, and i need to know which item number is to be drawn. I try to cast pNMHDR to LPNMLVCUSTOMDRAW pLVCD = (LPNMLVCUSTOMDRAW)pNMHDR; but i need to know the itemnumber who is to drawn... any one have some sugestions for me? thaks break;

              M Offline
              M Offline
              Michael Dunn
              wrote on last edited by
              #6

              LPNMLVCUSTOMDRAW pLVCD = (LPNMLVCUSTOMDRAW)pNMHDR;
              int nItem = (int) pLVCD->nmcd.dwItemSpec;

              --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

              L 1 Reply Last reply
              0
              • M Michael Dunn

                LPNMLVCUSTOMDRAW pLVCD = (LPNMLVCUSTOMDRAW)pNMHDR;
                int nItem = (int) pLVCD->nmcd.dwItemSpec;

                --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

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

                ups, yes, you right, i use this before in my previous project, thanks... :-> regards break;

                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