Add status icon to image in CListCtrl

525 views Asked by At

I have a CListCtrl in MFC where I am appending a set of 128x128 pixel images. Now I would like to append a 16x16 small status icon (OK/NOK style) to those images. How can I do this?

2

There are 2 answers

1
sergiol On

Just after posting previous answer, I discovered that it exists CImageList::SetOverlayImage

1
sergiol On

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.