One thing that always bugged me about
ImageLists
is that when you load a 256 color bitmap into them, they use the half-tone palette, which likely could screw up your bitmap's colors. Yet, Windows Explorer is magically able to display icons in its right pane list control (coming from an
ImageList
) in full color. So how does it do this?
The following methods will not work:
(MFC Version)
BOOL CImageList::Create( UINT nBitmapID,
int cx,
int nGrow,
COLORREF crMask)
BOOL CImageList::Create( LPCTSTR lpszBitmapID,
int cx,
int nGrow,
COLORREF crMask)
(Win32 Version)
HIMAGELIST ImageList_LoadBitmap( HINSTANCE hi,
LPCTSTR lpbmp,
int cx,
int cGrow,
COLORREF crMask)
HIMAGELIST ImageList_LoadImage( HINSTANCE hi,
LPCSTR lpbmp,
int cx,
int cGrow,
COLORREF crMask,
UINT uType,
UINT uFlags)
What will work is this:
(MFC Version)
CImageList imgl;
imgl.Create(cx, cy, ILC_MASK | ILC_COLOR32, 0, 0);
CBitmap bmp;
COLORREF rgbTransparentColor;
imgl.Add(&bmp, rgbTransparentColor);
(Win32 Version)
HIMAGELIST himgl = ImageList_Create(cx,
cy,
ILC_MASK | ILC_COLOR32,
0,
0);
HBITMAP hbmp;
COLORREF rgbTransparentColor;
ImageList_AddMasked(himgl, hbmp, rgbTransparentColor);
Copied From:
http://www.ucancode.net/Visual_C_MFC_Example/Add-bitmap-to-CImageList-VC-Example.htm[
^]