简体   繁体   English

在CListCtrl中向图像添加状态图标

[英]Add status icon to image in CListCtrl

I have a CListCtrl in MFC where I am appending a set of 128x128 pixel images. 我在MFC中有一个CListCtrl,其中要附加一组128x128像素的图像。 Now I would like to append a 16x16 small status icon (OK/NOK style) to those images. 现在,我想向这些图像添加一个16x16的小状态图标(确定/否样式)。 How can I do this? 我怎样才能做到这一点?

I think this may not solve your problem, but is near to be a solution. 我认为这可能无法解决您的问题,但是几乎可以解决。

CBitmap drawBitmap;

HICON hicon= m_pImageList->ExtractIcon(ix);
drawBitmap.Attach(hicon);

CDC dc;
dc.CreateCompatibleDC(NULL);
dc.SetBkMode(TRANSPARENT);


CPoint pt;
// do your calculations: pt will be define in what part of the image the icon will appear 
DrawIcon(&dc.GetSafeHdc(), pt.x, pt.y, IDI_YOUR_ICON);
DeleteDC(dc);

m_pImageList->Replace(ix, &drawBitmap, (CBitmap*)NULL);

ix is the index of the one you want to replace. ix是您要替换的索引。

Just after posting previous answer, I discovered that it exists CImageList::SetOverlayImage 发布之前的答案后,我发现它存在CImageList :: SetOverlayImage

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM