开发者

CListCtrl and thumnail fails to draw

I use the folow code to create a thumbnail for list control

HDC hDC=::GetDC(hWnd);
HDC pDC=::CreateCompatibleDC(hDC);
HBITMAP bm=::CreateCompatibleBitmap(hDC,THUMBNAIL_W,THUMBNAIL_H);
HBITMAP oldBmp=(HBITMAP)SelectObjec开发者_开发技巧t(pDC,bm);           
img.StretchBlt(pDC,rcBorder); 
CBitmap bmp;
bmp.Attach(bm);
m_imgLst.Add(&bmp,RGB(0,0,0));

a big image is load, it is store in CImage as

CImage img;

but the thumbnail is black, nothing is drawn

the above code

img.StretchBlt(pDC,rcBorder); doesn't do a thing.


This is an incomplete and poorly worded question. Mixing and matching Windows API, MFC, and GdiPlus is fine but without giving enough relevant code or explanation all anyone can do is guess at your problem.

That said here's my guess. The symptom of a black bitmap usually means your bit depth was wrong. I have no idea what you are doing with CImage but the code above looks fine albeit missing any validation of success on the API called.

I'll further assume that m_imgLst is an MFC CImageList object in which case a likely mistake was in the .Create call elsewhere on that object with an incompatible bit depth or dimensions for the image you are now trying to add.

You can test my theory by checking the return value of .Add it should be the index of the newly inserted image or -1 if it fails.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜