Board index » cppbuilder » TListView and selected

TListView and selected


2006-09-07 08:08:05 AM
cppbuilder18
Can someone tell me what I need to do to make the selected
area of a customdraw cell on the listview to act the same way
as the other cells when you select the row.
For example, when you select a row the entire row turns to
blue, and the text appears white. Now on the customdraw
cell it stays white, there is no border or coloring.
I took this from a vcl component set that I am trying to figure
out that part on.
void __fastcall TDownLoaderTest::ListViewAdvancedCustomDrawSubItem(
TCustomListView *Sender, TListItem *Item, int SubItem,
TCustomDrawState State, TCustomDrawStage Stage, bool &DefaultDraw)
{
TclInternetItem *InternetItem = static_cast<TclInternetItem*>(Item->Data);
if ((!InternetItem) || (SubItem != 4)) return;
TRect R;
TclResourceStateList *ResourceState = InternetItem->ResourceState;
ListView_GetSubItemRect(Item->Handle, Item->Index, SubItem, LVIR_BOUNDS,
&R);
TControlCanvas *canvas = new TControlCanvas();
__try
{
canvas->Control = Sender;
clProgressBar->Draw(ResourceState, canvas, R);
}
__finally
{
delete canvas;
}
DefaultDraw = false;
}
Can someone help me out here.
Thanks.
 
 

Re:TListView and selected

"Curtis Richards" < XXXX@XXXXX.COM >wrote in message
Quote
For example, when you select a row the entire row turns to
blue, and the text appears white. Now on the customdraw
cell it stays white, there is no border or coloring.
You are setting the DefaultDraw parameter to false. That means that you are
entirely responsible for drawing everything about the item, including its
background.
Gambit
 

Re:TListView and selected

So if I set the parameter to DefaultDraw=true; will that handle the
selection of the entire row for me?
I just want the entire row to be highlighted with the default colors
that you seee when you select a row, nothing more.
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Curtis Richards" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>For example, when you select a row the entire row turns to
>blue, and the text appears white. Now on the customdraw
>cell it stays white, there is no border or coloring.

You are setting the DefaultDraw parameter to false. That means that you
are
entirely responsible for drawing everything about the item, including its
background.


Gambit


 

{smallsort}

Re:TListView and selected

"Curtis Richards" < XXXX@XXXXX.COM >wrote in message
Quote
So if I set the parameter to DefaultDraw=true; will that handle
the selection of the entire row for me?
Yes.
Quote
I just want the entire row to be highlighted with the default colors
that you seee when you select a row, nothing more.
Then you should not be drawing anything at all.
Gambit
 

Re:TListView and selected

You are confusing me here.
This is the code the author has put in his demo to show
his vcl component. The code is displaying a progress
bar in the column of the listview. What other way is
there to display the progressbar without drawing it in
there?
void __fastcall TDownLoaderTest::ListViewAdvancedCustomDrawSubItem(
TCustomListView *Sender, TListItem *Item, int SubItem,
TCustomDrawState State, TCustomDrawStage Stage, bool &DefaultDraw)
{
TclInternetItem *InternetItem = static_cast<TclInternetItem*>(Item->Data);
if ((!InternetItem) || (SubItem != 4)) return;
TRect R;
TclResourceStateList *ResourceState = InternetItem->ResourceState;
ListView_GetSubItemRect(Item->Handle, Item->Index, SubItem, LVIR_BOUNDS, &R);
TControlCanvas *canvas = new TControlCanvas();
__try
{
canvas->Control = Sender;
clProgressBar->Draw(ResourceState, canvas, R);
}
__finally
{
delete canvas;
}
DefaultDraw = true;
}
Can you please show me what you are talking about?
Thanks.
 

Re:TListView and selected

"Curtis Richards" < XXXX@XXXXX.COM >wrote in message
Quote
This is the code the author has put in his demo to show
his vcl component. The code is displaying a progress
bar in the column of the listview. What other way is
there to display the progressbar without drawing it in
there?
You are not taking the Stage parameter into account. You should set
DefaultDraw to true, and then draw your progress bar only when the Stage is
cdPostPaint. For example:
void __fastcall
TDownLoaderTest::ListViewAdvancedCustomDrawSubItem(TCustomListView *Sender,
TListItem *Item, int SubItem, TCustomDrawState State, TCustomDrawStage
Stage, bool &DefaultDraw)
{
DefaultDraw = true;
TclInternetItem *InternetItem =
static_cast<TclInternetItem*>(Item->Data);
if( (InternetItem) && (SubItem == 4) && (Stage == cdPostPaint) )
{
TclResourceStateList *ResourceState =
InternetItem->ResourceState;
TRect R;
ListView_GetSubItemRect(Item->Handle, Item->Index, SubItem,
LVIR_BOUNDS, &R);
clProgressBar->Draw(ResourceState, Sender->Canvas, R);
}
}
Gambit
 

Re:TListView and selected

Hi Gambit,
Just when I thought it was safe to go back in the water :)
First I would like to say thank you for helping me out in
trying to understand this better.
If you don't mind I uploaded an attachment in the attachments
group with two pics.
The first pic has the original code.
TclInternetItem *InternetItem =
static_cast<TclInternetItem*>(Item->Data);
if ((!InternetItem) || (SubItem != 4)) return;
TRect R;
TclResourceStateList *ResourceState = InternetItem->ResourceState;
ListView_GetSubItemRect(Item->Handle, Item->Index, SubItem,
LVIR_BOUNDS, &R);
TControlCanvas *canvas = new TControlCanvas();
__try
{
canvas->Control = Sender;
clProgressBar->Draw(ResourceState, canvas, R);
}
__finally
{
delete canvas;
}
DefaultDraw = true;
The second Pic has this code.
Quote
void __fastcall
TDownLoaderTest::ListViewAdvancedCustomDrawSubItem(TCustomListView
*Sender,
TListItem *Item, int SubItem, TCustomDrawState State,
TCustomDrawStage
Stage, bool &DefaultDraw)
{
DefaultDraw = true;

TclInternetItem *InternetItem =
static_cast<TclInternetItem*>(Item->Data);
if( (InternetItem) && (SubItem == 4) && (Stage ==
cdPostPaint) )
{
TclResourceStateList *ResourceState =
InternetItem->ResourceState;
TRect R;

ListView_GetSubItemRect(Item->Handle, Item->Index,
SubItem,
LVIR_BOUNDS, &R);
clProgressBar->Draw(ResourceState, Sender->Canvas, R);
}
}
There is no other drawing in the program. Do you have any idea how
come it's still
not highlighting the row? Also, what happened to the font in the
other column?
Thanks again