使用Virtual CListCtrl和图标的奇怪行为 [英] Weird behaviour with Virtual CListCtrl and icons

查看:89
本文介绍了使用Virtual CListCtrl和图标的奇怪行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个虚拟的CListCtrl m_Infobox,它处理LVN_GETDISPINFO.它有1列,没有coulumn标头.
它具有图像列表:

I have a virtual CListCtrl, m_Infobox, that handles LVN_GETDISPINFO. It has 1 column and no coulumn headers.
It has an image list:

m_VirtualImageList.Create(16, 16, ILC_COLOR32 | ILC_MASK, 1,1);
m_Infobox.SetImageList(&(m_imagelistUtil.m_VirtualImageList), LVSIL_SMALL);


在OnGetdispinfo中,当列表需要文本时我会处理


In OnGetdispinfo i handle when the list wants text

if (pItem->mask & LVIF_TEXT) {
  lstrcpyn(pItem->pszText, m_csColumn1, pItem->cchTextMax);
}


而且效果很好.但是当我为图标添加处理功能时,事情就开始出错了.


and that works just fine. But when I add handling for icons thing start to go wrong.

if( pItem->mask & LVIF_IMAGE) {
  HICON hIcon = reinterpret_cast<HICON>(::LoadImage ( AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_COPY),IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR));
  m_imagelistUtil.m_VirtualImageList.Replace(0,hIcon);
  pItem->iImage = 0;
}


当我开始工作并在处理文件时添加行时,前几百行工作正常,然后列表变为空白或开始在整个对话框中绘制线,而不仅仅是在listctrl中.
仅当我尝试在每行上插入图标时才会发生这种情况.
在上面的示例中,我尝试对所有行使用相同的图标,但是获取图标(资源,其他图像列表,系统图像列表)的位置无关紧要,行为是相同的.

关于使用图标,我有什么不了解的地方吗?

我已经在网络上搜索并尝试了所有可以想到的内容,但是我没有想法.

感谢所有建议.

最好的问候,
Urban Dahlberg


When I start a job and add rows as I process files, the first few hundred lines works fine, then the list either goes blank or start drawing its lines all over the dialog, and not just in the listctrl.
This only happens when I try to insert icons on each row.
In the example above I try to use the same icon for all rows, but it doesn''t matter where I get the icons (resource, other image list, system image list), the behaviour is the same.

Is there something I don''t understand in regards to working with icons?

I have searched the web and tried everything I can think of, and I''m out of ideas.

All suggestions appreciated.

Best regards,
Urban Dahlberg

推荐答案

看看本文的基本用法:
使用列表控件 [ http://www.codeproject.com/KB/list/ [
Take a look at this article for basic usage:
Using the List Control[^]

And see the section dedicated to the CListCtrl here in CP:
http://www.codeproject.com/KB/list/[^]

There are plenty of samples there, I''m sure one or another will help you.

Good luck!


这篇关于使用Virtual CListCtrl和图标的奇怪行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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