I am having trouble in CE BltBit from a previously created compatable hdc to device's hdc.
The following code works:
hdc = pdis->hDC;
FillRect(hdc, &(pdis->rcItem), 开发者_高级运维(HBRUSH)GetStockObject(BLACK_BRUSH));
ImageList_Draw(himl, imageIndex, hdc, 15 , 30, ILD_NORMAL);
However the following just draws the black rectangle and does not put the image on top.
hdc = pdis->hDC;
hdcmem = CreateCompatibleDC(hdc);
FillRect(hdc, &(pdis->rcItem), (HBRUSH)GetStockObject(BLACK_BRUSH));
ImageList_Draw(himl, imageIndex, hdcmem, 0 , 0, ILD_NORMAL);
BitBlt(hdc, 15, 30, 130, 100, hdcmem, 0, 0, SRCCOPY);
Any ideas most welcome.
Best regards E
CreateCompatibleDC
doesn't do what you think it does. From the linked page:
Before an application can use a memory device context for drawing operations, it must select a bitmap of the correct width and height into the device context. This may be done by using
CreateCompatibleBitmap
to specify the height, width, and color organization required in the function call.
Device contexts are an abstraction. There must be a storage behind them -- a screen or, in your case, a bitmap.
精彩评论