在CListCtrl中将状态图标添加到图像

时间:2015-06-18 11:17:39

标签: c++ mfc clistctrl

我在MFC中有一个CListCtrl,我附加了一组128x128像素图像。现在我想为这些图像添加一个16x16的小状态图标(OK / NOK样式)。我怎么能这样做?

2 个答案:

答案 0 :(得分:0)

我认为这可能无法解决您的问题,但接近成为一种解决方案。

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是您要替换的索引。

答案 1 :(得分:0)

在发布上一个答案后,我发现它存在CImageList::SetOverlayImage