Okay, looking for some expert help here!
I have a right-click pop-up menu with some nifty features, but now I want to make it even nicer by placing images in front of the items. I can do this by loading a bitmap using LoadBitmap() and then use SetMenuItemBitmap() to set the bitmaps to the menu item. No problem at all to do this, the only problem is that the bitmaps aren't transparent. I know it has to be possible (how do the others do it else?) but I'm afraid my skills are just a tiny bit too less to do this. I guess I'll need to use GDI for this to make a certain color (like violet #FF00FF) transparent in the bitmap, so if anyone can help me with this, I'd really appreciate it!
This is what I use to place the bitmaps in the menu item at the moment:
code:
var hBitmapSrc = LoadBitmap(/* Path to file here */, 16, 16);
var MF_BYPOSITION = 0x400;
var Result = Interop.Call("user32", "SetMenuItemBitmaps", hMenu, i, MF_BYPOSITION, hBitmapSrc, hBitmapSrc); /* hMenu is the pop-up menu handle, i is the null-based item position */
function LoadBitmap(sPath, nWidth, nHeight) {
var IMAGE_BITMAP = 0;
var LR_LOADFROMFILE = 0x10;
var LR_SHARED = 0x8000;
var hInst = Interop.Call('kernel32', 'GetCurrentProcess');
var hImage = Interop.Call('user32', 'LoadImageW', hInst, sPath, IMAGE_BITMAP, nWidth, nHeight, LR_LOADFROMFILE | LR_SHARED);
return hImage;
}