开发者

ImageList and BltBit - ting

开发者 https://www.devze.com 2022-12-09 12:48 出处:网络
I am having trouble in CEBltBit from a previously created compatable hdc to device\'s hdc. The following code works:

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.

0

精彩评论

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