Board index » cppbuilder » Using vsReport with a virtual-mode TListView

Using vsReport with a virtual-mode TListView


2005-11-01 07:53:30 PM
cppbuilder52
I'm trying to speed up a TListView by setting OwnerData true (to enable
virtual mode) in BCB5.
Generally speaking, things are going well (thanks to help from a BCB Journal
article from 2000), but I'm hitting a brick wall trying to implement proper
support for vsReport. I'm creating TListColumn instances at run-time and
setting their Width properties to ColumnHeaderWidth, but in virtual mode all
I get is columns that are all at position 0 (in the header control) with
Width -2.
Setting AutoSize true has no effect on the problem.
All the changes are in BeginUpdate-EndUpdate blocks, for both Items and
Columns.
If I use a 'real' width (i.e. not one of the constants -1 or -2) the columns
are fine.
Does anyone have any ideas? I'm not averse to handling listview WM_NOTIFYs
if need be, but if a simple change will let me use the VCL properties, it'll
save me a lot of time.
Many thanks,
GT
 
 

Re:Using vsReport with a virtual-mode TListView

"Graham Thompson" < XXXX@XXXXX.COM >wrote in
message news:43675731$ XXXX@XXXXX.COM ...
Quote
I'm creating TListColumn instances at run-time and setting their Width
properties to ColumnHeaderWidth, but in virtual mode all I get is
columns that are all at position 0 (in the header control) with Width -2.
Auto-size columns are not supported for a virtual ListView. TListView does
not call ListView_SetColumnWidth() for vsReport when OwnerData is set to
True. You will have to call ListView_SetColumnWidth() manually after adding
your columns to the ListView.
Gambit
 

Re:Using vsReport with a virtual-mode TListView

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote
Auto-size columns are not supported for a virtual ListView. TListView
does
not call ListView_SetColumnWidth() for vsReport when OwnerData is set to
True. You will have to call ListView_SetColumnWidth() manually after
adding
your columns to the ListView.
Ah well, I thought that might be the case; I guess I'll have to calculate a
suitable width myself using ListView_GetStringWidth() for each item to find
the widest 'cell'. I notice TCustomListView has a wrapper for it
(TCustomListView.StringWidth()) but doesn't appear to call it. I was hoping
to use TCustomListView.UpdateColumn() but that's where the '...not
OwnerData' condition kicks in, so that's a non-starter.
Thanks for the advice,
GT
 

{smallsort}

Re:Using vsReport with a virtual-mode TListView

"Graham Thompson" < XXXX@XXXXX.COM >wrote in
message news: XXXX@XXXXX.COM ...
Quote
Ah well, I thought that might be the case; I guess I'll have to
calculate a suitable width myself using ListView_GetStringWidth()
for each item to find the widest 'cell'.
That is not needed. Nor is that what ColumnHeaderWidth does in the first
place, either. What you describe is handled by ColumnTextWidth instead.
In any case, as I mentioned earlier, you can simply call
TreeView_SetColumnWidth() yourself after adding your columns. Specify the
column's WidthType property as the width value. For example:
{
int NumColumns = 5;
for(int x = 0; x < NumColumns; ++x)
{
TListColumn *Column = ListView1->Columns->Add();
Column->Caption = "...";
Column->Width = ColumnHeaderWidth;
}
// needs to be done after all columns have been added,
// or else they are not sized properly...
for(int x = 0; x < NumColumns; ++x)
{
TListColumn *Column = ListView1->Columns->Items[x];
ListView_SetColumnWidth(ListView1->Handle, Column->Index,
Column->WidthType);
}
}
Gambit
 

Re:Using vsReport with a virtual-mode TListView

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote
That is not needed. Nor is that what ColumnHeaderWidth does in the first
place, either. What you describe is handled by ColumnTextWidth instead.
Interesting ... the code you suggested is what I had used myself with
virtual-mode and ColumnHeaderWidth, and it worked exactly as it says on the
tin.
But ... the reason I went with ColumnHeaderWidth in the first place is that
I've always used it in design-time list views and columns have resized
themselves to which ever was the larger - column heading or content. I
stumbled across this by:
(a) Adding a listview in vsReport at design-time, with the
required number of columns. Each column had AutoSize false
and taLeftJustify.
(b) In the form's constructor, loop around the column collection
setting "ListView1->Column[iColumn]->Width = ColumnHeaderWidth"
Then, as long as more than one Item is added, the columns size as described.
I'd always assumed this was undocumented side-effect...
Anyway - back to the virtul-mode TListView, I'll look into the column
dragging etc. too, since it looks like I might need to do a little
double-buffering...
Thanks once again Remy,
GT