CTreeCtrl icon 背景透明 解决方法

CTreeCtrl加ICON图标的代码片段如下:

这里要注意:Create的第二个参数

(1)颜色深度一定要选择正确eg,ILC_COLOR32

(2)或上掩码处理ILC_MASK,对ICON来说会使得其黑色的背景透明

    m_imgList.Create(16,16,ILC_COLOR32|ILC_MASK,2,0);
m_imgList.Add(AfxGetApp()
->LoadIcon(IDI_ICON_PLUS));
m_imgList.Add(AfxGetApp()
->LoadIcon(IDI_ICON_MINUS));
m_tree.SetImageList(
&m_imgList,TVSIL_NORMAL);
m_tree.InsertItem(_T(
"root"));

  

原文地址:https://www.cnblogs.com/oyjj/p/2132890.html