Search code examples
winapiuser32

SetMenuItemBitmaps BMP transparent colour


How do I set the transparent colour of a BMP image for SetMenuItemBitmaps, I'm currently using LoadImage with uType as IMAGE_BITMAP and fuLoad as LR_LOADFROMFILE + LR_LOADTRANSPARENT?


Solution

  • LoadImage documents the LR_LOADTRANSPARENT flag as:

    Retrieves the color value of the first pixel in the image and replaces the corresponding entry in the color table with the default window color (COLOR_WINDOW). All pixels in the image that use that entry become the default window color.

    Choose a color for the first pixel that isn't used anywhere else, and paint all portions of the bitmap that are supposed to be transparent using that color.

    Keep in mind that this flag is not meaningful for bitmaps with a color depth above 8bpp.