Here is a picture of my program:
As you can see, the icons aren't transparent, simply white. This is problematic, because I've coded the list-view to alternate colors and the white looks very ugly on grey.
Right now, I'm using a bitmap with a pink background for the icons, and using the pink color as a mask. Here's the code for my HIMAGELIST:
hImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, ICON_COUNT, 0);
if (hImageList != NULL)
{
HBITMAP hBitmap = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_ICONS));
if (hBitmap != NULL)
{
ImageList_AddMasked(hImageList, hBitmap, RGB(0xFF, 0, 0xFF)); // pink mask
DeleteObject(hBitmap);
}
ImageList_SetBkColor(hImageList, CLR_NONE);
}
ListView_SetImageList(hWnd, hImageList, LVSIL_SMALL);
Here is the code for the list-view's Custom Draw (the alternating colors)
LRESULT WhiteFlagUI::PaintListView(__in HWND hwndListView, __in LPARAM lParam)
{
LPNMLVCUSTOMDRAW lpListDraw = reinterpret_cast<LPNMLVCUSTOMDRAW>(lParam);
switch (lpListDraw->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
return (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYSUBITEMDRAW);
break;
case (CDDS_PREPAINT | CDDS_ITEM):
{
RECT rect;
if (ListView_GetSubItemRect(hwndListView, lpListDraw->nmcd.dwItemSpec, lpListDraw->iSubItem, LVIR_BOUNDS, &rect))
{
COLORREF color;
// determine color
if (lpListDraw->nmcd.uItemState & CDIS_SELECTED)
color = RGB(157, 173, 215);
else if (lpListDraw->nmcd.dwItemSpec % 2)
color = RGB(240, 240, 240);
else
color = RGB(255, 255, 255);
// paint
HBRUSH hBrush = CreateSolidBrush(color);
if (hBrush != NULL)
{
FillRect(lpListDraw->nmcd.hdc, &rect, hBrush);
DeleteObject(hBrush);
}
// return color info
lpListDraw->clrTextBk = color;
return CDRF_NEWFONT;
}
}
break;
}
return CDRF_DODEFAULT;
}
Quite frankly, I'm completely lost as to how to approach this. Does anyone have any ideas?