CreateMappedBitmap function (commctrl.h)

Creates a bitmap for use in a toolbar.

Syntax

HBITMAP CreateMappedBitmap(
       HINSTANCE  hInstance,
       INT_PTR    idBitmap,
       UINT       wFlags,
  [in] LPCOLORMAP lpColorMap,
       int        iNumMaps
);

Parameters

hInstance

Type: HINSTANCE

Handle to the module instance with the executable file that contains the bitmap resource.

idBitmap

Type: INT_PTR

Resource identifier of the bitmap resource.

wFlags

Type: UINT

Bitmap flag. This parameter can be zero or the following value:

Value Meaning
CMB_MASKED
Uses a bitmap as a mask.

[in] lpColorMap

Type: LPCOLORMAP

Pointer to a COLORMAP structure that contains the color information needed to map the bitmaps. If this parameter is NULL, the function uses the default color map.

iNumMaps

Type: int

Number of color maps pointed to by lpColorMap.

Return value

Type: HBITMAP

Returns the handle to the bitmap if successful, or NULL otherwise. To retrieve extended error information, call GetLastError.

Remarks

The function creates a new bitmap using the bitmap data and colors specified by the bitmap resource and the color mapping information.

This function is fully supported only for images with color maps; that is, images with 256 or fewer colors.

Examples

The following example code creates a bitmap from a resource and makes the color black appear transparent by mapping it to the system color for a button face.

DWORD backgroundColor = GetSysColor(COLOR_BTNFACE);
COLORMAP colorMap;
colorMap.from = RGB(0, 0, 0);
colorMap.to = backgroundColor;
HBITMAP hbm = CreateMappedBitmap(g_hInst, IDB_BITMAP1, 0, &colorMap, 1);

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header commctrl.h
Library Comctl32.lib
DLL Comctl32.dll
API set ext-ms-win-shell-comctl32-init-l1-1-1 (introduced in Windows 10, version 10.0.14393)