Thanks for your reply. While the TListView has its pluses and minuses, the
fact remains that the documentation for TListView's AutoSize property
explicitly states, and I quote:
"Use AutoSize to get or set whether the list column automatically sizes
itself to the width of its text."
It does not say "Use AutoSize to get or set whether the list column is sized
to a fraction of the total list view width". The width of the text in the
column has no effect on the column width at all, despite what the
Post by Asger JoergensenYou are right about the documentation, but I think You should see it
as an extra feature, using the VCL way get rid of the horizontal scrollbar
and autosize all in view.
This is not quite accurate: Setting AutoSize to true does not actually get
rid of the horizontal scroll bar. When a vertical scroll bar is present,
AutoSize still sets the total width of all columns to the actual width of
the ListView control, thus -always- creating a horizontal scroll bar (when a
vertical one is present).
No matter how you look at it, something is wrong. Whether it's the
documentation or the implementation of AutoSize itself, I wouldn't be able
to say.
Post by Asger JoergensenIt is strange, because I cant reproduce it on my PC, but then again
I still use BCB5 and WinXP..;-)
I'm sure there is a difference between BCB5 and 2007 -- I am also using
Windows XP (SP2).
Post by Asger JoergensenYou might have an open mind, but it is a little as if You are comparing
good working close with lastes fashion, the VCL does not implement every
feature of the windows controls and it does not have all the latest, but
it make it very easy to do windows programming and it does not lock You
in any way.
You are right. I really like C++ Builder and that was a little snippy of me
to say. However, AutoSize does not work as expected. And while it was easy
for me, I only knew about that ListView macro (and though to try sending
standard shell list view messages to Borland's ListView control) because I
have some experience with Windows development outside of C++ Builder. This
would not always be the case, and had C++ Builder been my introduction to
Windows programming, I would never have found a solution considering what
the 2007 documentation says about the property.
Post by Asger JoergensenIf You look at Your own code snippet You used the VCL implementation of
the columns and the ListView->Handle to make Your calls to the API listview
function. It is made easy for You..
It's true, it is easy. What worries me about this solution is I feel that it
is a hack: Nowhere does it say that TListView is based on the shell list
view control, and therefore I can not in good conscience bring myself to
rely on the fact that TListViews will accept Windows shell list view
messages (the macro I used is a shortcut for SendMessage(...,
LVM_SETCOLUMNWIDTH, ..., ...)). When I said it "bypasses the VCL
interfaces", I meant that I had to go around the normal properties and
methods of the TListView class itself, and instead use it's Window handle to
call Win32 API functions directly -- functions that are not necessarily
guaranteed to work on TListViews in the first place, if that makes sense.
Post by Asger JoergensenI do admit that the listview You precented looks very strange and I hope
someone will be able to help You find the error.
If I find the drawing error, I will post it here for sure. I have not found
a solution yet, and thanks again for your suggestions. I appreciate it. I'll
keep looking. As far as the AutoSize thing goes, although I don't like it,
the above ListView_SetColumnWidth macros can be used as a workaround for
now.
Jason