Board index » delphi » TListView in ViewStyle := vsList mode - ARRRGH

TListView in ViewStyle := vsList mode - ARRRGH

This is a multi-part message in MIME format.
--------------519BF61D348570F3EA0DD944
Content-Type: text/plain; charset=us-ascii
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Transfer-Encoding: 7bit

I want to present some info in a TListView and use the list view mode.
Hovewer, I have not been able to figure out how to tell the listview how
much text there is room for, to stop the ellipses (...) from appearing.
With the default column widht, the item strings I put in are too long.

After some looking in the win32 reference I found that by using this
call

  ListView_SetColumnWidth(PatchView.Handle, 0,
PatchView.StringWidth('WWWWWWWWWWWWWWWWW'));

I get the column in list mode to appear wider than the default. The
items, hovewer, still take up the same amount of space that they did
before.

It should be possible, at least the Explorer program seems to be able to
automatically scale the column widht to the textlength in list mode...

--------------519BF61D348570F3EA0DD944
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Eivind Bakkestuen
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Eivind Bakkestuen
n:              ;Eivind Bakkestuen
email;internet: eiv...@hypersoft.no
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
end:            vcard

--------------519BF61D348570F3EA0DD944--

 

Re:TListView in ViewStyle := vsList mode - ARRRGH


Quote
Eivind Bakkestuen wrote:

> I want to present some info in a TListView and use the list view mode.
> Hovewer, I have not been able to figure out how to tell the listview how
> much text there is room for, to stop the ellipses (...) from appearing.
> With the default column widht, the item strings I put in are too long.

> After some looking in the win32 reference I found that by using this
> call

>   ListView_SetColumnWidth(PatchView.Handle, 0,
> PatchView.StringWidth('WWWWWWWWWWWWWWWWW'));

> I get the column in list mode to appear wider than the default. The
> items, hovewer, still take up the same amount of space that they did
> before.

> It should be possible, at least the Explorer program seems to be able to
> automatically scale the column widht to the textlength in list mode...

Tried this?

ListView_SetColumnWidth(hwnd, col, LVSCW_AUTOSIZE)

or LVSCW_AUTOSIZE_USEHEADER

In case they ain't defined in Delphi:
  Autosize = -1
  AutoSize_UseHeader = -2

Regards,

Erik.

--
Independent contracting - Development of applications and drivers
for DOS, Win 3.1, Win 95, Win NT.

Visit http://www.info-pro.no/sperling for some free Delphi source.

Erik Sperling Johansen <e...@info-pro.no>

Re:TListView in ViewStyle := vsList mode - ARRRGH


This is a multi-part message in MIME format.
--------------756C43A5FC858C12ABEF23F0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Quote
> > It should be possible, at least the Explorer program seems to be
> able to
> > automatically scale the column widht to the textlength in list
> mode...

> Tried this?

> ListView_SetColumnWidth(hwnd, col, LVSCW_AUTOSIZE)

> or LVSCW_AUTOSIZE_USEHEADER

Yes. Nothing happens at all... I also tried using the message directly,
but same (no) results. The reason for trying it directly is something
that I suspect is a bug in the D3 implementation of
ListView_SetColumnWidth (or a documentation bug on M$' part... see the
win32 help file topic on ListView_SetColumnWidth). It is implemented
like this:

function ListView_SetColumnWidth(hwnd: HWnd; iCol: Integer; cx:
Integer): Bool;
begin
Result := Bool( SendMessage(hwnd, LVM_SETCOLUMNWIDTH, iCol,
    MakeLong((cx), 0)) );
end;

the problem is with the MakeLong statement. I can't figure out why
someone would want to chop off the top 16 bits of the 32bit integer cx,
especially since the constants you mention are negative (high bit set)
and thus are bound to end up as totally different from what they should
be after the trip through MakeLong, wich takes two 16bit word values as
parameters. The funny thing is, if you try to compile the statement
MakeLong(LVSCW_AUTOSIZE, 0) in your own Delphi code you can't; you get a
range error...

On top of this, the win32 topic also states that the icol parameter
should be -1 when the ListView is in list mode. This doesn't seem to be
correct, either, because sendmessage() returns false if I pass "1", but
true if I pass in "0" as column. Hm... could I be having an out-of-date
dll, despite having installed the latest MSIE? What date should
comctl32.dll have?
--------------756C43A5FC858C12ABEF23F0
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Eivind Bakkestuen
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Eivind Bakkestuen
n:              ;Eivind Bakkestuen
email;internet: eiv...@hypersoft.no
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
end:            vcard

--------------756C43A5FC858C12ABEF23F0--

Other Threads