I have a COM shell extension that adds an item to the Windows Explorer context menu and use a BMP image with a transparent background as the icon.
To set the image I use SetMenuItemBitmaps
like so:
[DllImport("user32.dll", ExactSpelling = true)]
internal static extern int SetMenuItemBitmaps(IntPtr hMenu,uint uPosition,uint uFlags,IntPtr hBitmapUnchecked,IntPtr hBitmapChecked);
SetMenuItemBitmaps(owner.hMenu,(uint)pos,Win32.MF_BYPOSITION,bitmap.GetHbitmap(),IntPtr.Zero);
My problem is this - when the icon first appears it looks fine but after hovering above it the icon's background becomes white (instead of transparent) and remains white until I reopen the menu.
I have tried setting both non default values in the parameters "hBitmapUnchecked", "hBitmapChecked" - but it doesn't seem to make any difference. The outcome remains the same.
This is the icon image before the hover (zoomed to 400%):
This is the icon image after the hover:
Note the white background around the second image!
So far, I've failed to find anything relevant on google. Is there some other way to set the icon to avoid this annoying background?