Board index » cppbuilder » TListView, TListItem::DisplayRect(drIcon) returns rect.left = rect.right

TListView, TListItem::DisplayRect(drIcon) returns rect.left = rect.right


2006-06-24 05:47:04 AM
cppbuilder0
I am using a TListView with ViewStyle=vsReport and OwnerData=true.
I am also doing custom drawing with a OnAdvancedCustomDrawItem event
handler.
When I try to get the rect for drawing the stateimage with:
TRect rect = Item->DisplayRect(drIcon);
I get a rect with left and right both = 20.
I have also tried using API call, with the same results:
RECT rect = {LVIR_ICON, 0, 0, 0};
SendMessage(ListView1->Handle, LVM_GETITEMRECT, Item->Index,
LPARAM)(&rect));
Am I missing or misunderstanding something?
Thanks in advance,
Daniel
 
 

Re:TListView, TListItem::DisplayRect(drIcon) returns rect.left = rect.right

"Daniel Wong" < XXXX@XXXXX.COM >wrote in message
Quote
When I try to get the rect for drawing the stateimage with:
TRect rect = Item->DisplayRect(drIcon);
I get a rect with left and right both = 20.
As you should be. What exactly are you having a problem with?
Quote
I have also tried using API call, with the same results:
That is the same code that DisplayRect() uses internally.
Gambit
 

Re:TListView, TListItem::DisplayRect(drIcon) returns rect.left = rect.right

Remy Lebeau (TeamB) wrote:
Quote
>TRect rect = Item->DisplayRect(drIcon);
>I get a rect with left and right both = 20.

As you should be. What exactly are you having a problem with?
I would have expected it to return a rect, with left = 0 and right = 20,
that can be used to draw the stateimage to the left of item caption. Is
there a reason why it doesn't?
I currently manually set left=0 after calling DisplayRect(), but that
seems kludgy, does it not?
What is the proper way to get the rect to draw a state image left of the
caption in a vsReport styled listview?
Daniel
 

{smallsort}

Re:TListView, TListItem::DisplayRect(drIcon) returns rect.left = rect.right

"Daniel Wong" < XXXX@XXXXX.COM >wrote in message
Quote
I would have expected it to return a rect, with left = 0 and right = 20
Why would you expect that? You told it to give you the rect for the icon,
so it did. The fact that there is an 20 pixels on the left suggests to me
that you have a second icon for each item. Are you using both the
SmallImages and StateImages properties to TListView?
Quote
that can be used to draw the stateimage to the left of item caption.
That is exactly what it is already giving you.
Quote
What is the proper way to get the rect to draw a state image left
of the caption in a vsReport styled listview?
You are already doing it.
Gambit
 

Re:TListView, TListItem::DisplayRect(drIcon) returns rect.left = rect.right

Remy Lebeau (TeamB) wrote:
Quote
>I would have expected it to return a rect, with left = 0 and right = 20

Why would you expect that? You told it to give you the rect for the icon,
so it did.
At first, I couldn't understand why your responses were so
as-a-matter-of-fact. But now they have made me realize my
misunderstanding of the purpose of StateImages. I should have been using
SmallImages all along (duh!). Thus explains my incorrect expectations.
Thanks for your help.
Daniel