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. Manually implement LVSCW_AUTOSIZE_USEHEADER

Manually implement LVSCW_AUTOSIZE_USEHEADER

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 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.
  • W Offline
    W Offline
    Wim Jans
    wrote on last edited by
    #1

    Hello, I'm interested in the process behind the LVSCW_AUTOSIZE_USEHEADER used to set the width of the header control of a CListCtrl. Does anybody know how they calculate the exact width of the text. This is based of the font used. What is I want to write this myself? m_cListCtrl.SetColumnWidth(i, CString("This is Column1).GetLength()) gives me the length of the string (15 points), but what I think I need to do is multiply this length by the average length (in points) of the characters used in the string. Let's say a character average width is 6 points, my header will be 15 (=GetLength)*6, which is a reasonable width for the header. Anybody knows of such a function. Or how I really should tackle this? Thanks in advance Wim

    D 1 Reply Last reply
    0
    • W Wim Jans

      Hello, I'm interested in the process behind the LVSCW_AUTOSIZE_USEHEADER used to set the width of the header control of a CListCtrl. Does anybody know how they calculate the exact width of the text. This is based of the font used. What is I want to write this myself? m_cListCtrl.SetColumnWidth(i, CString("This is Column1).GetLength()) gives me the length of the string (15 points), but what I think I need to do is multiply this length by the average length (in points) of the characters used in the string. Let's say a character average width is 6 points, my header will be 15 (=GetLength)*6, which is a reasonable width for the header. Anybody knows of such a function. Or how I really should tackle this? Thanks in advance Wim

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Wim Jans wrote: Does anybody know how they calculate the exact width of the text. CListCtrl::GetStringWidth() would be one way.


      Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

      W 1 Reply Last reply
      0
      • D David Crow

        Wim Jans wrote: Does anybody know how they calculate the exact width of the text. CListCtrl::GetStringWidth() would be one way.


        Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

        W Offline
        W Offline
        Wim Jans
        wrote on last edited by
        #3

        And a nice way to do it! Just fits my needs. Thanks for that :)

        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