Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi all,

I want to put icons in CListCtrl's item with space around the icons. To do it I need set CListCtrl's rows' height greater than icons' height, but I can not find any function like that in CListCtrl.
Using MeasureItem with owner-draw seem to be a overkill since i dont want to draw items by myself.

How can i do it without involving owner-draw?

Thanks in Advance.
Quy
Posted
Updated 23-Jun-11 19:02pm
v3

The easiest way to do that that I've used several times is to change the imagelist height.

You have to assign an invisible image to it and make it the height you need.

All done.

Hope this helps!

changes from here: I've not seen that you wanted to have the height bigger than the images inside... Apart of cheating making images bigger and transparent my solution won't help...
 
Share this answer
 
v2
Comments
quyps 26-Jun-11 21:21pm    
You suggestion is not exactly the solution, but it do give a hint. Items' height can be changed by size of imagelist which contains a fake image. Actual images should be drawn in postpaint draw stage of the control. I'm making a test. Very thanks.
Joan M 27-Jun-11 3:36am    
Glad to be helpful...
A variant of Joan Murt's solution is to pad your icons with a thick border around them, the same color as the list view background.
 
Share this answer
 
Comments
quyps 27-Jun-11 2:48am    
yes, you're right. Your solution work for what i need according to the question. However, my listctrl's item have different bg colors, and they are also not rectangular shape. If i padding space around icon i need to create icons for different backgrounds.
YDaoust 27-Jun-11 3:56am    
Transparent border ?
Thank all for help,

I have found a solution based on JoanMurt and YDaoust's suggestion.

1-Make a dump imagelist (without any real image) with desired size. It acts as placeholders in each list item.
2-Keep reference of really image list in listctrl object.
3-In Postpaint stage, draw images on placeholder's areas.


Quy
 
Share this answer
 
v2
Comments
YDaoust 27-Jun-11 3:57am    
Well done
Quy, I have no experience with this feature, but it seems that CListCtrl::SetWorkAreas might help you.
 
Share this answer
 
Comments
quyps 25-Jun-11 10:25am    
thanks, i made a test. SetWorkAreas just change the list's area in which all icons are displayed, and it is applied only for: icon layout and small icon layout.
What about SetItemPosition then ?
 
Share this answer
 
Comments
quyps 26-Jun-11 21:12pm    
Thanks, I did take a look. It's said in document that "The control must be in icon or small icon view.". My listctrl is set in detail view. I didnt try but i think this function is used to arrange item of CListCtrl in icon and small icon mode.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900