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 Column width

CListCtrl Column width

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.
  • P Offline
    P Offline
    Paolo Vernazza
    wrote on last edited by
    #1

    I've a CLIstCtrl with the Owner data style. It works great, but when I try to use SetColumnWidth(LVSCW_AUTOSIZE), it resizes the columns in a wrong way, because it considers only visible elements. So I decided to detemine the max length; I tryed using either CDC::GetOutputTextExtent than CListCtrl::GetStringWidth, but both ignore the space between the column border and the text, and I can't figure howto determine the size of that... I tryed using GetSystemMetrics with SM_CXFIXEDFRAME and SM_CXEDGE, but they seem to be wrong. Any ideat? thanks

    D R 2 Replies Last reply
    0
    • P Paolo Vernazza

      I've a CLIstCtrl with the Owner data style. It works great, but when I try to use SetColumnWidth(LVSCW_AUTOSIZE), it resizes the columns in a wrong way, because it considers only visible elements. So I decided to detemine the max length; I tryed using either CDC::GetOutputTextExtent than CListCtrl::GetStringWidth, but both ignore the space between the column border and the text, and I can't figure howto determine the size of that... I tryed using GetSystemMetrics with SM_CXFIXEDFRAME and SM_CXEDGE, but they seem to be wrong. Any ideat? thanks

      D Offline
      D Offline
      Dominik Reichl
      wrote on last edited by
      #2

      To determine the width/height of the scrollbars, use SM_CXVSCROLL/SM_CYVSCROLL as parameters.

      P 1 Reply Last reply
      0
      • D Dominik Reichl

        To determine the width/height of the scrollbars, use SM_CXVSCROLL/SM_CYVSCROLL as parameters.

        P Offline
        P Offline
        Paolo Vernazza
        wrote on last edited by
        #3

        Thanks, but it's not what I nedd... The control (in report mode) has many column; any column has: border (if it is visible or not depend on styles selected) space text space border. I need to find the size of that spaces...

        1 Reply Last reply
        0
        • P Paolo Vernazza

          I've a CLIstCtrl with the Owner data style. It works great, but when I try to use SetColumnWidth(LVSCW_AUTOSIZE), it resizes the columns in a wrong way, because it considers only visible elements. So I decided to detemine the max length; I tryed using either CDC::GetOutputTextExtent than CListCtrl::GetStringWidth, but both ignore the space between the column border and the text, and I can't figure howto determine the size of that... I tryed using GetSystemMetrics with SM_CXFIXEDFRAME and SM_CXEDGE, but they seem to be wrong. Any ideat? thanks

          R Offline
          R Offline
          Rage
          wrote on last edited by
          #4

          You could give the column header a fixed size and use LVSCW_AUTOSIZE_USEHEADER instead of LVSCW_AUTOSIZE. Anyway, you can get the longest string in the column, so just set the column width to this string width + a few pixels ? Or didn't I get the thing ? ~RaGE();

          P 1 Reply Last reply
          0
          • R Rage

            You could give the column header a fixed size and use LVSCW_AUTOSIZE_USEHEADER instead of LVSCW_AUTOSIZE. Anyway, you can get the longest string in the column, so just set the column width to this string width + a few pixels ? Or didn't I get the thing ? ~RaGE();

            P Offline
            P Offline
            Paolo Vernazza
            wrote on last edited by
            #5

            Using LVSCW_AUTOSIZE_USEHEADER has the same problem than using LVSCW_AUTOSIZE: if a non-visible string is longer than the header it isn't considered. Yes, what i'm doing il looking for the longest text extent (not the longest string, "w" is larger than "ll") and adding some pixel. But I would like to know how much should be "some pixel"... I think it depends on system font & some other param..

            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