Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer


Associates a new bitmap with the static control.

HBITMAP SetBitmap(
   HBITMAP hBitmap 


Handle of the bitmap to be drawn in the static control.

Return Value

The handle of the bitmap previously associated with the static control, or NULL if no bitmap was associated with the static control.


The bitmap will be automatically drawn in the static control. By default, it will be drawn in the upper-left corner and the static control will be resized to the size of the bitmap.

You can use various window and static control styles, including the following:

  • SS_BITMAP   Use this style always for bitmaps.
  • SS_CENTERIMAGE   Use to center in the static control. If the image is larger than the static control, it will be clipped. If it is smaller than the static control, the empty space around the image will be filled by the color of the pixel in the upper left corner of the bitmap.


CStatic myStatic;

// Create a child bitmap static control.
myStatic.Create(_T("my static"), 

// Set the bitmap of the static control to be the 
// system check-mark bitmap.
myStatic.SetBitmap( ::LoadBitmap(NULL, MAKEINTRESOURCE(OBM_CHECK)) );

See Also

CStatic Overview | Class Members | Hierarchy Chart | CStatic::GetBitmap | STM_SETIMAGE | Bitmaps

© 2016 Microsoft