I am working on one MFC/SDI
project Where I am using CListView
as a default View.
But the thing is, I have applied ImageList
to the CListCtrl
but these Images are not clearly displayed.
As shown in the picture below.
Below is the code for creating new image List.
Creating ImageList
where m_ImgList
is a member of CImageList
.
if(m_ImgList->m_hImageList == NULL || m_ImgList->DeleteImageList() == TRUE)
{
m_ImgList->Create(16,16, ILC_COLOR,0, 1);
}
Then I am creating images by using BLOB data from database.
Here, pByte
is BYTE*
to hold BLOB
Data.
HGLOBAL hGlobal = ::GlobalAlloc(GMEM_MOVEABLE, nbytes+5);
LPVOID pV = GlobalLock(hGlobal);
memcpy(pV, pByte, nbytes);
GlobalUnlock(hGlobal);
LPSTREAM pstm = NULL;
HRESULT hr = CreateStreamOnHGlobal(hGlobal, TRUE, &pstm);
CImage image;
image.Load(pstm);
if (image == NULL)
{
image.Load(NILIMAGE);
}
CPaintDC dc(this);
CDC pMDC;
pMDC.CreateCompatibleDC(&dc);
CBitmap pb;
pb.CreateCompatibleBitmap(&dc, iNewWidth, iNewHeight);
CBitmap *pob = (CBitmap*)pMDC.SelectObject(&pb);
image.StretchBlt(pMDC.m_hDC,0, 0, iNewWidth, iNewHeight,
0, 0, image.GetWidth(), image.GetHeight(), SRCCOPY);
pMDC.SelectObject(pob);
Adding images to the image list
if((m_ImgList->Add(&pb, RGB(0,0,0)))== -1)
{
_T("undone");
}
if(hGlobal != NULL)
::GlobalFree(hGlobal);
Can anyone tell me how can I do that? Thank you in Advance. and Sorry for bad English.