Adding icons to an imagelist that is used in a listctrl
-
I use a CListCtrl on a dialog. The problem is that the background of the icons is somehow changed to black when the dialog pops up. But the background is supposed to be transparent. Who knows how to prevent this? This is the code that i use:
CMyDlg::OnInitDialog() { m_imageList.Create(32, 32, ILC_COLOR4, 2, 2); //adding the icons for(int i=0; i<2; i++) { int nID = GetIconID( i ); //code taken from CWinApp::LoadIcon(int nID ) HICON hIcon = ::LoadIcon(AfxFindResourceHandle(MAKEINTRESOURCE(nID), RT_GROUP_ICON), MAKEINTRESOURCE(nID)); m_imageList.Add(hIcon); } m_listCtrl.SetImageList(&m_imageList, LVSIL_NORMAL); //inserting items in the listctrl for(int nIndex=0; nIndex<2; nIndex++) { m_type.InsertItem(nIndex, "some text", nIndex); nIndex++; } }
Thanks in advance, Jochem -
I use a CListCtrl on a dialog. The problem is that the background of the icons is somehow changed to black when the dialog pops up. But the background is supposed to be transparent. Who knows how to prevent this? This is the code that i use:
CMyDlg::OnInitDialog() { m_imageList.Create(32, 32, ILC_COLOR4, 2, 2); //adding the icons for(int i=0; i<2; i++) { int nID = GetIconID( i ); //code taken from CWinApp::LoadIcon(int nID ) HICON hIcon = ::LoadIcon(AfxFindResourceHandle(MAKEINTRESOURCE(nID), RT_GROUP_ICON), MAKEINTRESOURCE(nID)); m_imageList.Add(hIcon); } m_listCtrl.SetImageList(&m_imageList, LVSIL_NORMAL); //inserting items in the listctrl for(int nIndex=0; nIndex<2; nIndex++) { m_type.InsertItem(nIndex, "some text", nIndex); nIndex++; } }
Thanks in advance, Jochem -
not sure but it could be this Jochem wrote: m_imageList.Create(32, 32, ILC_COLOR4, 2, 2); try using ILC_COLOR16|ILC_MASK instead of ILC_COLOR4 Rob Whoever said nothing's impossible never tried slamming a revolving door!