BM_SETIMAGE Message

Associates a new image (icon or bitmap) with the button.

Syntax

To send this message, call the SendMessage function as follows.
lResult = SendMessage(    // returns LRESULT in lResult
   hWndControl,           // (HWND) handle to destination control
   BM_SETIMAGE,           // (UINT) message ID
   wParam,                // = () wParam; 
   lParam                 // = () lParam;
);

Parameters

wParam
The type of image to associate with the button. This parameter can be one of the following values:
  • IMAGE_BITMAP
  • IMAGE_ICON
lParam
A handle to the image to associate with the button.

Return Value

The return value is a handle to the image previously associated with the button, if any; otherwise, it is NULL.

Remarks

The appearance of text, an icon, or both on a button control depends on the BS_ICON and BS_BITMAP styles, and whether the BM_SETIMAGE message is called. The possible results are as follows:

BS_ICON or BS_BITMAP Set?BM_SETIMAGE Called?Result
YesYesShow icon only.
NoYesShow icon and text.
YesNoShow text only.
NoNoShow text only

Message Information

HeaderDeclared in Winuser.h, include Windows.h
Minimum operating systems Windows 95, Windows NT 4.0

See Also

BM_GETIMAGE
Tags :


Community Content

Jakub Nietrzeba
BM_SETIMAGE
BM_SETIMAGE on button without BS_ICON or BS_BITMAP flag has no effect on Windows XP
Tags :

Jens_0
Text is lost

As Jakub correctly said, BS_ICON or BS_BITMAP needs to be set to display a bitmap. According to the table below, then there's no possiblity to have image and text at the same time??

Thanks

Tags :

alweis
Works fine Win 7 RC
This function appears to work exactly as documented by this page in Win 7 RC. The table is a bit confusing but both text and image should display if neither BS_ICON or BS_BITMAP is not set.
Tags :

Page view tracker