如何更改项目大小以及它们之间的差距在自定义的CListCtrl淹没 [英] How to change item size and gap between them in Custom Drown CListCtrl

查看:155
本文介绍了如何更改项目大小以及它们之间的差距在自定义的CListCtrl淹没的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知 ON_WM_MEASUREITEM 不会被调用的自定义绘制列表控件。如果控制所有者绘制它仅使用。

As far as I know ON_WM_MEASUREITEM does not get called in Custom Draw list control. It is only used if control is Owner Drawn.

我已经找到一种方法来做到这一点,但它是有点一个黑客,我仍然无法控制,他们在某种程度上自动设置项目之间的差距。

I have found a way to do that, but it is somewhat a HACK and I still can not control gaps between items they are set up somehow automatically.

的技巧是,你可以创建 CImageList 与你需要的大小的未使用的图像,而如果您分配这样的图像列表,该列表控制,项目将调整到尺寸接近的图像的大小。之后,你可以使用自定义绘制画里面的任何扩大这些项目。

The trick is that you can create CImageList with the unused images of the size you need and if you assign such image list to the list control, items get resized to the dimensions close to the size of the images. After that you can use Custom Draw to paint whatever inside those enlarged items.

CImageList m_imageList1;
m_imageList1.Create(176, 144, ILC_COLOR32 | ILC_MASK, 5, 1);
GetListCtrl().SetImageList(&m_imageList1, LVSIL_NORMAL);

所以,问题是你如何改变项目大小和它们之间的间距在自定义淹死控制?

So the question is how do you change items size and spacing between them in Custom Drown control?

或用充满所有者绘制控件 LVS_OWNERDRAWFIXED 我是这里唯一的选择?

Or a fully Owner Drawn control with LVS_OWNERDRAWFIXED is my only option here?

推荐答案

更​​新。结果
我编在VS2008相同的自定义绘制的列表控件。和外观是不同的。该项目的大小是完美的,与项目之间没有空隙。我想,上浆问题,我只是在为MFC VS2003,我用最初。结果
人,MFC是一个常数HACK US preE :-)结果
结果
我想问题是封闭的。结果谢谢(我)。

Update.
I have compiled the same custom drawn list control in VS2008. And the look was different. The item size was perfect, and no gaps between the items. I guess that sizing problem I had was only in MFC for VS2003, I was using initially.
Man, MFC is a constant HACK spree :-)

I guess the question is closed.
Thank you (me).

这篇关于如何更改项目大小以及它们之间的差距在自定义的CListCtrl淹没的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆