Thanks for that, matty. Unfortunately, it doesn't seem to work. The transparency isn't getting applied. I don't know if this is caused by the LoadImage function or by the fact I pass it to SetMenuItemInfo to set the bitmap... :-\
According to LoadImage, the pink should be replaced by the default window color (which is white #FFFFF). However, it doesn't do that. The bitmap is getting placed correctly in the menu but it isn't transparent.
Following is the code I use to do the bitmap loading and set it to the menu item.
code:
var Bitmaps = new Array(); //Global array storing the bitmaps by their path, so I can destroy them when they're no longer needed.
var hBitmap = LoadBitmap("Images\\logview.bmp"); //Load the bitmap
SetMenuItemBitmap(hMenu, i, hBitmap); //hMenu is a pop-up handle, i is the menu item position (in my case, it equals 1 to specify the 2nd item)
function LoadBitmap(sPath) {
var IMAGE_BITMAP = 0;
var LR_LOADFROMFILE = 0x10;
var LR_LOADTRANSPARENT = 0x20;
var sFilePath = PathAppend(MsgPlus.ScriptFilesPath, sPath); //PathAppend is a function to append two paths by calling PathAppendW in shlwapi.
var hImage = Interop.Call('user32', 'LoadImageW', 0, sFilePath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_LOADTRANSPARENT);
if(hImage !== 0) Bitmaps[sPath] = hImage; //Adds the bitmap handle to the global array.
return hImage;
}
function SetMenuItemBitmap(hMenu, uItem, hBitmap) {
var MIIM_BITMAP = 0x80;
var MENUITEMINFO = Interop.Allocate(48);
with(MENUITEMINFO) {
WriteDWORD(0, Size);
WriteDWORD(4, MIIM_BITMAP);
WriteDWORD(44, hBitmap);
}
Interop.Call("user32", "SetMenuItemInfoW", hMenu, uItem, 1, MENUITEMINFO);
}