LoadBitmap

The LoadBitmap function loads the specified bitmap resource from a module's executable file. This function has been superseded by the LoadImage function.

HBITMAP LoadBitmap(
  HINSTANCE hInstance,  // handle to application instance
  LPCTSTR lpBitmapName  // address of bitmap resource name
);
 

Parameters

hInstance
Handle to the instance of the module whose executable file contains the bitmap to be loaded.
lpBitmapName
Pointer to a null-terminated string that contains the name of the bitmap resource to be loaded. Alternatively, this parameter can consist of the resource identifier in the low-order word and zero in the high-order word. The MAKEINTRESOURCE macro can be used to create this value.

Return Values

If the function succeeds, the return value is the handle to the specified bitmap.

If the function fails, the return value is NULL.

Windows NT: To get extended error information, call GetLastError.

Remarks

If the bitmap pointed to by the lpBitmapName parameter does not exist or there is insufficient memory to load the bitmap, the function fails.

An application can use the LoadBitmap function to access the predefined bitmaps used by the Win32 API. To do so, the application must set the hInstance parameter to NULL and the lpBitmapName parameter to one of the following values:

Bitmap Name Bitmap Name
OBM_BTNCORNERS OBM_OLD_RESTORE
OBM_BTSIZE OBM_OLD_RGARROW
OBM_CHECK OBM_OLD_UPARROW
OBM_CHECKBOXES OBM_OLD_ZOOM
OBM_CLOSE OBM_REDUCE
OBM_COMBO OBM_REDUCED
OBM_DNARROW OBM_RESTORE
OBM_DNARROWD OBM_RESTORED
OBM_DNARROWI OBM_RGARROW
OBM_LFARROW OBM_RGARROWD
OBM_LFARROWD OBM_RGARROWI
OBM_LFARROWI OBM_SIZE
OBM_MNARROW OBM_UPARROW
OBM_OLD_CLOSE OBM_UPARROWD
OBM_OLD_DNARROW OBM_UPARROWI
OBM_OLD_LFARROW OBM_ZOOM
OBM_OLD_REDUCE OBM_ZOOMD

Bitmap names that begin with OBM_OLD represent bitmaps used by 16-bit versions of Windows earlier than 3.0.

For an application to use any of the OBM_ constants, the constant OEMRESOURCE must be defined before the WINDOWS.H header file is included.

The application must call the DeleteObject function to delete each bitmap handle returned by the LoadBitmap function.

Windows CE: When you initialize a bitmap by using the LoadBitmap function, the bitmap is read-only. When you select the bitmap into a device context, you cannot modify the device context (for instance, by drawing text into it) because that would require the ability to write to the bitmap.

Windows CE does not support the OBM_* values in the lpBitmapName parameter.

Windows CE 1.0 supports only a 2 bit gray scale palette, so you can use only one bit per pixel (monochrome .bmp) or two bit per pixel (.2bp) bitmaps.

See Also

Bitmaps Overview, Bitmap Functions, CreateBitmap, DeleteObject, LoadCursor, LoadIcon, LoadImage, MAKEINTRESOURCE