What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [PROBLEM] Icons in menu have black backgrounds on XP

[PROBLEM] Icons in menu have black backgrounds on XP
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
O.P. Huh?  [PROBLEM] Icons in menu have black backgrounds on XP
Hi,

I faced this problem already some time ago during Countdown Live 2 development, but I thought it was simply caused by my terrible coding. Maybe it is caused by it, but after so many revisions I think there has to be something else with this...

This is what my script does:
  1. I create a popup menu with CreatePopupMenu.
  2. I add a string menu item to it with AppendMenu.
  3. I create a HBITMAP from an image:
    1. I create a GDI+ Bitmap object from an image file (in my case, "test.gif") using GdipCreateBitmapFromFile.
    2. I create a HBITMAP from the Bitmap object using GdipCreateHBITMAPFromBitmap with 0xFF000000 0x00000000 as background parameter (totally transparent, according to Matty Matty made a mistake, PLSC updated).
  4. I add the HBITMAP to the menu item:
    1. I create a partial MENUITEMINFO structure with the cbSize, fMask and hbmpItem members set.
    2. I use SetMenuItemInfo to assign this structure to the menu item.
  5. I let the menu pop up when the user clicks on a button using TrackPopupMenu.
This works great! I can have beautiful icons next to my menu items, I even made a whole class which simplifies this process. I was so excited about this until... I sent it to my testers. First response: cool, but the menu item icons have a black background. The cause? I run Vista, my testers have XP. One of my testers also runs Vista and he confirmed that it works on his Vista PC, but not on his XP system.
I received this screenshot from one of my XP testers: (cropped)
[Image: menu-icon-problem.png]
I have spent hours trying to figure out why this was happening, but I couldn't find anything. Finally, I gave up and added a Windows version check so that the images would only be added on Vista or higher.

Since then, I periodically gave this problem another attempt to solve it, but today I decided to stop waisting time on it for much longer. I attached an example script of this problem, and if someone can find the missing link and fix this on XP... please, share your discoveries! :)

.plsc File Attachment: Menu Icon Problem.plsc (4.27 KB)
This file has been downloaded 173 time(s).

This post was edited on 01-04-2008 at 04:19 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
01-04-2008 04:04 PM
Profile E-Mail PM Web Find Quote Report
phalanxii
Full Member
***


Posts: 146
Reputation: 5
32 / Male / Flag
Joined: Aug 2006
Status: Away
RE: [PROBLEM] Icons in menu have black backgrounds on XP
From my experimenting, it seems that only the blue component of your background parameter affects the background. Changing it to 0x000000FF yields a bright blue, and values in between (like 0x0000007F) produce dark blues. The alpha, red and green channels seem to be ignored and taken as 0.

I don't know whether it's a problem with your image or a bug with GDI+, but I found some links for you of other people having the same problem: [1] and [2].
01-05-2008 06:10 AM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
O.P. RE: [PROBLEM] Icons in menu have black backgrounds on XP
Aww... you're giving me headaches, phalanxii! :P
Unfortunately, I can't do testing myself as all PCs here at home are upgraded to Vista.

So, from what I understand, there are problems with converting a GDI+ Bitmap to a HBITMAP. But, let's say that instead of preserving transparency, would it be easier to create a color mask and create transparency by filtering out one color? Would that solve the need of using GDI+ Bitmaps? Would it be possible in fact? :P

UPDATE: Okay, markee and NanaFreak use exactly the same function for their Web2Live script to add new signatures to the list. They modify the image list and it works great. I try to add it to a menu item and it fails. So, maybe it's not the bitmap loading, but the bitmap drawing... I guess that we'll have to look at the 4th step, namely the the SetMenuItemInfo part. Any known issues with that bit? ^o)

UPDATE 2: Hmm... this looks like an interesting MSDN article: Vista Style Menus. It looks like it's really caused by the menus! :O

After a read, I think it's clear to me that Vista causes the icons to work, while lower versions don't support it. Maybe an owner-draw could fix it... but I doubt Plus! scripts can actually handle those! :(

Therefore, I'd like to submit a request to Patchou:
  • Make the menus of MenuButtonControls editable in run-time. Something like PlusWnd::MenuButton_SetMenu(CtrlId, MenuXML) would be great! :)
  • Add some kind of support for images in menus. Plus! already does an owner-draw on the menu, so why can't you use that to draw images on it? You already did so with ComboBoxControls! ;)

This post was edited on 01-05-2008 at 02:49 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
01-05-2008 11:19 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


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