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:
- I create a popup menu with CreatePopupMenu.
- I add a string menu item to it with AppendMenu.
- I create a HBITMAP from an image:
- I create a GDI+ Bitmap object from an image file (in my case, "test.gif") using GdipCreateBitmapFromFile.
- 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).
- I add the HBITMAP to the menu item:
- I create a partial MENUITEMINFO structure with the cbSize, fMask and hbmpItem members set.
- I use SetMenuItemInfo to assign this structure to the menu item.
- 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)
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!