tags:

views:

15

answers:

0

Here is my code. I still cannot assign the icon to my toolbar button.

void CRebarHandler::setButtonMenu(){
TBBUTTONINFO inf;
inf.cbSize=sizeof(inf);
inf.dwMask = TBIF_IMAGE;
inf.fsStyle= BTNS_AUTOSIZE;




    HINSTANCE module        = _AtlBaseModule.GetResourceInstance(); 
//if(module)
    //MessageBox(NULL, L"module is OK ", MB_ICONASTERISK);


HICON hMotley           = LoadIcon(module, MAKEINTRESOURCE(IDI_ICON1));
//if(hMotley)
    //MessageBox(NULL, L"hMotley is OK ", MB_ICONASTERISK);

HIMAGELIST m_hImageList = ImageList_Create(32,32, ILC_COLOR16, 1, 0);
//if(m_hImageList)
    //MessageBox(NULL, L"m_hImageList is OK ", MB_ICONASTERISK);

//int iImageIndex = ImageList_AddIcon(m_hImageList, hMotley);

SendMessage(m_hWndToolbar, CCM_SETVERSION, (WPARAM) 2, 0);  
SendMessage(m_hWndToolbar, TB_SETIMAGELIST, 3, (LPARAM)m_hImageList);

inf.iImage = ImageList_AddIcon(m_hImageList, hMotley);
SendMessage(m_hWndToolbar, TB_SETBUTTONINFO, m_buttonID, (LPARAM)&inf);

}