Home > Back-end >  XP Popup Menu Icons not Transparent when highlighted
XP Popup Menu Icons not Transparent when highlighted

Time:12-07

I know XP is old, but I just have to know the issue here.

I don't see a way to provide a popup menu with anything like an icon or bitmap with a mask, only a bitmap. So, if I use a compatible bitmap, it will look transparent when the selection bar is not highlighting it, but when highlighted the entire graphic still shows (with a square button face color around it).

If I use a 32bit DIB with alpha, the transparent item just shows black (whereas Windows 10 handles the transparency fine - I presume Vista and Win7 would, too).

If I manually set all the A's to 0 in the DIB, it is still black (on Win10, the images where color would normally be appear white - I would have thought it would be transparent).

Anyway, was there ever a way to provide an icon (since it has a mask), or a bitmap with mask, to a menu so things like XP can handle it automatically (no owner draw)?

Is there a way to force loading of an .ICO file to be the 256 color version instead of the 32bit RGB/A version? I don't have a 24bit RGB graphic in the .ICO, so maybe XP would pick that if it existed instead?

I know GDI doesn't support alpha in all cases, but sometimes it does, and it appears the Windows version matters as well.

Does someone have a background on this, and can tell if this is a known XP issue with 32bit bitmaps?

CodePudding user response:

On XP you must custom draw but not the entire thing, just the bitmap/icon.

On Windows 95/NT4 the only way to do this properly is to custom draw the entire menu item. Before Vista the menu look only changed once, the addition of flat menus in XP, so custom draw everything is certainly possible.

Some time around Windows 98/2000 the ability to set MENUITEMINFO.hbmpItem to HBMMENU_CALLBACK was added. Use DrawIconEx or a image list.

Vista added support for 32bit ARGB bitmaps. You should not use the callback method here because that will disable the new visual style.

See also:

  • Related