Trying to Create a ToolBar with an ImageList, not working.

Posted by blaquee on Stack Overflow See other posts from Stack Overflow or by blaquee
Published on 2010-04-08T02:36:44Z Indexed on 2010/04/08 2:43 UTC
Read the original article Hit count: 345

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about toolbar

Related posts about win32