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 to set the alignment of items of CListCtrl

How to set the alignment of items of CListCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
6 Posts 2 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
    rahul kulshreshtha
    wrote on last edited by
    #1

    I want to set the alignment of the items only and not for the header. I tried with SetColumn with LVCFMT_RIGHT but that aligns header also. I just want to align only the items(header should be skipped) I also thought that SetItem should work for aligning only a single item but I don't know how it can be used for aligning a single item.

    L 1 Reply Last reply
    0
    • R rahul kulshreshtha

      I want to set the alignment of the items only and not for the header. I tried with SetColumn with LVCFMT_RIGHT but that aligns header also. I just want to align only the items(header should be skipped) I also thought that SetItem should work for aligning only a single item but I don't know how it can be used for aligning a single item.

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

      According to the documentation[^] alignment affects both header and content. The only way I can think to work round this would be to make it owner drawn and catch the WM_DRAWITEM message[^] to draw the items yourself.

      One of these days I'm going to think of a really clever signature.

      R 1 Reply Last reply
      0
      • L Lost User

        According to the documentation[^] alignment affects both header and content. The only way I can think to work round this would be to make it owner drawn and catch the WM_DRAWITEM message[^] to draw the items yourself.

        One of these days I'm going to think of a really clever signature.

        R Offline
        R Offline
        rahul kulshreshtha
        wrote on last edited by
        #3

        Thanks Richard, I am going to give it a try. I searched for the example for this and found this http://msdn.microsoft.com/en-us/library/kc9hahtd(v=vs.80).aspx[^] Can you refer any other examples? I am new to OwnerDraw. This is what I got about ownerdraw. http://msdn.microsoft.com/en-us/library/windows/desktop/hh298352(v=vs.85).aspx[^]

        L 1 Reply Last reply
        0
        • R rahul kulshreshtha

          Thanks Richard, I am going to give it a try. I searched for the example for this and found this http://msdn.microsoft.com/en-us/library/kc9hahtd(v=vs.80).aspx[^] Can you refer any other examples? I am new to OwnerDraw. This is what I got about ownerdraw. http://msdn.microsoft.com/en-us/library/windows/desktop/hh298352(v=vs.85).aspx[^]

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

          That first link looks like it is the answer to your question, give it a try and then modify to your specific requirements.

          One of these days I'm going to think of a really clever signature.

          R 1 Reply Last reply
          0
          • L Lost User

            That first link looks like it is the answer to your question, give it a try and then modify to your specific requirements.

            One of these days I'm going to think of a really clever signature.

            R Offline
            R Offline
            rahul kulshreshtha
            wrote on last edited by
            #5

            Thanks a lot. That worked. It aligned the text as I expected but few items could not be drawn, I guess I have to skip where the item type is image instead of text. Or may be I have to set the image also. I am working on it. I had used lvs_ownerdrawfixed. Thanks, Rahul Kulshreshtha

            L 1 Reply Last reply
            0
            • R rahul kulshreshtha

              Thanks a lot. That worked. It aligned the text as I expected but few items could not be drawn, I guess I have to skip where the item type is image instead of text. Or may be I have to set the image also. I am working on it. I had used lvs_ownerdrawfixed. Thanks, Rahul Kulshreshtha

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

              In general the items in a list control consist of a text description and an image. If you use images then you would normally have one for every item. Take a look at Windows explorer and switch between the various views to see how the 'standard' displays are laid out.

              One of these days I'm going to think of a really clever signature.

              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