Trying to Create a ToolBar with an ImageList, not working.
- by blaquee
Im trying to get my toolbar to work, with an imagelist. The images are png's and are individual So i was adding them in the ImageList in succession. But it wasnt 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 );
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 );
return NULL;
Is there something im missing? or not doing?