dscott
June 16th, 1999, 07:50 PM
Hi,
Currently I am extracting an icon from an excutable and adding that icon to a toolbar button within my application. The following code shows how I accomplish this:
void CZManagerApp::LoadUserDefinedToolBarIcons()
{
CZString strTool;
HICON hIconSmall;
ICONINFO IconInfo;
TBBUTTON tbButton;
m_uStartID = m_uCommandID;
strTool = "some executable file.exe";
::ExtractIconEx((LPCTSTR)strTool, 0, NULL, &hIconSmall, 1);
::GetIconInfo(hIconSmall, &IconInfo);
// Where m_TBControl is of type "CToolBarCtrl"
tbButton.iBitmap = m_TbControl.AddBitmap(1, CBitmap::FromHandle(IconInfo.hbmColor));
tbButton.idCommand = m_uCommandID;
tbButton.fsState = TBSTATE_ENABLED;
tbButton.fsStyle = TBSTYLE_BUTTON;
tbButton.dwData = 0;
tbButton.iString = 0;
m_TbControl.AddButtons(1, &tbb);
DestroyIcon(hIconSmall);
m_uCommandID++;
}
This works great except for when the icon is transparent in areas then I get the transparent areas showing up as black. Does anyone know what I'm missing?
Dan
Currently I am extracting an icon from an excutable and adding that icon to a toolbar button within my application. The following code shows how I accomplish this:
void CZManagerApp::LoadUserDefinedToolBarIcons()
{
CZString strTool;
HICON hIconSmall;
ICONINFO IconInfo;
TBBUTTON tbButton;
m_uStartID = m_uCommandID;
strTool = "some executable file.exe";
::ExtractIconEx((LPCTSTR)strTool, 0, NULL, &hIconSmall, 1);
::GetIconInfo(hIconSmall, &IconInfo);
// Where m_TBControl is of type "CToolBarCtrl"
tbButton.iBitmap = m_TbControl.AddBitmap(1, CBitmap::FromHandle(IconInfo.hbmColor));
tbButton.idCommand = m_uCommandID;
tbButton.fsState = TBSTATE_ENABLED;
tbButton.fsStyle = TBSTYLE_BUTTON;
tbButton.dwData = 0;
tbButton.iString = 0;
m_TbControl.AddButtons(1, &tbb);
DestroyIcon(hIconSmall);
m_uCommandID++;
}
This works great except for when the icon is transparent in areas then I get the transparent areas showing up as black. Does anyone know what I'm missing?
Dan