EDN Admin
Well-known member
Hi,
We want to load an icon and want to display that icon in a toolbar button. But we are unable display the icon on a dynamically added toolbar button. This was working fine with the old CToolbar class. Please have a look at the given sample code. We set PNG image on Toolbar. Might be it failed in updating existing png image with HBITMAP.
//hIcon is handler of new icon image
if(hIcon)
{
CMFCToolBarImages *pImgList;
pImgList = mytoolbar.GetImages();
int Index = mytoolbar.CommandToIndex(nID);
CMFCToolBarButton *pButtonInfo = mytoolbar.GetButton(nIndex);
//UpdateImg is failed in updating existing image with icon
pImgList->UpdateImage(pButtonInfo->GetImage(),(HBITMAP)hIcon);
mytoolbar.SetUserImages(pImgList);
mytoolbar.Invalidate(TRUE);
:
estroyIcon( hIcon );
}
View the full article
We want to load an icon and want to display that icon in a toolbar button. But we are unable display the icon on a dynamically added toolbar button. This was working fine with the old CToolbar class. Please have a look at the given sample code. We set PNG image on Toolbar. Might be it failed in updating existing png image with HBITMAP.
//hIcon is handler of new icon image
if(hIcon)
{
CMFCToolBarImages *pImgList;
pImgList = mytoolbar.GetImages();
int Index = mytoolbar.CommandToIndex(nID);
CMFCToolBarButton *pButtonInfo = mytoolbar.GetButton(nIndex);
//UpdateImg is failed in updating existing image with icon
pImgList->UpdateImage(pButtonInfo->GetImage(),(HBITMAP)hIcon);
mytoolbar.SetUserImages(pImgList);
mytoolbar.Invalidate(TRUE);
:

}
View the full article