What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [?] Transparent bitmap in a pop-up menu

[?] Transparent bitmap in a pop-up menu
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
O.P. RE: [?] Transparent bitmap in a pop-up menu
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);
}
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
08-22-2007 10:42 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[?] Transparent bitmap in a pop-up menu - by Matti on 08-21-2007 at 07:14 PM
RE: [?] Transparent bitmap in a pop-up menu - by matty on 08-21-2007 at 07:22 PM
RE: [?] Transparent bitmap in a pop-up menu - by Matti on 08-22-2007 at 10:42 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On