Board index » cppbuilder » TListView images for Captions and Items

TListView images for Captions and Items


2004-02-14 11:39:39 PM
cppbuilder77
Hi,
I have problems with positioning images in TListView in report view.
I am using both SmallImages and StateImages (and BCB5).
SmallImages is used to add pictures to Columns (and this works OK).
StateImages is used to add images to list items.
StateImages are displayed incorrectly: they are shifted
upwards, and there is a horizontal space between images and item
text. How to position them correctly?
Another question is how to get the list item height (to prepare images
of the proper size)? And how to get the right size for the Caption
images?
Thank you,
Maciej
--
Maciej Komosinski, Ph.D. Institute of Computing Science
Poznan University of Technology, Poland
www.cs.put.poznan.pl/mkomosinski
 
 

Re:TListView images for Captions and Items

"Maciej Komosinski" < XXXX@XXXXX.COM >
wrote in message news:402e40c3$ XXXX@XXXXX.COM ...
Quote
StateImages are displayed incorrectly: they are shifted
upwards, and there is a horizontal space between images
and item text. How to position them correctly?
You have no control over the positioning unless you owner-draw the items
manually.
Quote
Another question is how to get the list item height (to prepare
images of the proper size)?
Retreive the bounding rectangle for any particular item. TListItem has a
DisplayRect() method, and then calculate the height from the TRect's Bottom
and Top values.
Gambit
 

Re:TListView images for Captions and Items

Quote
>StateImages are displayed incorrectly: they are shifted
>upwards, and there is a horizontal space between images
>and item text. How to position them correctly?

You have no control over the positioning unless you owner-draw the items
manually.
So the situation described above cannot be fixed (looks like
some bug) unless I owner-draw them?
Quote
>Another question is how to get the list item height (to prepare
>images of the proper size)?

Retreive the bounding rectangle for any particular item. TListItem has a
DisplayRect() method, and then calculate the height from the TRect's Bottom
and Top values.
I would like to know it even if there are no items.
I think it is a constant... maybe some helpful API function exists?
Thank you,
Maciej
 

{smallsort}

Re:TListView images for Captions and Items

"Maciej Komosinski" < XXXX@XXXXX.COM >
wrote in message news: XXXX@XXXXX.COM ...
Quote
So the situation described above cannot be fixed (looks like
some bug) unless I owner-draw them?
The VCL is not the one drawing the icons to begin with. The OS is. You
probably don't have your images sized correctly to begin with, so there is
extra bordering around the image where the OS is expecting normal image data
to actually be.
Quote
I would like to know it even if there are no items.
There is no way to get that value without at least 1 item available. The
underlying ListView control from the Win32 API simply does not provide
access to that value any other way. That is not a VCL limitation.
Gambit
 

Re:TListView images for Captions and Items

Quote
>StateImages are displayed incorrectly: they are shifted
>upwards, and there is a horizontal space between images
>and item text. How to position them correctly?

>Another question is how to get the list item height (to prepare
>images of the proper size)?

Retreive the bounding rectangle for any particular item. TListItem has a
DisplayRect() method, and then calculate the height from the TRect's Bottom
and Top values.
O.K. That is how I did.
I checked the Height() and it was 14. I prepared StateImages
of size 14x14, but it _still_ looks bad. See this picture:
arapi.w.interia.pl/bad_lv_img.gif
The arrow in Captions is from SmallImages,
the images for items are StateImages.
Yours,
Maciej
 

Re:TListView images for Captions and Items

"Maciej Komosinski" < XXXX@XXXXX.COM >
wrote in message news:40337065$ XXXX@XXXXX.COM ...
Quote
I checked the Height() and it was 14. I
prepared StateImages of size 14x14
You didn't take spacing around the items into account.
but it _still_ looks bad. See this picture:
Quote

arapi.w.interia.pl/bad_lv_img.gif
Are you, by chance, do any kind of owner-drawing yourself?
Gambit
 

Re:TListView images for Captions and Items

Quote
>I checked the Height() and it was 14. I
>prepared StateImages of size 14x14

You didn't take spacing around the items into account.
Yes, I didn't... How can I do this?
Quote
>but it _still_ looks bad. See this picture:
>arapi.w.interia.pl/bad_lv_img.gif

Are you, by chance, do any kind of owner-drawing yourself?
No, I don't :-)
I just manage two image lists and assign their indexes
to Captions and Items.
Maciej
 

Re:TListView images for Captions and Items

"Maciej Komosinski" < XXXX@XXXXX.COM >
wrote in message news:4034adb1$ XXXX@XXXXX.COM ...
Quote
Yes, I didn't... How can I do this?
Look at the LVM_GETITEMSPACING message (or the ListView_GetItemSpacing()
macro) in the Win32 API.
Gambit
 

Re:TListView images for Captions and Items

Quote
>Yes, I didn't... How can I do this?

Look at the LVM_GETITEMSPACING message (or the ListView_GetItemSpacing()
macro) in the Win32 API.
Is this supposed to return item spacing even for the vsReport
layout? I am using
DWORD spc=0;
spc=ListView_GetItemSpacing(lv->Handle,TRUE);
but spc always becomes 983146.
Maciej
 

Re:TListView images for Captions and Items

Quote
DWORD spc=0;
spc=ListView_GetItemSpacing(lv->Handle,TRUE);

but spc always becomes 983146.
Well, these are two values,
"The horizontal spacing is contained in the low-order WORD and the
vertical spacing is contained in the high-order WORD."
But if the image itself has 14 pixels, how can the spacing
be 000f and 006a...
Maciej
 

Re:TListView images for Captions and Items

Well, I will get the help I need from msdn docs for
the listview control.
Thanks for your help,
Maciej