How to draw a transparent image using WinAPI ImageList_DrawIndirect?
I need to draw a 32-bit image from a native API imagelist wi开发者_C百科th the specified level of transparency, but I can't do that. I'm using the ImageList_DrawIndirect
call and the ILS_ALPHA
image state in the IMAGELISTDRAWPARAMS
structure passed to ImageList_DrawIndirect
, but it seems it doesn't work as expected. ComCtl of v6 is "attached" to my app so it's not the reason of the problem.
How to do that?
My code looks like this:
Dim idp As IMAGELISTDRAWPARAMS
idp.cbSize = Len(idp)
idp.himl = m_hIml
idp.hdcDst = hdc
idp.rgbBk = -1
idp.x = xPixels
idp.y = yPixels
idp.i = 0
idp.fState = ILS_ALPHA
idp.Frame = 128
ImageList_DrawIndirect(idp)
It's VB6, but it doesn't matter - in fact, we are working only with pure WinAPI at this point.
That code works perfectly for me in my app. By that I mean that I have the same code in my app, with the sole exception that I am not setting rgbBk
.
My guess is that somehow the images in your image list have lost their alpha channel.
I'm surprised to see that you set rgbBk
because I believe it has no effect for images with alpha.
精彩评论