I am trying to get my toolbar to work with an ImageList
. The images are individual PNGs, so I was adding them in the ImageList
in succession, Bbt it wasn't working. Here is the code to add the Image
to the ImageList
:
HIMAGELIST CreateToolBarImages(HINSTANCE hInst)
{
HIMAGELIST v_ImageList = NULL;
// IMAGE_LIST v_Img;
HICON hIcon;
HBITMAP hBit;
COLORMAP cMap;
COLORREF fromColor = RGB( 0,0,0 );
InitCommonControls();
v_ImageList = ImageList_Create(32, 32, ILC_MASK, 1, 1);
cMap.from = fromColor;
cMap.to = ::GetSysColor(COLOR_BTNFACE);
hBit = CreateMappedBitmap(hInst, IDB_CONSOLE, 0, &cMap, 1);
// hBit = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_CONSOLE));
consoleImg = ImageList_Add(v_ImageList, hBit, 0);
if (consoleImg == -1)
return NULL;
DeleteObject(hBit);
// [edit Franci Penov]
return v_ImageList;
}
Then I create The ToolBar, but it fails at the Image function.
HWND CreateToolBarButton(HWND hWndParent)
{
const int ImageID = 0;
const int numB = 1;
COLORREF iColor;
HWND hToolBar = CreateWindowEx(0,
TOOLBARCLASSNAME,
NULL,
WS_CHILD |TBSTYLE_LIST |TBSTYLE_FLAT | WS_VISIBLE,
0,0,0,0,
hWndParent,
NULL,
g_hInst,
NULL);
if (hToolBar == NULL)
return NULL;
HIMAGELIST ImgList = CreateToolBarImages(g_hInst);
if (ImgList == NULL)
MessageBox( hWndParent, L"No Tool Images", L"BOB", MB_OK );
// [edit Franci Penov]
return hToolBar;
}
Is there something I am missing or not doing?