BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SubItemImages

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Paul Dowd
Guest





PostPosted: Wed Sep 06, 2006 3:36 pm    Post subject: SubItemImages Reply with quote



Hi,

I have a TListView in which I want to put a different symbol in each row
of one of the subitem columns, drawn in a different colour. The only way
I can seem to achieve this is by doing it in the CustomDrawSubItem event
like this:

//---------------------------------------------------------------------------
void __fastcall TP12DXF::RecordsCustomDrawSubItem(TCustomListView *Sender,
TListItem *Item, int SubItem, TCustomDrawState State, bool
&DefaultDraw)
{
DefaultDraw = false;
TListView *L = (TListView*)Sender;
TPoint p = Item->GetPosition();
p.x = 5;
for(int i=0; i<SubItem; i++)
p.x += L->Column[i]->Width;
SubItem--;
L->Canvas->Brush->Color = clWhite;
L->Canvas->Pen->Color = clWhite;
L->Canvas->FloodFill(p.x, p.y, p.x + L->Column[SubItem]->Width - 1,
L->Canvas->TextHeight("X"));
L->Canvas->Pen->Color = clBlack;
if(SubItem == SYMBOL)
{
SymbolList->BkColor = Colour[parms.record[Item->Index].colour];
SymbolList->Draw(L->Canvas, p.x, p.y,
parms.record[Item->Index].symbol, dsNormal, itImage, true);
}
else if(SubItem == SYMBOL_SIZE)
L->Canvas->TextOut(p.x, p.y, parms.record[Item->Index].symbol_size);
else if(SubItem == LABEL_SIZE)
L->Canvas->TextOut(p.x, p.y, parms.record[Item->Index].label_size);
else if(SubItem == LABEL_POS)
L->Canvas->TextOut(p.x, p.y,
LabelPosition[parms.record[Item->Index].label_pos]);
else if(SubItem == LABEL_INT)
L->Canvas->TextOut(p.x, p.y, parms.record[Item->Index].label_int);
else if(SubItem == LAYER)
L->Canvas->TextOut(p.x, p.y,
LayerName[parms.record[Item->Index].layer]);
strcpy(LayerName[0], Item->Caption.c_str());
}
//---------------------------------------------------------------------------


However, this updates VERY slowly. Is there not a way of doing this
using the SubItemImages property?

Paul
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Sep 06, 2006 9:29 pm    Post subject: Re: SubItemImages Reply with quote



"Paul Dowd" <paul (AT) fgps (DOT) com> wrote in message
news:44fea45f$1 (AT) newsgroups (DOT) borland.com...

Quote:
However, this updates VERY slowly. Is there not a way of doing this
using the SubItemImages property?

Simply assign a TImageList to the TListView::SmallImages property, and then
set the TListItem::SubItemImages property to the desired indexes.


Gambit
Back to top
Paul Dowd
Guest





PostPosted: Thu Sep 07, 2006 1:49 pm    Post subject: Re: SubItemImages Reply with quote



Hi,

When I try this I get an image in the first column when the row is
highlighted (in fact I dont want any image in the first column), but do
not get any image in the column I want. I am trying this:

....
Records->Items->Item[i]->SubItemImages[1] = parms.record[i].symbol;
....

Could it be something to do with the masking? I have tried all
combinations of settings but am getting nowhere!

Paul

Remy Lebeau (TeamB) wrote:
Quote:

Simply assign a TImageList to the TListView::SmallImages property, and then
set the TListItem::SubItemImages property to the desired indexes.
Back to top
Paul Dowd
Guest





PostPosted: Thu Sep 07, 2006 1:49 pm    Post subject: Re: SubItemImages Reply with quote

Hi,

When I try this I get an image in the first column when the row is
highlighted (in fact I dont want any image in the first column), but do
not get any image in the column I want. I am trying this:

....
Records->Items->Item[i]->SubItemImages[1] = parms.record[i].symbol;
....

Could it be something to do with the masking? I have tried all
combinations of settings but am getting nowhere!

Paul

Remy Lebeau (TeamB) wrote:
Quote:

Simply assign a TImageList to the TListView::SmallImages property, and then
set the TListItem::SubItemImages property to the desired indexes.
Back to top
Paul Dowd
Guest





PostPosted: Thu Sep 07, 2006 1:50 pm    Post subject: Re: SubItemImages Reply with quote

Hi,

When I try this I get an image in the first column when the row is
highlighted (in fact I dont want any image in the first column), but do
not get any image in the column I want. I am trying this:

....
Records->Items->Item[i]->SubItemImages[1] = parms.record[i].symbol;
....

Could it be something to do with the masking? I have tried all
combinations of settings but am getting nowhere!

Paul

Remy Lebeau (TeamB) wrote:
Quote:

Simply assign a TImageList to the TListView::SmallImages property, and then
set the TListItem::SubItemImages property to the desired indexes.
Back to top
Paul Dowd
Guest





PostPosted: Thu Sep 07, 2006 7:40 pm    Post subject: Re: SubItemImages Reply with quote

Another thing I have noticed in trying to solve this problem is that the
OnGetSubItemImage event is not being triggered - could this be related?

Paul

Remy Lebeau (TeamB) wrote:
Quote:
"Paul Dowd" <paul (AT) fgps (DOT) com> wrote in message
news:44fea45f$1 (AT) newsgroups (DOT) borland.com...

However, this updates VERY slowly. Is there not a way of doing this
using the SubItemImages property?

Simply assign a TImageList to the TListView::SmallImages property, and then
set the TListItem::SubItemImages property to the desired indexes.


Gambit

Back to top
Paul Dowd
Guest





PostPosted: Thu Sep 07, 2006 7:57 pm    Post subject: Re: SubItemImages Reply with quote

I have found the problem: if the TListView has checkboxes then the
SubItemImages are not displayed.

Is there a way around this?

Paul

Remy Lebeau (TeamB) wrote:
Quote:
"Paul Dowd" <paul (AT) fgps (DOT) com> wrote in message
news:44fea45f$1 (AT) newsgroups (DOT) borland.com...

However, this updates VERY slowly. Is there not a way of doing this
using the SubItemImages property?

Simply assign a TImageList to the TListView::SmallImages property, and then
set the TListItem::SubItemImages property to the desired indexes.


Gambit

Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Sep 07, 2006 9:26 pm    Post subject: Re: SubItemImages Reply with quote

"Paul Dowd" <paul (AT) fgps (DOT) com> wrote in message
news:4500333a$1 (AT) newsgroups (DOT) borland.com...

Quote:
I have found the problem: if the TListView has checkboxes
then the SubItemImages are not displayed.

What you describe is caused by a bug (or intentionally design?) in the
ComCtrls unit, specifically in the ResetExStyles() method of
TCustomListView, that does not allow the LVS_EX_SUBITEMIMAGES and
LVS_EX_CHECKBOXES styles to be active at the same time. There are only two
workarounds:

1) set the CheckBoxes property to false (so that SubItemImages will work)
and then use your own TImageList for the StateImages property to manage the
checkbox images manually.

2) disable runtime packages in your project (if you have not already done
so), then add ComCtrls.pas to your project, and then change this line:

if FCheckboxes then Styles := LVS_EX_CHECKBOXES;

To this instead:

if FCheckboxes then Styles := Styles or LVS_EX_CHECKBOXES;


Gambit
Back to top
Paul Dowd
Guest





PostPosted: Fri Sep 08, 2006 10:32 pm    Post subject: Re: SubItemImages Reply with quote

Thanks for your help. I have in fact already gone for option 1) below
which works fine.
Paul

Remy Lebeau (TeamB) wrote:
Quote:

What you describe is caused by a bug (or intentionally design?) in the
ComCtrls unit, specifically in the ResetExStyles() method of
TCustomListView, that does not allow the LVS_EX_SUBITEMIMAGES and
LVS_EX_CHECKBOXES styles to be active at the same time. There are only two
workarounds:

1) set the CheckBoxes property to false (so that SubItemImages will work)
and then use your own TImageList for the StateImages property to manage the
checkbox images manually.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.