Announcement

Collapse
No announcement yet.

Listview_SetColumnWidth(hWnd, iCol, %LVSCW_AUTOSIZE_USEHEADER)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Roger Garstang
    replied
    Actually by buffer I was meaning the space for the grid. Probably not needed, but if you use the API to size for your text and it still won't fit you could try adding 2-3 more to the width.

    As for the buffer for the actual text, use a MAX_PATH ASCIIZ as MCM suggested, then You will be safe when you assign text to it. As for the API calls, usually they have a text length parameter and if not you need to figure out what they will be assigning and allow for it or risk it writting over your memory.

    Leave a comment:


  • Michael Mattias
    replied
    Is there some off the wall value retrievable as a system setting that determines that "buffer" that listviews use on the column, or is it just part of the listview control?
    I have looked for this myself for years and never found it (I love the listview control). You'll just have to go with the flow and supply your own buffers as documented when you have data too long to fit the supplied buffer. I've never encountered a buffer less than %MAX_PATH if that helps.

    BTW, if you encounter data too long for the supplied buffer very often, I think I might start looking at using something other than a listview control for that presentation.

    MCM

    Leave a comment:


  • Adam J. Drake
    replied
    GetTextExtentPoint32?

    I hadn't thought to try that...

    Is there some off the wall value retrievable as a system setting that determines that "buffer" that listviews use on the column, or is it just part of the listview control?

    Leave a comment:


  • Roger Garstang
    replied
    This could be useful too since XP Themes have an issue autosizing the first column correctly...could be your problem in sizing to begin with too. SP3 still hasn't fixed this, but Vista has.

    There is an API to get the width needed to display a font of characters you pass it too if you aren't using it. May also be good to have a buffer for the grid of the cell too.

    Leave a comment:


  • Rodney Hicks
    replied
    Or if the data width is less than header width, increase the width of the data.
    In other words, a minimum width for data.

    Leave a comment:


  • Chris Holbrook
    replied
    Originally posted by Adam J. Drake View Post
    Well, I've calculated the data width, and I'm trying to make sure that for 1 character columns, the 3-4 character column headers show...My data width calculation for 1 character columns doesn't even allow 1 character to show fully.
    OK so create a structure containing the data width, or the column heading width, whichever is the larger, maybe with a limit for the too - wide columns.

    Leave a comment:


  • Adam J. Drake
    replied
    Well, I've calculated the data width, and I'm trying to make sure that for 1 character columns, the 3-4 character column headers show...My data width calculation for 1 character columns doesn't even allow 1 character to show fully.

    Leave a comment:


  • Chris Holbrook
    replied
    Originally posted by Adam J. Drake View Post
    Using LVSCW_AUTOSIZE_USEHEADER
    either you use the header width or the data width, why make it difficult by attempting both at the same time? Especially as you have already calculated the data width.

    Leave a comment:


  • Listview_SetColumnWidth(hWnd, iCol, %LVSCW_AUTOSIZE_USEHEADER)

    Using LVSCW_AUTOSIZE_USEHEADER for ListView_SetColumnWidth, is it possible to somehow calculate what that width should be prior to setting the column width?

    What I'm working on is creating a a display of sets of data where I have what each item's length is (giving me a sum total of the data length), and a column header as well for the ListView. The way I tried this at first was to proportionally size each column based on percentage of total data length, which works ok as long as the data length is not shorter than the column header.

    I want to make sure the column header shows, and columns with 1 byte of data show, but I'm struggling for ideas on how to turn this into a 'dynamic" algorithm to handle most situations.

    Any ideas or a shove in a different direction would be much appreciated.
Working...
X