Icon background when using ExtractIcon
Posted on 2001-07-26
I'm using Visual C++ 6.0 on Windows98. I'm writing an application that has a tree view and a list view, much the same as Windows Explorer. I'm trying to add a basic computer icon to the tree control in the tree view. I've created a few of my own icons and added them through the resource editor. They all appear fine in the tree control. I wanted to use a standard icon for a computer and chose to use the shell32.dll.
In the code, OnInitialUpdate I create a CImageList with the following construction:
m_ImageList.Create(20, 20, ILC_COLOR32, 16, 4);
I then load my personal icons:
hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_MY_ICON));
nMyIconIndex = m_ImageList.Add(hIcon);
like I said, this works fine and the icons appear on the tree control.
I then try to do the standard icon this way:
hIcon = ::ExtractIcon(AfxGetResourceHandle(), "c:\\windows\\system\\shell32.dll", 15);
nLoadedIcon = m_ImageList.Add(hIcon);
When I display the icon in the tree control, the icon is visible, however the background of the icon is black. Since the tree view background is white, it is easy to see the black background of the icon. I've tried to use the m_ImageList.SetBkColor(CLR_NONE) and m_ImageList.SetBkColor(RGB(0,0,0)) and neither one yielded any difference.
How can I get rid of that black background on the standard icon that I load via ExtractIcon.
Or is there somewhere I could get a .ico file that corresponds to the standard icons in windows? Then I could just add the .ico file right into the resource editor.
Any help would be greatly appreciated.