How to use 256 Color Bitmaps in ImageList (Win32 SDK solution) | CodeGuru

How to use 256 Color Bitmaps in ImageList (Win32 SDK solution)

–> This is how to use 256(or 16bit, 24bit)-color bitmaps in ImageLists for ListViews, TreeViews, etc… Usually you use something like this to load/create your imagelist: hScreens = ImageList_LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(BMP_SCREENS), 100, CLR_NONE, CLR_NONE, IMAGE_BITMAP, LR_LOADTRANSPARENT); However it will always convert your bitmap to 16 colors or fail. now, simply replace it with this code: HBITMAP […]

Written By
CodeGuru Staff
CodeGuru Staff
Nov 7, 1998
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

–>

This is how to use 256(or 16bit, 24bit)-color bitmaps in ImageLists for
ListViews, TreeViews, etc…

Usually you use something like this to load/create your imagelist:

hScreens = ImageList_LoadImage(GetModuleHandle(NULL),
 MAKEINTRESOURCE(BMP_SCREENS), 100, CLR_NONE, CLR_NONE, IMAGE_BITMAP,
 LR_LOADTRANSPARENT);

However it will always convert your bitmap to 16 colors or fail.
now, simply replace it with this code:

HBITMAP hScrBM;

hScreens = ImageList_Create(100, 70, ILC_COLOR8, 0, 999);
hScrBM = LoadImage(GetModuleHandle(NULL),
 MAKEINTRESOURCE(BMP_SCREENS256), IMAGE_BITMAP, 0, 0,
 LR_LOADTRANSPARENT);

ImageList_Add(hScreens, hScrBM, NULL);

DeleteObject(hScrBM);

Of course, you can use other values instead of ILC_COLOR8 (256color):
ILC_COLOR16, ILC_COLOR24, … (see “ImageList_Create()” online help in
VC++)

Hope this helps…

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.