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. hi i want to color the cell of list control

hi i want to color the cell of list control

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.
  • R Offline
    R Offline
    rajneshmalik
    wrote on last edited by
    #1

    hi all i have five list control in report mode on my single dialog when i click one and go to second,third,fourth and five by clicking the cell of list control i want to change the color of cell of list control only where i click the particular cell of list controls, how can i do this,reply please i will be so greatful thank u in advance malik

    F R N 3 Replies Last reply
    0
    • R rajneshmalik

      hi all i have five list control in report mode on my single dialog when i click one and go to second,third,fourth and five by clicking the cell of list control i want to change the color of cell of list control only where i click the particular cell of list controls, how can i do this,reply please i will be so greatful thank u in advance malik

      F Offline
      F Offline
      Force Code
      wrote on last edited by
      #2

      Anything in Windows that there's not a documented interface for, you can usually accomplish through Windows subclassing. In your case, to sketch out a solution, you would subclass the list control window, and then handle in all liklihood WM_PAINT. On that message, you would send LVM_GETITEMRECT to the list control window, and get the bounding rect of the list control cell you were interested in. Then just BitBlt whatever color you want to the hdc of the window, using the dimensions of the rect you retrieved (possibly using PATBLT for a ROP code, first setting the hdc brush to the appropriate color.) So that's the basic idea. Actually, although I'm not sure I entirely understood you, the above solution might not work if you BitBlt to the cell and then the original WinProc writes text over it, as the textbackground color may be wrong, unless its being drawn transparent. Of course, there's SetBkMode to make the text background transparent, but I don't know how you get this to work for the hdc the original WndProc is writing to. It looks like you've got some work to do on your own, but its certainly not impossible. Also there's LVM_SETTEXTBKCOLOR, FWIW. -- modified at 11:09 Thursday 25th October, 2007

      1 Reply Last reply
      0
      • R rajneshmalik

        hi all i have five list control in report mode on my single dialog when i click one and go to second,third,fourth and five by clicking the cell of list control i want to change the color of cell of list control only where i click the particular cell of list controls, how can i do this,reply please i will be so greatful thank u in advance malik

        R Offline
        R Offline
        Roger Broomfield
        wrote on last edited by
        #3

        LVS_OWNERDRAWFIXED the list-view control sends a WM_DRAWITEM message to paint eachitem

        R 1 Reply Last reply
        0
        • R rajneshmalik

          hi all i have five list control in report mode on my single dialog when i click one and go to second,third,fourth and five by clicking the cell of list control i want to change the color of cell of list control only where i click the particular cell of list controls, how can i do this,reply please i will be so greatful thank u in advance malik

          N Offline
          N Offline
          Nelek
          wrote on last edited by
          #4

          If you mean with color the item-selection and that only the current listtrl has a selection... you can play with the KillFocus to unselect the item/subitem when changing of ListCtrl. You should have no colors on any unselected ListCtrl.

          Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)

          R 1 Reply Last reply
          0
          • N Nelek

            If you mean with color the item-selection and that only the current listtrl has a selection... you can play with the KillFocus to unselect the item/subitem when changing of ListCtrl. You should have no colors on any unselected ListCtrl.

            Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)

            R Offline
            R Offline
            rajneshmalik
            wrote on last edited by
            #5

            please give some more light on your approach because i am new to mfc malik

            1 Reply Last reply
            0
            • R Roger Broomfield

              LVS_OWNERDRAWFIXED the list-view control sends a WM_DRAWITEM message to paint eachitem

              R Offline
              R Offline
              rajneshmalik
              wrote on last edited by
              #6

              please give some light on your approach because i am new for mfc malik

              R 1 Reply Last reply
              0
              • R rajneshmalik

                please give some light on your approach because i am new for mfc malik

                R Offline
                R Offline
                Roger Broomfield
                wrote on last edited by
                #7

                do an article search for lvs_ownerdrawfixed. there are two that look particularly interesting to solve your dilemma, one by Muhammad Azam[^] and one by Piotr Szewczyk[^]

                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